1
0
Fork 0
mirror of synced 2025-07-03 03:47:20 +02:00

Improve the previous commit

This commit is contained in:
jvoisin 2018-09-05 17:22:17 +02:00
parent 1d7e374e5b
commit 46bb1b83ea
4 changed files with 40 additions and 7 deletions

View file

@ -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)