mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-20 17:53:03 +01:00
Fixed revision (again).
This commit is contained in:
parent
99926fd170
commit
c070e66d11
15
src/Misc.py
15
src/Misc.py
@ -232,23 +232,28 @@ class Misc(callbacks.Privmsg):
|
|||||||
if name.endswith('.py'):
|
if name.endswith('.py'):
|
||||||
name = name[:-3]
|
name = name[:-3]
|
||||||
try:
|
try:
|
||||||
|
def startsWithPluginsDir(filename):
|
||||||
|
for dir in conf.supybot.directories.plugins():
|
||||||
|
if filename.startswith(dir):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
modules = {}
|
modules = {}
|
||||||
for (moduleName, module) in sys.modules.iteritems():
|
for (moduleName, module) in sys.modules.iteritems():
|
||||||
if hasattr(module, '__file__'):
|
if hasattr(module, '__file__'):
|
||||||
if module.__file__.startswith(conf.installDir):
|
if startsWithPluginsDir(module.__file__):
|
||||||
modules[moduleName.lower()] = moduleName
|
modules[moduleName.lower()] = moduleName
|
||||||
try:
|
try:
|
||||||
module = sys.modules[name]
|
module = sys.modules[name]
|
||||||
if not module.__file__.startswith(conf.installDir):
|
if not startsWithPluginsDir(module.__file__):
|
||||||
raise KeyError
|
raise KeyError
|
||||||
except KeyError:
|
except KeyError:
|
||||||
try:
|
try:
|
||||||
module = sys.modules[modules[name.lower()]]
|
module = sys.modules[modules[name.lower()]]
|
||||||
if not module.__file__.startswith(conf.installDir):
|
if not startsWithPluginsDir(module.__file__):
|
||||||
raise KeyError
|
raise KeyError
|
||||||
except KeyError:
|
except KeyError:
|
||||||
module = sys.modules[name.lower()]
|
module = sys.modules[name.lower()]
|
||||||
if not module.__file__.startswith(conf.installDir):
|
if not startsWithPluginsDir(module.__file__):
|
||||||
raise KeyError
|
raise KeyError
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.error('I couldn\'t find a Supybot module named %s' % name)
|
irc.error('I couldn\'t find a Supybot module named %s' % name)
|
||||||
@ -256,7 +261,7 @@ class Misc(callbacks.Privmsg):
|
|||||||
if hasattr(module, '__revision__'):
|
if hasattr(module, '__revision__'):
|
||||||
irc.reply(module.__revision__)
|
irc.reply(module.__revision__)
|
||||||
else:
|
else:
|
||||||
irc.error('Module %s has no __revision__.' % name)
|
irc.error('Module %s has no __revision__ string.' % name)
|
||||||
else:
|
else:
|
||||||
def getVersion(s):
|
def getVersion(s):
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user