module import helper

This commit is contained in:
Michael Davidsaver
2013-12-10 17:06:49 -05:00
parent 6a9aa2e29d
commit 907db555b4
2 changed files with 13 additions and 2 deletions

View File

@ -1,7 +1,7 @@
import threading, sys, traceback, time
from devsup.util import Worker
from devsup.util import Worker, importmod
try:
import _dbapi
@ -326,5 +326,5 @@ def processLink(name, lstr):
rec = getRecord(name)
parts = lstr.split(None,1)
modname, args = parts[0], parts[1] if len(parts)>1 else None
mod = __import__(modname, fromlist=['__should_not_exist'])
mod = importmod(modname)
return rec, mod.build(rec, args)

View File

@ -6,6 +6,17 @@ try:
except ImportError:
import queue
def importmod(modname):
"""Import the named python module(s)
add return the leaf.
>>> M=importmod('xml.sax')
>>> M.__name__
'xml.sax'
>>>
"""
return __import__(modname, fromlist=['__should_not_exist'])
class StoppableThread(threading.Thread):
"""A thread which can be requested to stop.