initial working version

This commit is contained in:
Chris Yereaztian
2015-01-31 01:12:34 +01:00
parent 30bd8895c5
commit 9c892ffe92
9 changed files with 781 additions and 0 deletions

20
simpleextractor/which.py Normal file
View File

@@ -0,0 +1,20 @@
"""
which.py : Same as the Unix "which" command: tests if an executable exists and returns name
"""
def which(program):
# Author Credit: Jay @ http://stackoverflow.com/a/377028
import os
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None