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):
if inspect.ismodule(m[1]):
if inspect.isclass(m[1]):
classes.append(m[1])
for importer, modname, ispkg in pkgutil.iter_modules(
m[1].__path__):
module_name = module.__name__
submod_name = '.'.join((module_name, m[0], modname))
try:
mod = importlib.import_module(submod_name)
except Exception:
pass
else:
classes.extend(
_check_module_for_class(module=mod,
depth=depth+1))
elif hasattr(m[1], '__path__'):
for importer, modname, ispkg in pkgutil.iter_modules(
m[1].__path__):
module_name = module.__name__
submod_name = '.'.join((module_name, m[0], modname))
try:
mod = importlib.import_module(submod_name)
except Exception:
pass
else:
classes.extend(
_check_module_for_class(module=mod,
depth=depth+1))
return classes
......
Markdown is supported
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