mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Added utils.python.universalImport to make the previous idiom cleaner.
This commit is contained in:
parent
d6ad5b051f
commit
a86b4694d7
@ -40,6 +40,7 @@ import supybot.utils as utils
|
||||
from supybot.commands import *
|
||||
import supybot.callbacks as callbacks
|
||||
|
||||
convertcore = utils.python.universalImport('convertcore', 'our_convertcore')
|
||||
try:
|
||||
import convertcore
|
||||
except ImportError:
|
||||
|
@ -27,9 +27,21 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import sys
|
||||
import types
|
||||
import threading
|
||||
|
||||
def universalImport(*names):
|
||||
f = sys._getframe(1)
|
||||
for name in names:
|
||||
try:
|
||||
ret = __import__(name, globals=f.f_globals)
|
||||
except ImportError:
|
||||
continue
|
||||
else:
|
||||
return ret
|
||||
raise ImportError, ','.join(names)
|
||||
|
||||
def changeFunctionName(f, name, doc=None):
|
||||
if doc is None:
|
||||
doc = f.__doc__
|
||||
|
Loading…
Reference in New Issue
Block a user