Skip to content
Snippets Groups Projects
Commit ad9100f9 authored by Chris Lamb's avatar Chris Lamb :eyes:
Browse files

Move special-casing of returncodes in zip to use Command.VALID_RETURNCODES.

parent dd233275
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,11 @@ from .utils.command import Command
class Zipinfo(Command):
# zipinfo returns with an exit code of 1 or 2 when reading
# Mozilla-optimized or Java "jmod" ZIPs as they have non-standard headers
# which are safe to ignore.
VALID_RETURNCODES = {0, 1, 2}
@tool_required('zipinfo')
def cmdline(self):
# zipinfo (without -v) puts warning messages (some of which contain
......@@ -43,18 +48,6 @@ class Zipinfo(Command):
# to work around it, we run it on /dev/stdin instead, seems to work ok.
return ['zipinfo', '/dev/stdin']
@property
def returncode(self):
returncode = super().returncode
# zipinfo returns with an exit code of 1 or 2 when reading
# Mozilla-optimized or Java "jmod" ZIPs as they have non-standard
# headers which are safe to ignore.
if returncode in (1, 2):
returncode = 0
return returncode
def stdin(self):
return open(self.path, 'rb')
......@@ -72,6 +65,9 @@ class ZipinfoVerbose(Zipinfo):
class Zipnote(Command):
# zipnote returns with an exit code of 3 for invalid archives
VALID_RETURNCODES = {0, 3}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
......@@ -85,13 +81,6 @@ class Zipnote(Command):
shutil.copy(self.path, path)
return ['zipnote', path]
@property
def returncode(self):
returncode = super().returncode
# zipnote returns with an exit code of 3 for invalid archives
return 0 if returncode == 3 else returncode
def filter(self, line):
"""
Example output from zipnote(1):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment