

@internationalizeDocstring
def contributors(self, irc, msg, args, cb, nick):
    "<plugin> [<nick>]\n\n        Replies with a list of people who made contributions to a given plugin.\n        If <nick> is specified, that person's specific contributions will\n        be listed.  Note: The <nick> is the part inside of the parentheses\n        in the people listing.\n        "

    def getShortName(authorInfo):
        "\n            Take an Authors object, and return only the name and nick values\n            in the format 'First Last (nick)'.\n            "
        return ('%(name)s (%(nick)s)' % authorInfo.__dict__)

    def buildContributorsString(longList):
        '\n            Take a list of long names and turn it into :\n            shortname[, shortname and shortname].\n            '
        L = [getShortName(n) for n in longList]
        return format('%L', L)

    def sortAuthors():
        "\n            Sort the list of 'long names' based on the number of contributions\n            associated with each.\n            "
        L = list(module.__contributors__.items())

        def negativeSecondElement(x):
            return (- len(x[1]))
        utils.sortBy(negativeSecondElement, L)
        return [t[0] for t in L]

    def buildPeopleString(module):
        '\n            Build the list of author + contributors (if any) for the requested\n            plugin.\n            '
        head = (_('The %s plugin') % cb.name())
        author = _('has not been claimed by an author')
        conjunction = _('and')
        contrib = _('has no contributors listed.')
        hasAuthor = False
        hasContribs = False
        if hasattr(module, '__author__'):
            if (module.__author__ != supybot.authors.unknown):
                author = (_('was written by %s') % utils.web.mungeEmail(str(module.__author__)))
                hasAuthor = True
        if hasattr(module, '__contributors__'):
            contribs = sortAuthors()
            if hasAuthor:
                try:
                    contribs.remove(module.__author__)
                except ValueError:
                    pass
            if contribs:
                contrib = format(_('%s %h contributed to it.'), buildContributorsString(contribs), len(contribs))
                hasContribs = True
            elif hasAuthor:
                contrib = _('has no additional contributors listed.')
        if (hasContribs and (not hasAuthor)):
            conjunction = _('but')
        return ' '.join([head, author, conjunction, contrib])

    def buildPersonString(module):
        '\n            Build the list of contributions (if any) for the requested person\n            for the requested plugin\n            '
        isAuthor = False
        authorInfo = None
        moduleContribs = module.__contributors__.keys()
        lnick = nick.lower()
        for contrib in moduleContribs:
            if (contrib.nick.lower() == lnick):
                authorInfo = contrib
                break
        authorInfo = (authorInfo or getattr(supybot.authors, nick, None))
        if (not authorInfo):
            return (_('The nick specified (%s) is not a registered contributor.') % nick)
        fullName = utils.web.mungeEmail(str(authorInfo))
        contributions = []
        if hasattr(module, '__contributors__'):
            if (authorInfo not in module.__contributors__):
                return (_("The %s plugin does not have '%s' listed as a contributor.") % (cb.name(), nick))
            contributions = module.__contributors__[authorInfo]
        isAuthor = (getattr(module, '__author__', False) == authorInfo)
        (nonCommands, commands) = utils.iter.partition((lambda s: (' ' in s)), contributions)
        results = []
        if commands:
            s = _('command')
            if (len(commands) > 1):
                s = utils.str.pluralize(s)
            results.append(format(_('the %L %s'), commands, s))
        if nonCommands:
            results.append(format(_('the %L'), nonCommands))
        if (results and isAuthor):
            return format(_('%s wrote the %s plugin and also contributed %L.'), (fullName, cb.name(), results))
        elif (results and (not isAuthor)):
            return format(_('%s contributed %L to the %s plugin.'), fullName, results, cb.name())
        elif (isAuthor and (not results)):
            return (_('%s wrote the %s plugin') % (fullName, cb.name()))
        else:
            return (_('%s has no listed contributions for the %s plugin.') % (fullName, cb.name()))
    module = cb.classModule
    if (not nick):
        irc.reply(buildPeopleString(module))
    else:
        nick = ircutils.toLower(nick)
        irc.reply(buildPersonString(module))

dataset/ETHPy150Open ProgVal/Limnoria/plugins/Plugin/plugin.py Plugin.contributors/original