Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
adbar committed Oct 16, 2023
1 parent d070356 commit c39b9d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
3 changes: 2 additions & 1 deletion htmldate/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"picture",
"rdf",
"svg",
"track",
"video",
]
# "iframe", "layer", "param"
# "iframe", "input", "layer", "param", "source"
13 changes: 2 additions & 11 deletions htmldate/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
cchardet_detect = None
from charset_normalizer import from_bytes

# from lxml.etree import strip_tags
from lxml.html import HtmlElement, HTMLParser, fromstring # type: ignore

from .settings import MAX_FILE_SIZE, MIN_FILE_SIZE
Expand Down Expand Up @@ -219,19 +218,11 @@ def load_html(htmlobject: Union[bytes, str, HtmlElement]) -> Optional[HtmlElemen
return tree


def clean_html(tree, elemlist):
def clean_html(tree: HtmlElement, elemlist: List[str]) -> HtmlElement:
"Delete selected elements."
# return tree
for element in tree.iter(elemlist):
try:
element.drop_tree()
except AttributeError:
except AttributeError: # pragma: no cover
element.getparent().remove(element)
# for element in tree.xpath(".//*[@src]"):
# try:
# element.drop_tree()
# except AttributeError:
# element.getparent().remove(element)
# for element in tree.iter("head", "html", "title"):
# element.drop_tag()
return tree

0 comments on commit c39b9d2

Please sign in to comment.