From 46bb1b83ea0843c25783f86e2033a10aeaed79d2 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 5 Sep 2018 17:22:17 +0200 Subject: Improve the previous commit --- libmat2/office.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libmat2/office.py') 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): def remove_all(self) -> bool: # pylint: disable=too-many-branches + + if self.unknown_member_policy not in ['omit', 'keep', 'abort']: + logging.error("The policy %s is invalid.", self.unknown_member_policy) + raise ValueError + with zipfile.ZipFile(self.filename) as zin,\ zipfile.ZipFile(self.output_filename, 'w') as zout: @@ -120,9 +125,6 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser): logging.warning("In file %s, keeping unknown element %s (format: %s)", self.filename, item.filename, mtype) else: - if self.unknown_member_policy != 'abort': - logging.warning("Invalid unknown_member_policy %s, " + - "treating as 'abort'", self.unknown_member_policy) logging.error("In file %s, element %s's format (%s) " + "isn't supported", self.filename, item.filename, mtype) -- cgit v1.3