DR -> DR SDK #16
@ -162,22 +162,20 @@ class _DR_runtime(Options):
|
||||
try:
|
||||
if mod_path.is_dir() and mod_path.name != '__pycache__': # 处理文件夹 mod
|
||||
if importlib.util.find_spec(mod_path.name) is not None:
|
||||
module = importlib.import_module(mod_path.name)
|
||||
mods.append(mod_path.name)
|
||||
else:
|
||||
print(f'can not import mod {mod_path} because importlib can not find spec')
|
||||
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
|
||||
print(f'importing mod {mod_path=} {mod_path.stem}')
|
||||
module = importlib.import_module(mod_path.stem)
|
||||
if importlib.util.find_spec(mod_path.stem) is not None:
|
||||
mods.append(mod_path.stem)
|
||||
except ImportError:
|
||||
print(f'ImportError when loading mod {mod_path}')
|
||||
traceback.print_exc()
|
||||
self.DR_Mod_List = [(mod, Version('0.0.0-unknown')) for mod in mods]
|
||||
self.DR_Mod_List = [(mod, Version('0.0.0-unloaded')) for mod in mods]
|
||||
return mods
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user