From 5f2979e442ac1a7a0255b813cc004ef2ab911572 Mon Sep 17 00:00:00 2001 From: Erik Hahn Date: Thu, 30 Jul 2009 22:03:11 +0200 Subject: [PATCH] Catch IndexError when directory is missing --- ordnung.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ordnung.py b/ordnung.py index eb6988f..5881795 100644 --- a/ordnung.py +++ b/ordnung.py @@ -1,6 +1,6 @@ from path import path import fnmatch -import os +import os, sys from optparse import OptionParser from tag_wrapper import tag @@ -38,8 +38,12 @@ def main(): parser.add_option("-t", "--target", dest="targetpath", help="create new directory structure in directory TARGET (default=directory)") #TODO: not implemented (options, args) = parser.parse_args() - - base=args[0] + + try: + base = args[0] + except IndexError: + print "You must specify a directory" + sys.exit() basepath = path(base) for filepath in basepath.walkfiles(): if issupportedfile(filepath): -- 2.11.4.GIT