diff options
author | Dylan Baker <baker.dylan.c@gmail.com> | 2015-11-13 15:42:20 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2016-06-01 07:08:43 -0700 |
commit | 0c323b06abc4a42ee7a2b900308f6c617ea9e4c1 (patch) | |
tree | e7c1cf276bb151317e264e36df42b5a118ffa013 /framework | |
parent | 20dff36860e6ad411c4107a5ebebd4a06c309849 (diff) |
core.py: remove flag from checkDir, use exception block
This simplifies the function.
Diffstat (limited to 'framework')
-rw-r--r-- | framework/core.py | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/framework/core.py b/framework/core.py index 870a70816..c339572ef 100644 --- a/framework/core.py +++ b/framework/core.py @@ -117,17 +117,13 @@ def get_config(arg=None): # Ensure the given directory exists def checkDir(dirname, failifexists): - exists = True try: os.stat(dirname) except OSError as e: - if e.errno in [errno.ENOENT, errno.ENOTDIR]: - exists = False - - if exists and failifexists: - print("%(dirname)s exists already.\nUse --overwrite if " - "you want to overwrite it.\n" % locals(), file=sys.stderr) - exit(1) + if e.errno not in [errno.ENOENT, errno.ENOTDIR] and failifexists: + print("%(dirname)s exists already.\nUse --overwrite if " + "you want to overwrite it.\n" % locals(), file=sys.stderr) + exit(1) try: os.makedirs(dirname) |