Commit 88fed3cc authored by payno's avatar payno
Browse files

[utils] rework '_check_module_for_class'

parent d69ab181
...@@ -62,19 +62,19 @@ def _check_module_for_class(module, depth=0): ...@@ -62,19 +62,19 @@ def _check_module_for_class(module, depth=0):
if inspect.ismodule(m[1]): if inspect.ismodule(m[1]):
if inspect.isclass(m[1]): if inspect.isclass(m[1]):
classes.append(m[1]) classes.append(m[1])
elif hasattr(m[1], '__path__'):
for importer, modname, ispkg in pkgutil.iter_modules( for importer, modname, ispkg in pkgutil.iter_modules(
m[1].__path__): m[1].__path__):
module_name = module.__name__ module_name = module.__name__
submod_name = '.'.join((module_name, m[0], modname)) submod_name = '.'.join((module_name, m[0], modname))
try: try:
mod = importlib.import_module(submod_name) mod = importlib.import_module(submod_name)
except Exception: except Exception:
pass pass
else: else:
classes.extend( classes.extend(
_check_module_for_class(module=mod, _check_module_for_class(module=mod,
depth=depth+1)) depth=depth+1))
return classes return classes
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment