From 58ea1d15f369cd5476378415c416c8470a7a8a52 Mon Sep 17 00:00:00 2001 From: Sean Hammond Date: Tue, 15 Jun 2010 20:42:44 +0100 Subject: [PATCH] If action is tidy then don't bother hecking if TO_DIR is valid. --- dotfilemanager.py | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/dotfilemanager.py b/dotfilemanager.py index c513028..1fd8a3d 100755 --- a/dotfilemanager.py +++ b/dotfilemanager.py @@ -179,24 +179,26 @@ if __name__ == "__main__": print usage() sys.exit(2) - try: - TO_DIR = sys.argv[3] - except IndexError: - TO_DIR = os.path.join('~','.dotfiles') - TO_DIR = os.path.abspath(os.path.expanduser(TO_DIR)) - - if not os.path.isdir(TO_DIR): - print "TO_DIR %s is not a directory!" % TO_DIR - print usage() - sys.exit(2) - - if ACTION == 'link': - link(FROM_DIR,TO_DIR) - elif ACTION == 'tidy': + if ACTION == 'tidy': tidy(FROM_DIR) - elif ACTION == 'report': - link(FROM_DIR,TO_DIR,report=True) - tidy(FROM_DIR,report=True) else: - print usage() - sys.exit(2) + + try: + TO_DIR = sys.argv[3] + except IndexError: + TO_DIR = os.path.join('~','.dotfiles') + TO_DIR = os.path.abspath(os.path.expanduser(TO_DIR)) + + if not os.path.isdir(TO_DIR): + print "TO_DIR %s is not a directory!" % TO_DIR + print usage() + sys.exit(2) + + if ACTION == 'link': + link(FROM_DIR,TO_DIR) + elif ACTION == 'report': + link(FROM_DIR,TO_DIR,report=True) + tidy(FROM_DIR,report=True) + else: + print usage() + sys.exit(2)