<commit_before>#   Copyright 2011 <NAME>
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.

"""Pyhole Launchpad Plugin"""

from launchpadlib.launchpad import Launchpad as LP

from pyhole import utils


class Launchpad(object):
    """Provide access to Canonical's Launchpad"""

    def __init__(self, irc):
        self.irc = irc

    @utils.spawn
    def bugs(self, params=None):
        """Display current bugs for a team (ex: .bugs <project> <team>)"""
        if params:
            launchpad = LP.login_anonymously(
                "pyhole",
                "production",
                self.irc.cache)

            project, team = params.split(" ")
            members = launchpad.people[team]
            proj = launchpad.projects[project]

            for person in members.members:
                self.irc.log.debug("LP: Looking up %s" % person.display_name)
                self._find_bugs(person, proj)
        else:
            self.irc.say(self.bugs.__doc__)

    def _find_bugs(self, person, proj):
        """Lookup Launchpad bugs"""
        bugs = proj.searchTasks(assignee=person)
        for b in bugs:
            self.irc.say("%s %s" % (person.display_name, b.web_link))
            self.irc.say(b.title)<commit_msg>Moved LP login to __init__<commit_after>#   Copyright 2011 <NAME>
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.

"""Pyhole Launchpad Plugin"""

from launchpadlib.launchpad import Launchpad as LP

from pyhole import utils


class Launchpad(object):
    """Provide access to Canonical's Launchpad"""

    def __init__(self, irc):
        self.irc = irc
        self.launchpad = LP.login_anonymously(
            "pyhole",
            "production",
            self.irc.cache)

    @utils.spawn
    def bugs(self, params=None):
        """Display current bugs for a team (ex: .bugs <project> <team>)"""
        if params:
            project, team = params.split(" ")
            members = self.launchpad.people[team]
            proj = self.launchpad.projects[project]

            for person in members.members:
                self.irc.log.debug("LP: Looking up %s" % person.display_name)
                self._find_bugs(person, proj)
        else:
            self.irc.say(self.bugs.__doc__)

    def _find_bugs(self, person, proj):
        """Lookup Launchpad bugs"""
        bugs = proj.searchTasks(assignee=person)
        for b in bugs:
            self.irc.say("%s %s" % (person.display_name, b.web_link))
            self.irc.say(b.title)
{'fraction_non_alphanumeric': 0.09985775248933143, 'fraction_numerical': 0.004551920341394026, 'mean_word_length': 2.464039408866995, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1030134', 'n_tokens_mistral': 1045, 'n_tokens_neox': 976, 'n_words': 335}