Add error handling for SVG parsing.

This commit is contained in:
Sergey Vartanov 2022-08-19 10:56:54 +03:00
parent cb1bdceedb
commit cdbcedc6ec

View file

@ -310,10 +310,12 @@ class ShapeExtractor:
id_: str = node.attrib["id"] id_: str = node.attrib["id"]
if STANDARD_INKSCAPE_ID_MATCHER.match(id_) is not None: if STANDARD_INKSCAPE_ID_MATCHER.match(id_) is not None:
if not verify_sketch_element(node, id_): if not verify_sketch_element(node, id_):
logging.warning( path_part = ""
f"Not verified SVG element `{id_}`, " try:
f"{node.attrib['d'].split(' ')[:3]}." path_part = f", {node.attrib['d'].split(' ')[:3]}."
) except (KeyError, ValueError):
pass
logging.warning(f"Not verified SVG element `{id_}`{path_part}")
return return
if "d" in node.attrib and node.attrib["d"]: if "d" in node.attrib and node.attrib["d"]: