summaryrefslogtreecommitdiff
path: root/libmat2/office.py
diff options
context:
space:
mode:
authorjvoisin2018-09-05 17:22:17 +0200
committerjvoisin2018-09-05 17:26:09 +0200
commit46bb1b83ea0843c25783f86e2033a10aeaed79d2 (patch)
tree3446382de51c0a861f4158f6be9e65bcf94b06ad /libmat2/office.py
parent1d7e374e5b0c6a84b3319d9d1e7c6f5c222af878 (diff)
Improve the previous commit
Diffstat (limited to 'libmat2/office.py')
-rw-r--r--libmat2/office.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/libmat2/office.py b/libmat2/office.py
index e79fe58..224067c 100644
--- a/libmat2/office.py
+++ b/libmat2/office.py
@@ -84,6 +84,11 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser):
84 84
85 def remove_all(self) -> bool: 85 def remove_all(self) -> bool:
86 # pylint: disable=too-many-branches 86 # pylint: disable=too-many-branches
87
88 if self.unknown_member_policy not in ['omit', 'keep', 'abort']:
89 logging.error("The policy %s is invalid.", self.unknown_member_policy)
90 raise ValueError
91
87 with zipfile.ZipFile(self.filename) as zin,\ 92 with zipfile.ZipFile(self.filename) as zin,\
88 zipfile.ZipFile(self.output_filename, 'w') as zout: 93 zipfile.ZipFile(self.output_filename, 'w') as zout:
89 94
@@ -120,9 +125,6 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser):
120 logging.warning("In file %s, keeping unknown element %s (format: %s)", 125 logging.warning("In file %s, keeping unknown element %s (format: %s)",
121 self.filename, item.filename, mtype) 126 self.filename, item.filename, mtype)
122 else: 127 else:
123 if self.unknown_member_policy != 'abort':
124 logging.warning("Invalid unknown_member_policy %s, " +
125 "treating as 'abort'", self.unknown_member_policy)
126 logging.error("In file %s, element %s's format (%s) " + 128 logging.error("In file %s, element %s's format (%s) " +
127 "isn't supported", 129 "isn't supported",
128 self.filename, item.filename, mtype) 130 self.filename, item.filename, mtype)