From a4a37777229fd4fe6afd6e5beeba4f9342850699 Mon Sep 17 00:00:00 2001 From: oogm Date: Thu, 8 Apr 2021 22:14:41 +0200 Subject: [PATCH] Update import_emojis.py to retain keyword order --- tools/import_emojis.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/import_emojis.py b/tools/import_emojis.py index a626a5a260..30db3b0b13 100755 --- a/tools/import_emojis.py +++ b/tools/import_emojis.py @@ -114,11 +114,13 @@ for emoji in emoji_picker_datasource_emojis: # If additional keywords exist, add them to emoji_picker_datasource_emojis # Avoid duplicates and keep order. Put official unicode.com keywords first and extend up with emojilib ones. - new_keywords = OrderedDict.fromkeys(emoji_picker_datasource_emojis[emoji]["j"] + emoji_additional_keywords).keys() + new_keywords = OrderedDict.fromkeys(emoji_picker_datasource_emojis[emoji]["j"] + emoji_additional_keywords) # Remove the ones derived from the unicode name - new_keywords = new_keywords - {emoji.replace("-", "_")} - {emoji.replace("-", " ")} - {emoji_name} + for keyword in [emoji.replace("-", "_")] + [emoji.replace("-", " ")] + [emoji_name]: + if keyword in new_keywords: + new_keywords.pop(keyword) # Write new keywords back - emoji_picker_datasource_emojis[emoji]["j"] = list(new_keywords) + emoji_picker_datasource_emojis[emoji]["j"] = list(new_keywords.keys()) # Filter out components from unicode 13.1 (as they are not suitable for single-emoji reactions) emoji_picker_datasource['categories'] = [x for x in emoji_picker_datasource['categories'] if x['id'] != 'component']