mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-03-29 19:06:49 +01:00
Plugin: simplify the 'contributors' command
- Remove author sorting; it's not obvious that this is being done anyways. - Format author and contributors as separate sentences; conjunctions are messy for code and very language-specific.
This commit is contained in:
parent
930da6a6ba
commit
65e3e18fe2
@ -151,6 +151,7 @@ class Plugin(callbacks.Plugin):
|
|||||||
in the format 'First Last (nick)'.
|
in the format 'First Last (nick)'.
|
||||||
"""
|
"""
|
||||||
return '%(name)s (%(nick)s)' % authorInfo.__dict__
|
return '%(name)s (%(nick)s)' % authorInfo.__dict__
|
||||||
|
|
||||||
def buildContributorsString(longList):
|
def buildContributorsString(longList):
|
||||||
"""
|
"""
|
||||||
Take a list of long names and turn it into :
|
Take a list of long names and turn it into :
|
||||||
@ -158,48 +159,27 @@ class Plugin(callbacks.Plugin):
|
|||||||
"""
|
"""
|
||||||
L = [getShortName(n) for n in longList]
|
L = [getShortName(n) for n in longList]
|
||||||
return format('%L', L)
|
return format('%L', L)
|
||||||
def sortAuthors():
|
|
||||||
"""
|
|
||||||
Sort the list of 'long names' based on the number of contributions
|
|
||||||
associated with each.
|
|
||||||
"""
|
|
||||||
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):
|
def buildPeopleString(module):
|
||||||
"""
|
"""
|
||||||
Build the list of author + contributors (if any) for the requested
|
Build the list of author + contributors (if any) for the requested
|
||||||
plugin.
|
plugin.
|
||||||
"""
|
"""
|
||||||
head = _('The %s plugin') % cb.name()
|
author = getattr(module, '__author__', supybot.authors.unknown)
|
||||||
author = _('has not been claimed by an author')
|
if author != supybot.authors.unknown:
|
||||||
conjunction = _('and')
|
s = _('The %s plugin was written by %s. ' % (cb.name(), author))
|
||||||
contrib = _('has no contributors listed.')
|
else:
|
||||||
hasAuthor = False
|
s = _('The %s plugin has not been claimed by an author. ')
|
||||||
hasContribs = False
|
|
||||||
if hasattr(module, '__author__'):
|
contribs = getattr(module, '__contributors__', {})
|
||||||
if module.__author__ != supybot.authors.unknown:
|
if contribs:
|
||||||
author = _('was written by %s') % str(module.__author__)
|
s += format(_('%s %h contributed to it.'),
|
||||||
hasAuthor = True
|
buildContributorsString(contribs.keys()),
|
||||||
if hasattr(module, '__contributors__'):
|
len(contribs))
|
||||||
contribs = sortAuthors()
|
else:
|
||||||
if hasAuthor:
|
s += _('No additional contributors are listed.')
|
||||||
try:
|
return s
|
||||||
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):
|
def buildPersonString(module):
|
||||||
"""
|
"""
|
||||||
Build the list of contributions (if any) for the requested person
|
Build the list of contributions (if any) for the requested person
|
||||||
|
Loading…
x
Reference in New Issue
Block a user