🐛 修复 windows 下路径问题 (#87)

This commit is contained in:
omg-xtao 2022-08-29 21:37:20 +08:00 committed by GitHub
parent 91a133b694
commit aa882c3f93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -85,9 +85,9 @@ class ModuleInfo:
if self.relative_path is None: if self.relative_path is None:
return "" return ""
if os.path.isdir(self.relative_path): if os.path.isdir(self.relative_path):
return self.relative_path.replace(os.sep, ".") return self.relative_path.replace("/", ".")
root, _ = os.path.splitext(self.relative_path) root, _ = os.path.splitext(self.relative_path)
return root.replace(os.sep, ".") return root.replace("/", ".")
def __str__(self): def __str__(self):
return self.module_name return self.module_name

View File

@ -18,9 +18,9 @@ class ModulesManager:
self.modules_list.clear() self.modules_list.clear()
def refresh_list(self, pathname: str): def refresh_list(self, pathname: str):
path_list = glob(pathname) path_list = [i.replace(os.sep, "/") for i in glob(pathname)]
for temp_path in path_list: for temp_path in path_list:
if temp_path.startswith('__'): if "__" in temp_path:
continue continue
if os.path.isdir(temp_path): if os.path.isdir(temp_path):
self.modules_list.append(ModuleInfo(relative_path=temp_path)) self.modules_list.append(ModuleInfo(relative_path=temp_path))
@ -52,4 +52,4 @@ class ModulesManager:
Log.warning(f"{self.manager_name}加载 {module_info} 失败", exc) Log.warning(f"{self.manager_name}加载 {module_info} 失败", exc)
else: else:
module_name_list.append(module_info.module_name) module_name_list.append(module_info.module_name)
Log.info(self.manager_name + "加载模块: " + ", ".join(module_name_list)) Log.info(f"{self.manager_name}加载模块: " + ", ".join(module_name_list))