You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
741 B
Python
27 lines
741 B
Python
import inspect, os, sys
|
|
|
|
my_path = os.path.dirname(inspect.getfile(inspect.currentframe()))
|
|
|
|
def _import_module_into_scope(modulename):
|
|
module = __import__(modulename)
|
|
|
|
for name in vars(module):
|
|
data = getattr(module, name)
|
|
globals()[name] = data
|
|
|
|
sys.path.insert(0, my_path)
|
|
|
|
for fname in os.listdir(my_path):
|
|
fpath = os.path.join(my_path, fname)
|
|
fbasename, fext = os.path.splitext(fname)
|
|
|
|
if os.path.isdir(fpath):
|
|
if os.path.isfile(os.path.join(my_path, fname, "__init__.py")):
|
|
# This is a python directory module
|
|
_import_module_into_scope(fname)
|
|
elif os.path.isfile(fpath) and fext == ".py" and fbasename != "__init__":
|
|
# This is a python file module
|
|
_import_module_into_scope(fbasename)
|
|
|
|
sys.path.remove(my_path)
|