def load_stache(stache_name, possible_dirs):
for dir_ in possible_dirs:
path = Path(dir_).resolve()
python_path = path.parent
with PythonPathContext(str(python_path)):
stache_path = find_last_child(path) / stache_name
stache_module = "{}.{}".format(str(find_last_child(path)), stache_name)
module_spec = importlib.util.spec_from_file_location(
stache_module,
"{}.py".format(stache_path))
if module_spec:
foo = importlib.util.module_from_spec(module_spec)
module_spec.loader.exec_module(foo)
return
raise Exception("No stache with name {} found".format(stache_name))
评论列表
文章目录