mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Fix for 'revision Math' bug.
This commit is contained in:
parent
ff370e29cf
commit
67ab9f8ae1
22
src/Misc.py
22
src/Misc.py
@ -233,11 +233,25 @@ class Misc(callbacks.Privmsg):
|
|||||||
name = name[:-3]
|
name = name[:-3]
|
||||||
try:
|
try:
|
||||||
modules = {}
|
modules = {}
|
||||||
for moduleName in sys.modules:
|
for (moduleName, module) in sys.modules.iteritems():
|
||||||
|
if hasattr(module, '__file__'):
|
||||||
|
if module.__file__.startswith(conf.installDir):
|
||||||
modules[moduleName.lower()] = moduleName
|
modules[moduleName.lower()] = moduleName
|
||||||
module = sys.modules[modules[name.lower()]]
|
try:
|
||||||
|
module = sys.modules[name]
|
||||||
|
if not module.__file__.startswith(conf.installDir):
|
||||||
|
raise KeyError
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.error('I couldn\'t find a module named %s' % name)
|
try:
|
||||||
|
module = sys.modules[modules[name.lower()]]
|
||||||
|
if not module.__file__.startswith(conf.installDir):
|
||||||
|
raise KeyError
|
||||||
|
except KeyError:
|
||||||
|
module = sys.modules[name.lower()]
|
||||||
|
if not module.__file__.startswith(conf.installDir):
|
||||||
|
raise KeyError
|
||||||
|
except KeyError:
|
||||||
|
irc.error('I couldn\'t find a Supybot module named %s' % name)
|
||||||
return
|
return
|
||||||
if hasattr(module, '__revision__'):
|
if hasattr(module, '__revision__'):
|
||||||
irc.reply(module.__revision__)
|
irc.reply(module.__revision__)
|
||||||
@ -260,7 +274,7 @@ class Misc(callbacks.Privmsg):
|
|||||||
if dir in module.__file__:
|
if dir in module.__file__:
|
||||||
names[name] = getVersion(module.__revision__)
|
names[name] = getVersion(module.__revision__)
|
||||||
break
|
break
|
||||||
L = ['%s: %s' % (k, v) for (k, v) in names.items()]
|
L = ['%s: %s' % (k, v) for (k, v) in names.items() if v]
|
||||||
irc.reply(utils.commaAndify(L))
|
irc.reply(utils.commaAndify(L))
|
||||||
|
|
||||||
def source(self, irc, msg, args):
|
def source(self, irc, msg, args):
|
||||||
|
@ -192,6 +192,12 @@ class MiscTestCase(ChannelPluginTestCase, PluginDocumentation):
|
|||||||
self.assertNotError('revision Misc.py')
|
self.assertNotError('revision Misc.py')
|
||||||
self.assertNotError('revision')
|
self.assertNotError('revision')
|
||||||
|
|
||||||
|
def testRevisionDoesNotLowerUnnecessarily(self):
|
||||||
|
self.assertNotError('load Math')
|
||||||
|
m1 = self.assertNotError('revision Math')
|
||||||
|
m2 = self.assertNotError('revision math')
|
||||||
|
self.assertEqual(m1, m2)
|
||||||
|
|
||||||
def testRevisionIsCaseInsensitive(self):
|
def testRevisionIsCaseInsensitive(self):
|
||||||
self.assertNotError('revision misc')
|
self.assertNotError('revision misc')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user