From f97be684c78d9eea9500a6ad6a1ed8c28696a5d3 Mon Sep 17 00:00:00 2001 From: Kibzik Date: Thu, 25 May 2023 11:47:55 +0300 Subject: [PATCH] leave similar tags --- src/html_presets_processor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/html_presets_processor.py b/src/html_presets_processor.py index 65a447c..56318a2 100644 --- a/src/html_presets_processor.py +++ b/src/html_presets_processor.py @@ -51,7 +51,6 @@ class HtmlPresetsProcessor: @staticmethod def _tags_with_attrs_condition(**kwargs): - found_tags: list[Tag] = list() names = [attr["name"] for attr in kwargs["rule"]["condition"]["attrs"]] values = [re.compile(attr["value"]) for attr in kwargs["rule"]["condition"]["attrs"]] attr_conditions: dict[str, re] = dict(zip(names, values)) @@ -307,10 +306,11 @@ class HtmlPresetsProcessor: found_tags = found_tags + f_tags if was_found else [] if not was_found: break - # if there are several conditions on tags and found_tags isn't empty + # If there are several conditions on tags and found_tags isn't empty if len(conditions_on_tag) > 1 and found_tags: - # tags satisfying all conditions((more than 1 condition) - found_tags = [tag for tag in found_tags if found_tags.count(tag) == len(conditions_on_tag)] + # Leave only tags satisfying all conditions(more than 1 condition) + # >= because there can be similar tags + found_tags = [tag for tag in found_tags if found_tags.count(tag) >= len(conditions_on_tag)] # Make an action with necessary tags for found_tag in found_tags: