DR -> DR SDK #16

Merged
shenjackyuanjie merged 41 commits from feature/dr-sdk into main 2023-05-03 00:40:53 +08:00
2 changed files with 8 additions and 9 deletions
Showing only changes of commit df5476ae7d - Show all commits

View File

@ -160,19 +160,19 @@ class _DR_runtime(Options):
sys.path.append(self.mod_path) sys.path.append(self.mod_path)
for mod_path in paths: for mod_path in paths:
try: try:
if mod_path.is_dir: # 文件夹格式的 mod if mod_path.is_dir: # 处理文件夹 mod
if not (mod_path / '__init__.py').exists(): # 不符合格式要求
continue
if importlib.util.find_spec(mod_path.name) is not None: if importlib.util.find_spec(mod_path.name) is not None:
module = importlib.import_module(mod_path.name) module = importlib.import_module(mod_path.name)
info: Options = module.INFO
mods.append(mod_path.name) mods.append(mod_path.name)
print(f'find mod in {mod_path} ID: {info.mod_id} name: {info.name} version: {info.version}')
print(f'import mod {mod_path}')
else: else:
print(f'can not import mod {mod_path} because importlib can not find spec') print(f'can not import mod {mod_path} because importlib can not find spec')
else: elif mod_path.suffix in ('.pyz', '.zip'): # 处理压缩包 mod
... if importlib.util.find_spec(mod_path.name) is not None:
module = importlib.import_module(mod_path.name)
mods.append(mod_path.name)
elif mod_path.suffix == '.py': # 处理单文件 mod
module = importlib.import_module(mod_path.stem)
mods.append(mod_path.stem)
except ImportError: except ImportError:
print(f'ImportError when loading mod {mod_path}') print(f'ImportError when loading mod {mod_path}')
traceback.print_exc() traceback.print_exc()

View File

@ -32,7 +32,6 @@
- 已删除 - 已删除
- Removed - Removed
### Changes ### Changes
- `main.toml` - `main.toml`