Functions | |
def | FindFile |
def | which |
def | where |
Variables | |
string | __version__ = '1.0.0' |
string | __author__ = 'Wim Lavrijsen (WLavrijsen@lbl.gov)' |
list | __all__ = [ 'FindFile', 'which', 'where' ] |
def DybPython::unixtools::FindFile | ( | filename, | ||
pathlist, | ||||
access | ||||
) |
Find <filename> with rights <access> through <pathlist>.
Definition at line 17 of file unixtools.py.
00017 : 00018 """Find <filename> with rights <access> through <pathlist>.""" 00019 00020 # special case for those filenames that already contain a path 00021 if os.path.dirname( filename ): 00022 if os.access( filename, access ): 00023 return filename 00024 00025 # test the file name in all possible paths until first found 00026 for path in pathlist: 00027 f = os.path.join( path, filename ) 00028 if os.access( f, access ): 00029 return f 00030 00031 # no such accessible file avalailable 00032 return None 00033 00034 ### UNIX-style which ------------------------------------------------------------
def DybPython::unixtools::which | ( | filename, | ||
env = os.environ | ||||
) |
Search for <filename> through the PATH in environment <env>. Only executable files will be returned.
Definition at line 36 of file unixtools.py.
00036 : 00037 """Search for <filename> through the PATH in environment <env>. Only executable 00038 files will be returned.""" 00039 00040 # retrieve the value of the PATH environment variable 00041 try: 00042 p = env[ 'PATH' ] 00043 except KeyError: 00044 p = os.defpath 00045 00046 return FindFile( filename, string.split( p, os.pathsep ), os.X_OK ) 00047 00048 ### "which" for python files ----------------------------------------------------
def DybPython::unixtools::where | ( | filename, | ||
prepath = [] | ||||
) |
Search for <filename> in the python path and the given <prepath>.
Definition at line 50 of file unixtools.py.
00050 : 00051 """Search for <filename> in the python path and the given <prepath>.""" 00052 00053 # look in the given path and in the python path 00054 pathlist = prepath + sys.path 00055 00056 for ext in [ '', '.py', '.pyc', '.so' ]: 00057 result = FindFile( filename + ext, pathlist, os.R_OK ) 00058 if result: 00059 break 00060 00061 return result return result
string DybPython::unixtools::__version__ = '1.0.0' [static] |
Definition at line 10 of file unixtools.py.
string DybPython::unixtools::__author__ = 'Wim Lavrijsen (WLavrijsen@lbl.gov)' [static] |
Definition at line 11 of file unixtools.py.
list DybPython::unixtools::__all__ = [ 'FindFile', 'which', 'where' ] [static] |
Definition at line 13 of file unixtools.py.