/lib/domain - try for ImportError bug

This commit is contained in:
Maxime Alves LIRMM@home 2020-10-27 13:06:27 +01:00
parent 64e60343bf
commit 9a4f90d36b
1 changed files with 7 additions and 2 deletions

View File

@ -137,7 +137,11 @@ def gen_router_routes(m_router: ModuleType, path: List[str]) -> Generator:
subroutes = route_params.get('SUBROUTES', [])
for subroute in subroutes:
path.append(subroute)
try:
submod = importlib.import_module(f'.{subroute}', m_router.__name__)
except ImportError:
continue
yield from gen_router_routes(submod, path)
path.pop()
@ -156,11 +160,12 @@ def gen_domain_routes(domain: str, m_dom: ModuleType) -> Generator:
try:
m_router = importlib.import_module('.routers', domain)
yield from gen_router_routes(m_router, [domain])
except ImportError:
logger.warning('Domain **%s** has no **routers** module', domain)
logger.debug('%s', m_dom)
if m_router:
yield from gen_router_routes(m_router, [domain])
def d_domains(config) -> Dict[str, ModuleType]:
"""