Skip to content
Snippets Groups Projects
Commit 565cb66d authored by Julien (jvoisin) Voisin's avatar Julien (jvoisin) Voisin
Browse files

Minor simplification in how we're handling xml for office files

parent 052a3567
No related branches found
No related tags found
No related merge requests found
...@@ -22,17 +22,11 @@ assert Pattern ...@@ -22,17 +22,11 @@ assert Pattern
logging.basicConfig(level=logging.ERROR) logging.basicConfig(level=logging.ERROR)
def _parse_xml(full_path: str): def _parse_xml(full_path: str):
""" This function parse XML with namespace support. """ """ This function parse XML, with namespace support. """
def parse_map(f): # etree support for ns is a bit rough
namespace_map = dict()
for _, (key, value) in ET.iterparse(f, ("start-ns", )):
namespace_map[key] = value
return namespace_map
namespace_map = parse_map(full_path) namespace_map = dict()
for _, (key, value) in ET.iterparse(full_path, ("start-ns", )):
# Register the namespaces namespace_map[key] = value
for key, value in namespace_map.items():
ET.register_namespace(key, value) ET.register_namespace(key, value)
return ET.parse(full_path), namespace_map return ET.parse(full_path), namespace_map
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment