From df735477459402d8271948ac58f0d5ecae92a88b Mon Sep 17 00:00:00 2001 From: James Vega Date: Tue, 26 Apr 2005 02:53:08 +0000 Subject: [PATCH] Fix up Plugin.contributors and a couple contributors dicts. --- plugins/Internet/__init__.py | 2 +- plugins/Math/__init__.py | 2 +- plugins/Plugin/plugin.py | 16 +++++++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/plugins/Internet/__init__.py b/plugins/Internet/__init__.py index 4c307b33c..50361df57 100644 --- a/plugins/Internet/__init__.py +++ b/plugins/Internet/__init__.py @@ -42,7 +42,7 @@ __author__ = supybot.authors.jemfinch # This is a dictionary mapping supybot.Author instances to lists of # contributions. -__contributors__ = {supybot.authors.jamessan:'whois'} +__contributors__ = {supybot.authors.jamessan: ['whois']} import config import plugin diff --git a/plugins/Math/__init__.py b/plugins/Math/__init__.py index cd13b21a0..92ed2e54c 100644 --- a/plugins/Math/__init__.py +++ b/plugins/Math/__init__.py @@ -42,7 +42,7 @@ __author__ = supybot.authors.jemfinch # This is a dictionary mapping supybot.Author instances to lists of # contributions. -__contributors__ = {supybot.Author('Keith Jones', 'kmj', ''): 'convert'} +__contributors__ = {supybot.Author('Keith Jones', 'kmj', ''): ['convert']} import config import plugin diff --git a/plugins/Plugin/plugin.py b/plugins/Plugin/plugin.py index 070b2da0a..25cef2b02 100644 --- a/plugins/Plugin/plugin.py +++ b/plugins/Plugin/plugin.py @@ -147,12 +147,12 @@ class Plugin(callbacks.Plugin): contrib = 'has no contributors listed.' hasAuthor = False hasContribs = False - if getattr(module, '__author__', None): + if hasattr(module, '__author__'): if module.__author__ != supybot.authors.unknown: author = 'was written by %s' % \ utils.web.mungeEmail(str(module.__author__)) hasAuthor = True - if getattr(module, '__contributors__', None): + if hasattr(module, '__contributors__'): contribs = sortAuthors() if hasAuthor: try: @@ -175,7 +175,14 @@ class Plugin(callbacks.Plugin): for the requested plugin """ isAuthor = False - authorInfo = getattr(supybot.authors, nick, None) + 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 @@ -186,8 +193,7 @@ class Plugin(callbacks.Plugin): return 'The %s plugin does not have \'%s\' listed as a ' \ 'contributor.' % (cb.name(), nick) contributions = module.__contributors__[authorInfo] - if getattr(module, '__author__', False) == authorInfo: - isAuthor = True + isAuthor = getattr(module, '__author__', False) == authorInfo (nonCommands, commands) = utils.iter.partition(lambda s: ' ' in s, contributions) results = []