From 9ee4f65b90c5d2c5d63df87e2d78dbb1fffe4f85 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Sat, 6 Mar 2010 14:38:51 +0100 Subject: [PATCH] Check that archive exists before handling it. --- patool | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/patool b/patool index cc63a63..d87b920 100755 --- a/patool +++ b/patool @@ -20,6 +20,7 @@ patool [extract|list|create|formats] [sub-command-options] import sys 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.") +import os from patoolib import handle_archive, list_formats, baker # parameter help and short options @@ -32,11 +33,16 @@ shortopts = {"verbose": "v"} def handle_multi_archive(archives, cmd, **kwargs): """Handle a multi-archive command.""" res = 0 - for archive in archives: - newres = handle_archive(archive, cmd, **kwargs) - # return error if one of the archives could not be extracted - if newres: - res = newres + archives = [x for x in archives if os.path.exists(x)] + if archives: + for archive in archives: + 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