Coverage for portality/lib/nav.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v6.4.2, created at 2022-11-09 15:10 +0000

1from typing import Iterable 

2 

3from portality.core import app 

4 

5 

6def yield_all_route(entries: Iterable[dict]) -> Iterable[str]: 

7 """ 

8 :param entries: 

9 :return: iterable of route name (endpoint) 

10 """ 

11 

12 for e in entries: 

13 if 'route' in e: 

14 yield e['route'] 

15 if 'entries' in e: 

16 yield from yield_all_route(e['entries']) 

17 

18 

19def get_nav_entries() -> Iterable[dict]: 

20 return app.jinja_env.globals.get("data", {}).get('nav', {}).get('entries', [])