From f18900f471350f4cd88c0ef2f7452623aaadd96b Mon Sep 17 00:00:00 2001 From: relikd Date: Sat, 26 Sep 2020 00:07:21 +0200 Subject: [PATCH] Group categories by kind --- src/html_categories.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/html_categories.py b/src/html_categories.py index e48b6dc..111d0f3 100755 --- a/src/html_categories.py +++ b/src/html_categories.py @@ -4,6 +4,24 @@ import lib_common as mylib import lib_html as HTML +def write_overview_page(base_dir, category_tuples, title): + cluster = {} + for x in category_tuples: + i = int(int(x[0]) / 1000) + try: + cluster[i].append(x) + except KeyError: + cluster[i] = [x] + src = '

{}

'.format(title) + for i, arr in sorted(cluster.items()): + mylib.sort_by_name(arr, 1) + kind = 'Apps' if i == 6 else 'Games' if i == 7 else 'Other' + src += '

{}

'.format(kind) + src += '
' + src += ''.join([HTML.a_category(*x) for x in arr]) + '
' + HTML.write(base_dir, src, title) + + def process(affected=None, per_page=60): print('generating html: category-index ...') base = mylib.path_out('category') @@ -27,13 +45,7 @@ def process(affected=None, per_page=60): mylib.symlink(fname, mylib.path_add(out_dir, 'data.json')) print(' .. {} categories'.format(len(arr))) - mylib.sort_by_name(arr, 1) - src = ''.join([HTML.a_category(*x) for x in arr]) - HTML.write(base, ''' -

{}

-
- {} -
'''.format(parent, src), parent) + write_overview_page(base, arr, parent) print('')