[enh] change categories_as_tabs from a list to a dict

The tab icon names are currently hard coded in the templates.
This commit lets us introduce an icon property in the future, e.g:

categories_as_tabs:
  general:
    icon: search-outline
This commit is contained in:
Martin Fischer
2022-01-04 18:00:45 +01:00
parent b38036d519
commit a4c2cfb837
7 changed files with 40 additions and 38 deletions

View File

@@ -146,7 +146,9 @@ def group_engines_in_tab(engines: Iterable[Engine]) -> List[Tuple[str, Iterable[
"""Groups an Iterable of engines by their first non tab category"""
def get_group(eng):
non_tab_categories = [c for c in eng.categories if c not in settings['categories_as_tabs'] + [OTHER_CATEGORY]]
non_tab_categories = [
c for c in eng.categories if c not in list(settings['categories_as_tabs'].keys()) + [OTHER_CATEGORY]
]
return non_tab_categories[0] if len(non_tab_categories) > 0 else DEFAULT_GROUP_NAME
groups = itertools.groupby(sorted(engines, key=get_group), get_group)