forked from LiveCarta/BookConverter
Fix: condition is never empty
This commit is contained in:
@@ -225,8 +225,8 @@ class HtmlPresetsProcessor:
|
||||
tags: list[str] = preset_rule["tags"] if preset_rule.get(
|
||||
"tags") else preset_rule["condition"]["tags"]
|
||||
found_tags: list[Tag] = []
|
||||
if preset_rule["condition"]:
|
||||
conditions_on_tag = tuple((k, v) for k, v in preset_rule["condition"].items() if v)
|
||||
conditions_on_tag = tuple((k, v) for k, v in preset_rule["condition"].items() if v)
|
||||
if conditions_on_tag:
|
||||
for condition_on_tag in conditions_on_tag:
|
||||
condition_func = self.conditions[condition_on_tag[0]]
|
||||
was_found, f_tags = condition_func(body_tag=body_tag,
|
||||
@@ -238,8 +238,8 @@ class HtmlPresetsProcessor:
|
||||
break
|
||||
# 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(>1)
|
||||
found_tags = [tag for tag in found_tags if found_tags.count(tag) > 1]
|
||||
# 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)]
|
||||
for found_tag in found_tags:
|
||||
action(body_tag=body_tag, found_tag=found_tag, rule=preset_rule)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user