提交 e73a7e40 编写于 作者: S storyicon

feat: ensure the indexability of dynamically imported packages

Signed-off-by: Nstoryicon <storyicon@foxmail.com>
上级 bef51aed
......@@ -2,13 +2,18 @@ import os
import importlib.util
from modules import errors
import sys
def load_module(path):
module_spec = importlib.util.spec_from_file_location(os.path.basename(path), path)
module = importlib.util.module_from_spec(module_spec)
module_spec.loader.exec_module(module)
if os.path.isfile(path):
sp = os.path.splitext(path)
module_name = sp[0]
else:
module_name = os.path.basename(path)
sys.modules[module_name] = module
return module
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册