Add a try/catch arround plugin directory determination (might be useful for some utilities...)

This commit is contained in:
Valentin Lorentz 2011-02-28 16:02:17 +01:00
parent cb0139299a
commit db849e21a0

View File

@ -74,7 +74,13 @@ def getPluginDir(plugin_name):
except KeyError: # It sometimes happens with Owner
pass
if filename == None:
try:
filename = sys.modules['supybot.plugins.' + plugin_name].__file__
except: # In the case where the plugin is not loaded by Supybot
try:
filename = sys.modules['plugin'].__file__
except:
filename = sys.modules['__main__'].__file__
if filename.endswith(".pyc"):
filename = filename[0:-1]