summaryrefslogtreecommitdiff
path: root/git/util.py
diff options
context:
space:
mode:
authorYaroslav Halchenko <debian@onerussian.com>2017-11-27 20:35:19 -0500
committerYaroslav Halchenko <debian@onerussian.com>2017-11-27 20:35:19 -0500
commit6ee08fce6ec508fdc6e577e3e507b342d048fa16 (patch)
tree47b8bac37afca3878d4535d3c13db38e55242628 /git/util.py
parent0a96030d82fa379d24b952a58eed395143950c7b (diff)
downloadgitpython-6ee08fce6ec508fdc6e577e3e507b342d048fa16.tar.gz
RF: primarily flake8 lints + minor RF to reduce duplication in PATHEXT
I did keep some "bare" except with catch all Exception: , while tried to disable flake8 complaints where clearly all exceptions are to be catched
Diffstat (limited to 'git/util.py')
-rw-r--r--git/util.py17
1 files changed, 6 insertions, 11 deletions
diff --git a/git/util.py b/git/util.py
index 5baeee91..18c28fd1 100644
--- a/git/util.py
+++ b/git/util.py
@@ -188,20 +188,15 @@ def assure_directory_exists(path, is_file=False):
def _get_exe_extensions():
- try:
- winprog_exts = tuple(p.upper() for p in os.environ['PATHEXT'].split(os.pathsep))
- except:
- winprog_exts = ('.BAT', 'COM', '.EXE')
-
- return winprog_exts
+ PATHEXT = os.environ.get('PATHEXT', None)
+ return tuple(p.upper() for p in PATHEXT.split(os.pathsep)) \
+ if PATHEXT \
+ else (('.BAT', 'COM', '.EXE') if is_win else ())
def py_where(program, path=None):
# From: http://stackoverflow.com/a/377028/548792
- try:
- winprog_exts = tuple(p.upper() for p in os.environ['PATHEXT'].split(os.pathsep))
- except:
- winprog_exts = is_win and ('.BAT', 'COM', '.EXE') or ()
+ winprog_exts = _get_exe_extensions()
def is_exec(fpath):
return osp.isfile(fpath) and os.access(fpath, os.X_OK) and (
@@ -347,7 +342,7 @@ def expand_path(p, expand_vars=True):
if expand_vars:
p = osp.expandvars(p)
return osp.normpath(osp.abspath(p))
- except:
+ except Exception:
return None
#} END utilities