summaryrefslogtreecommitdiff
path: root/libmat2/office.py
diff options
context:
space:
mode:
Diffstat (limited to 'libmat2/office.py')
-rw-r--r--libmat2/office.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/libmat2/office.py b/libmat2/office.py
index b3fde7e..1ececdf 100644
--- a/libmat2/office.py
+++ b/libmat2/office.py
@@ -4,7 +4,9 @@ import shutil
4import tempfile 4import tempfile
5import datetime 5import datetime
6import zipfile 6import zipfile
7import logging
7from typing import Dict, Set, Pattern 8from typing import Dict, Set, Pattern
9
8try: # protect against DoS 10try: # protect against DoS
9 from defusedxml import ElementTree as ET # type: ignore 11 from defusedxml import ElementTree as ET # type: ignore
10except ImportError: 12except ImportError:
@@ -17,6 +19,8 @@ from . import abstract, parser_factory
17assert Set 19assert Set
18assert Pattern 20assert Pattern
19 21
22logging.basicConfig(level=logging.ERROR)
23
20def _parse_xml(full_path: str): 24def _parse_xml(full_path: str):
21 """ This function parse XML with namespace support. """ 25 """ This function parse XML with namespace support. """
22 def parse_map(f): # etree support for ns is a bit rough 26 def parse_map(f): # etree support for ns is a bit rough
@@ -98,7 +102,7 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser):
98 if self._specific_cleanup(full_path) is False: 102 if self._specific_cleanup(full_path) is False:
99 shutil.rmtree(temp_folder) 103 shutil.rmtree(temp_folder)
100 os.remove(self.output_filename) 104 os.remove(self.output_filename)
101 print("Something went wrong during deep cleaning of %s" % item.filename) 105 logging.info("Something went wrong during deep cleaning of %s", item.filename)
102 return False 106 return False
103 107
104 if item.filename in self.files_to_keep: 108 if item.filename in self.files_to_keep:
@@ -112,7 +116,7 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser):
112 if not tmp_parser: 116 if not tmp_parser:
113 shutil.rmtree(temp_folder) 117 shutil.rmtree(temp_folder)
114 os.remove(self.output_filename) 118 os.remove(self.output_filename)
115 print("%s's format (%s) isn't supported" % (item.filename, mtype)) 119 logging.info("%s's format (%s) isn't supported", item.filename, mtype)
116 return False 120 return False
117 tmp_parser.remove_all() 121 tmp_parser.remove_all()
118 os.rename(tmp_parser.output_filename, full_path) 122 os.rename(tmp_parser.output_filename, full_path)