From 565cb66d1405bc334681e59ae41f8631b96e7d51 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Thu, 19 Jul 2018 22:52:40 +0200 Subject: [PATCH] Minor simplification in how we're handling xml for office files --- libmat2/office.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/libmat2/office.py b/libmat2/office.py index 1ececdf..c6c4688 100644 --- a/libmat2/office.py +++ b/libmat2/office.py @@ -22,17 +22,11 @@ assert Pattern logging.basicConfig(level=logging.ERROR) def _parse_xml(full_path: str): - """ 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 + """ This function parse XML, with namespace support. """ - namespace_map = parse_map(full_path) - - # Register the namespaces - for key, value in namespace_map.items(): + namespace_map = dict() + for _, (key, value) in ET.iterparse(full_path, ("start-ns", )): + namespace_map[key] = value ET.register_namespace(key, value) return ET.parse(full_path), namespace_map