From 97cbada88297591c17876303c78ab284d3c0b149 Mon Sep 17 00:00:00 2001 From: Dominik Reh Date: Tue, 20 Dec 2022 13:28:43 +0100 Subject: [PATCH] Sort yaml tags by count --- scripts/tag_autocomplete_helper.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/tag_autocomplete_helper.py b/scripts/tag_autocomplete_helper.py index 79f19b1..cb9c71b 100644 --- a/scripts/tag_autocomplete_helper.py +++ b/scripts/tag_autocomplete_helper.py @@ -73,8 +73,10 @@ def get_ext_wildcard_tags(): wildcard_tags[tag] += 1 except yaml.YAMLError as exc: print(exc) + # Sort by count + sorted_tags = sorted(wildcard_tags.items(), key=lambda item: item[1], reverse=True) output = [] - for tag, count in wildcard_tags.items(): + for tag, count in sorted_tags: output.append(f"{tag},{count}") return output @@ -136,12 +138,10 @@ if WILDCARD_EXT_PATHS is not None: wildcards_ext = get_ext_wildcards() if wildcards_ext: write_to_temp_file('wce.txt', wildcards_ext) - -# Write extension wildcards to wce.txt if found -if WILDCARD_EXT_PATHS is not None: - wildcards_ext = get_ext_wildcard_tags() - if wildcards_ext: - write_to_temp_file('wcet.txt', wildcards_ext) + # Write yaml extension wildcards to wcet.txt if found + wildcards_yaml_ext = get_ext_wildcard_tags() + if wildcards_yaml_ext: + write_to_temp_file('wcet.txt', wildcards_yaml_ext) # Write embeddings to emb.txt if found if EMB_PATH.exists():