forked from LiveCarta/BookConverter
Fix duplicate tags cause of dict.get(key) = 0
This commit is contained in:
@@ -34,15 +34,11 @@ class HtmlPresetsProcessor:
|
||||
def _tags_with_parent_condition(**kwargs):
|
||||
found_tags: list[Tag] = list()
|
||||
# add unique id in order not to add duplicates to the
|
||||
# found_tags(because tag with subtag could duplicate found_tag)
|
||||
u_id = 0
|
||||
# found_tags(because parent_tag with sub parent_tag could be a duplicate found_tag)
|
||||
for parent_tag in kwargs["body_tag"].select(kwargs["family_condition"]):
|
||||
for tag in parent_tag.find_all([re.compile(tag) for tag in kwargs["tags"]]):
|
||||
if not tag.attrs.get("unique_id"):
|
||||
tag.attrs["unique_id"] = u_id
|
||||
u_id += 1
|
||||
found_tags.append(tag)
|
||||
return len(found_tags) != 0, list(found_tags)
|
||||
found_tags.append(tag)
|
||||
return len(found_tags) != 0, list(set(found_tags))
|
||||
|
||||
@staticmethod
|
||||
def _tags_with_child_condition(**kwargs):
|
||||
@@ -184,6 +180,7 @@ class HtmlPresetsProcessor:
|
||||
def _unwrap_tag(self, **kwargs):
|
||||
if kwargs["found_tag"].parent:
|
||||
self.set_attrs_to_parent(kwargs["found_tag"], kwargs["found_tag"].parent)
|
||||
print(kwargs["found_tag"])
|
||||
kwargs["found_tag"].unwrap()
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user