From 30d7dbdb39d9ac0b1baaa1d025adb3ed5168437a Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Wed, 9 Sep 2020 12:53:51 -0700 Subject: [PATCH] Fix tag_export.flat_dict which was not truthful about synonyms. --- etiquette/tag_export.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/etiquette/tag_export.py b/etiquette/tag_export.py index 8c1359f..1040e4d 100644 --- a/etiquette/tag_export.py +++ b/etiquette/tag_export.py @@ -41,11 +41,13 @@ def easybake(tags, include_synonyms=True, with_objects=False): lines.sort() return lines -def flat_dict(tags): +def flat_dict(tags, include_synonyms=True): ''' A dictionary where every tag is its own key, and the value is a list containing itself all of its nested children. - Synonyms not included. + + If synonyms are included, their key is a string, and the value is the same + list as the children of the master tag. { people: [people, family, mother], @@ -62,6 +64,8 @@ def flat_dict(tags): for child in tag.walk_children(): children = list(child.walk_children()) result[child] = children + if not include_synonyms: + continue for synonym in child.get_synonyms(): result[synonym] = children return result