From 37f0daf18f66674d2dcbf2429f594e7677969c6a Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Mon, 13 Feb 2012 21:05:48 +0100 Subject: [PATCH] Print error when archive files do not exist. --- doc/changelog.txt | 1 + patool | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/doc/changelog.txt b/doc/changelog.txt index 19c1942..2bf0bb6 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -1,6 +1,7 @@ 0.15 "" (released xx.xx.2012) * Print help when unknown options are given. + * Print error when archive files do not exist. 0.14 "Book of Dragons" (released 30.1.2012) diff --git a/patool b/patool index 9aafa4e..eb0866f 100755 --- a/patool +++ b/patool @@ -33,16 +33,16 @@ shortopts = {"verbose": "v"} def handle_multi_archive(archives, cmd, **kwargs): """Handle a multi-archive command.""" res = 0 - archives = [x for x in archives if os.path.exists(x)] - if archives: - for archive in archives: + for archive in archives: + if not os.path.isfile(archive): + res = 1 + msg = "archive %r is not a file" % archive + print >>sys.stderr, "patool error:", msg + else: newres = handle_archive(archive, cmd, **kwargs) # 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 @@ -70,16 +70,19 @@ def create (archive, file1, *files, **kwargs): allfiles = (file1,)+files return handle_archive(archive, 'create', *allfiles, **kwargs) + @baker.command def diff (archive1, archive2): """Show differences between two archives.""" return handle_archive(archive1, "diff", archive2) + @baker.command def repack (archive1, archive2): """Repackage one archive in another format.""" return handle_archive(archive1, "repack", archive2) + @baker.command def formats (): """List supported and available archive formats."""