mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
Fix for 'revision Math' bug.
This commit is contained in:
parent
ff370e29cf
commit
67ab9f8ae1
24
src/Misc.py
24
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():
|
||||||
modules[moduleName.lower()] = moduleName
|
if hasattr(module, '__file__'):
|
||||||
module = sys.modules[modules[name.lower()]]
|
if module.__file__.startswith(conf.installDir):
|
||||||
|
modules[moduleName.lower()] = moduleName
|
||||||
|
try:
|
||||||
|
module = sys.modules[name]
|
||||||
|
if not module.__file__.startswith(conf.installDir):
|
||||||
|
raise KeyError
|
||||||
|
except KeyError:
|
||||||
|
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:
|
except KeyError:
|
||||||
irc.error('I couldn\'t find a module named %s' % name)
|
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