Changes due to dev updates

This commit is contained in:
Kibzik
2023-03-27 14:26:38 +03:00
parent 3252131266
commit 54b97d01c5

View File

@@ -16,7 +16,7 @@ class HtmlPresetsProcessor:
"table_wrapper": self._process_tag_using_table,
"decomposer": self._decompose_tag,
"replacer": self._replace_tag,
"attrs_remover": self._remove_attrs,
"attr_remover": self._remove_attrs,
"attr_replacer": self._replace_attr,
"unwrapper": self._unwrap_tag,
"inserter": self._insert_tag,
@@ -204,7 +204,7 @@ class HtmlPresetsProcessor:
def process_tags(self,
body_tag: BeautifulSoup,
preset_rules: list[dict[str, Union[list[str], str, dict[str, Union[list[dict[str, str]], int, str]]]]],
preset_rule: dict[str, Union[list[str], str, dict[str, Union[list[dict[str, str]], int, str]]]],
action):
"""
Function does action with tags
@@ -212,7 +212,7 @@ class HtmlPresetsProcessor:
----------
body_tag: BeautifulSoup
Tag & contents of the body tag
preset_rules: List[Dict[str, Union[List[str], str, Dict[str, Union[List[Dict[str, str]], int, str]]]]]
preset_rule: Dict[str, Union[List[str], str, Dict[str, Union[List[Dict[str, str]], int, str]]]]
list of conditions when fire function
action: function
action what to do with tag
@@ -222,7 +222,6 @@ class HtmlPresetsProcessor:
Body Tag with processed certain tags
"""
for preset_rule in preset_rules:
tags: list[str] = preset_rule["tags"] if preset_rule.get(
"tags") else preset_rule["condition"]["tags"]
found_tags: list[Tag] = []
@@ -248,8 +247,8 @@ class HtmlPresetsProcessor:
action(body_tag=body_tag, found_tag=found_tag, rule=preset_rule)
def _process_presets(html_preprocessor: HtmlPresetsProcessor, html_soup: BeautifulSoup):
for preset in html_preprocessor.preset:
def _process_presets(html_presets_processor: HtmlPresetsProcessor, html_soup: BeautifulSoup):
for preset in html_presets_processor.preset:
# html_preprocessor.logger.log(rule["preset_name"].title() + " process.")
action = html_preprocessor.name2action[preset["preset_name"]]
html_preprocessor.process_tags(html_soup, preset["rules"], action)
action = html_presets_processor.name2action[preset["preset_name"]]
html_presets_processor.process_tags(html_soup, preset["rule"], action)