mirror of
https://github.com/shmilylty/OneForAll.git
synced 2026-08-26 04:47:48 +08:00
解决python 3.6不能相对导入问题
This commit is contained in:
+5
-7
@@ -22,9 +22,8 @@ class Collect(object):
|
|||||||
for module in modules:
|
for module in modules:
|
||||||
module_path = settings.module_dir.joinpath(module)
|
module_path = settings.module_dir.joinpath(module)
|
||||||
for path in module_path.rglob('*.py'):
|
for path in module_path.rglob('*.py'):
|
||||||
# Classes to be imported
|
import_module = f'modules.{module}.{path.stem}'
|
||||||
import_module = ('modules.' + module, path.stem)
|
self.modules.append([import_module, path.stem])
|
||||||
self.modules.append(import_module)
|
|
||||||
else:
|
else:
|
||||||
self.modules = settings.enable_partial_module
|
self.modules = settings.enable_partial_module
|
||||||
|
|
||||||
@@ -32,8 +31,8 @@ class Collect(object):
|
|||||||
"""
|
"""
|
||||||
Import do function
|
Import do function
|
||||||
"""
|
"""
|
||||||
for package, name in self.modules:
|
for module, name in self.modules:
|
||||||
import_object = importlib.import_module('.' + name, package)
|
import_object = importlib.import_module(module)
|
||||||
func = getattr(import_object, 'run')
|
func = getattr(import_object, 'run')
|
||||||
self.collect_funcs.append([func, name])
|
self.collect_funcs.append([func, name])
|
||||||
|
|
||||||
@@ -47,8 +46,7 @@ class Collect(object):
|
|||||||
|
|
||||||
threads = []
|
threads = []
|
||||||
# Create subdomain collection threads
|
# Create subdomain collection threads
|
||||||
for collect_func in self.collect_funcs:
|
for func_obj, func_name in self.collect_funcs:
|
||||||
func_obj, func_name = collect_func
|
|
||||||
thread = threading.Thread(target=func_obj, name=func_name,
|
thread = threading.Thread(target=func_obj, name=func_name,
|
||||||
args=(self.domain,), daemon=True)
|
args=(self.domain,), daemon=True)
|
||||||
threads.append(thread)
|
threads.append(thread)
|
||||||
|
|||||||
Reference in New Issue
Block a user