Check that archive exists before handling it.
This commit is contained in:
parent
0ad54e0f0f
commit
9ee4f65b90
16
patool
16
patool
|
@ -20,6 +20,7 @@ patool [extract|list|create|formats] [sub-command-options] <command-args>
|
||||||
import sys
|
import sys
|
||||||
if not hasattr(sys, "version_info") or sys.version_info < (2, 4, 0, "final", 0):
|
if not hasattr(sys, "version_info") or sys.version_info < (2, 4, 0, "final", 0):
|
||||||
raise SystemExit("This program requires Python 2.4 or later.")
|
raise SystemExit("This program requires Python 2.4 or later.")
|
||||||
|
import os
|
||||||
from patoolib import handle_archive, list_formats, baker
|
from patoolib import handle_archive, list_formats, baker
|
||||||
|
|
||||||
# parameter help and short options
|
# parameter help and short options
|
||||||
|
@ -32,11 +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
|
||||||
for archive in archives:
|
archives = [x for x in archives if os.path.exists(x)]
|
||||||
newres = handle_archive(archive, cmd, **kwargs)
|
if archives:
|
||||||
# return error if one of the archives could not be extracted
|
for archive in archives:
|
||||||
if newres:
|
newres = handle_archive(archive, cmd, **kwargs)
|
||||||
res = newres
|
# return error if one of the archives could not be extracted
|
||||||
|
if newres:
|
||||||
|
res = newres
|
||||||
|
else:
|
||||||
|
print >>sys.stderr, "patool error: none of the given archive files exist"
|
||||||
|
res = 1
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue