From ffef94411981c9612c2e001dd014432598f925b4 Mon Sep 17 00:00:00 2001 From: Rock Chin <1010553892@qq.com> Date: Sun, 5 Mar 2023 16:04:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=83=AD=E9=87=8D=E8=BD=BD=E5=90=8E?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=BC=80=E5=85=B3=E7=8A=B6=E6=80=81=E8=A2=AB?= =?UTF-8?q?=E9=87=8D=E7=BD=AE=20(#177)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/utils/reloader.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/utils/reloader.py b/pkg/utils/reloader.py index 7e436678..d701b067 100644 --- a/pkg/utils/reloader.py +++ b/pkg/utils/reloader.py @@ -7,13 +7,15 @@ import pkg.utils.context import pkg.plugin.host -def walk(module, prefix=''): +def walk(module, prefix='', path_prefix=''): """遍历并重载所有模块""" for item in pkgutil.iter_modules(module.__path__): if item.ispkg: - walk(__import__(module.__name__ + '.' + item.name, fromlist=['']), prefix + item.name + '.') + + walk(__import__(module.__name__ + '.' + item.name, fromlist=['']), prefix + item.name + '.', path_prefix + item.name + '/') else: - logging.info('reload module: {}'.format(prefix + item.name)) + logging.info('reload module: {}, path: {}'.format(prefix + item.name, path_prefix + item.name + '.py')) + pkg.plugin.host.__current_module_path__ = "plugins/" + path_prefix + item.name + '.py' importlib.reload(__import__(module.__name__ + '.' + item.name, fromlist=['']))