Print error when archive files do not exist.
This commit is contained in:
parent
81ab40ab45
commit
37f0daf18f
|
@ -1,6 +1,7 @@
|
||||||
0.15 "" (released xx.xx.2012)
|
0.15 "" (released xx.xx.2012)
|
||||||
|
|
||||||
* Print help when unknown options are given.
|
* Print help when unknown options are given.
|
||||||
|
* Print error when archive files do not exist.
|
||||||
|
|
||||||
0.14 "Book of Dragons" (released 30.1.2012)
|
0.14 "Book of Dragons" (released 30.1.2012)
|
||||||
|
|
||||||
|
|
15
patool
15
patool
|
@ -33,16 +33,16 @@ shortopts = {"verbose": "v"}
|
||||||
def handle_multi_archive(archives, cmd, **kwargs):
|
def handle_multi_archive(archives, cmd, **kwargs):
|
||||||
"""Handle a multi-archive command."""
|
"""Handle a multi-archive command."""
|
||||||
res = 0
|
res = 0
|
||||||
archives = [x for x in archives if os.path.exists(x)]
|
for archive in archives:
|
||||||
if archives:
|
if not os.path.isfile(archive):
|
||||||
for archive in archives:
|
res = 1
|
||||||
|
msg = "archive %r is not a file" % archive
|
||||||
|
print >>sys.stderr, "patool error:", msg
|
||||||
|
else:
|
||||||
newres = handle_archive(archive, cmd, **kwargs)
|
newres = handle_archive(archive, cmd, **kwargs)
|
||||||
# return error if one of the archives could not be extracted
|
# return error if one of the archives could not be extracted
|
||||||
if newres:
|
if newres:
|
||||||
res = newres
|
res = newres
|
||||||
else:
|
|
||||||
print >>sys.stderr, "patool error: none of the given archive files exist"
|
|
||||||
res = 1
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,16 +70,19 @@ def create (archive, file1, *files, **kwargs):
|
||||||
allfiles = (file1,)+files
|
allfiles = (file1,)+files
|
||||||
return handle_archive(archive, 'create', *allfiles, **kwargs)
|
return handle_archive(archive, 'create', *allfiles, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
@baker.command
|
@baker.command
|
||||||
def diff (archive1, archive2):
|
def diff (archive1, archive2):
|
||||||
"""Show differences between two archives."""
|
"""Show differences between two archives."""
|
||||||
return handle_archive(archive1, "diff", archive2)
|
return handle_archive(archive1, "diff", archive2)
|
||||||
|
|
||||||
|
|
||||||
@baker.command
|
@baker.command
|
||||||
def repack (archive1, archive2):
|
def repack (archive1, archive2):
|
||||||
"""Repackage one archive in another format."""
|
"""Repackage one archive in another format."""
|
||||||
return handle_archive(archive1, "repack", archive2)
|
return handle_archive(archive1, "repack", archive2)
|
||||||
|
|
||||||
|
|
||||||
@baker.command
|
@baker.command
|
||||||
def formats ():
|
def formats ():
|
||||||
"""List supported and available archive formats."""
|
"""List supported and available archive formats."""
|
||||||
|
|
Loading…
Reference in New Issue