From 8ed5f0be512612cfee66748390c5af8e12bf7cde Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Wed, 9 Sep 2020 12:58:57 -0700 Subject: [PATCH] Fix tag_expression usage of frozen_children which was tag objects. At some point, I changed tag_export.flat_dict from using strings as keys to using actual Tag objects as keys. The tag expression handler never got updated, so frozen_children[tagname] raised KeyError as it was looking for a string. I considered using tag_expression_tree.map to convert all the tree tokens into tag objects, but when we render the tree back into text it will say "Tag:name" instead of just "name" throughout the whole expression, and I don't want to deal with converting those back. --- etiquette/searchhelpers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/etiquette/searchhelpers.py b/etiquette/searchhelpers.py index a9b44b9..7bcf7a4 100644 --- a/etiquette/searchhelpers.py +++ b/etiquette/searchhelpers.py @@ -484,6 +484,10 @@ def tag_expression_tree_builder( return expression_tree def tag_expression_matcher_builder(frozen_children): + frozen_children = { + (tag.name if not isinstance(tag, str) else tag): children + for (tag, children) in frozen_children.items() + } def match_function(photo_tags, tagname): ''' Used as the `match_function` for the ExpressionTree evaluation.