From 9a4f90d36bcbb1c31de6806402aba8a0c0e4027b Mon Sep 17 00:00:00 2001 From: "Maxime Alves LIRMM@home" Date: Tue, 27 Oct 2020 13:06:27 +0100 Subject: [PATCH] /lib/domain - try for ImportError bug --- halfapi/lib/domain.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/halfapi/lib/domain.py b/halfapi/lib/domain.py index ea3c20e..bc4fc65 100644 --- a/halfapi/lib/domain.py +++ b/halfapi/lib/domain.py @@ -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) - submod = importlib.import_module(f'.{subroute}', m_router.__name__) + 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]: """