ATLAS Offline Software
Functions | Variables
python.Utils.unixtools Namespace Reference

Functions

def FindFile (filename, pathlist, access)
 helper -------------------------------------------------------------------— More...
 
def which (filename, env=os.environ)
 UNIX-style which ---------------------------------------------------------—. More...
 
def where (filename, prepath=[])
 "which" for python files -------------------------------------------------— More...
 
def find_datafile (fname, pathlist=None, access=os.R_OK)
 pathresolver-like helper function --------------------------------------— More...
 

Variables

string __version__ = '1.0.0'
 data ________________________________________________________________________ More...
 
string __author__ = 'Wim Lavrijsen (WLavrijsen@lbl.gov)'
 
list __all__
 

Function Documentation

◆ find_datafile()

def python.Utils.unixtools.find_datafile (   fname,
  pathlist = None,
  access = os.R_OK 
)

pathresolver-like helper function --------------------------------------—

the python equivalent to the C++ PathResolver for datafiles.

Definition at line 67 of file unixtools.py.

67 def find_datafile(fname, pathlist=None, access=os.R_OK):
68  """the python equivalent to the C++ PathResolver for datafiles.
69  """
70  if pathlist is None:
71  pathlist = os.getenv('DATAPATH').split(os.pathsep)
72 
73  if not isinstance(pathlist, list):
74  raise TypeError("pathlist must be a list or an iterable (got %s)" %
75  type(pathlist))
76 
77  return FindFile(fname, pathlist, access)

◆ FindFile()

def python.Utils.unixtools.FindFile (   filename,
  pathlist,
  access 
)

helper -------------------------------------------------------------------—

Find <filename> with rights <access> through <pathlist>.

Definition at line 20 of file unixtools.py.

20 def FindFile( filename, pathlist, access ):
21  """Find <filename> with rights <access> through <pathlist>."""
22 
23  # special case for those filenames that already contain a path
24  if os.path.dirname( filename ):
25  if os.access( filename, access ):
26  return filename
27 
28  # test the file name in all possible paths until first found
29  for path in pathlist:
30  f = os.path.join( path, filename )
31  if os.access( f, access ):
32  return f
33 
34  # no such accessible file avalailable
35  return None
36 
37 

◆ where()

def python.Utils.unixtools.where (   filename,
  prepath = [] 
)

"which" for python files -------------------------------------------------—

Search for <filename> in the python path and the given <prepath>.

Definition at line 53 of file unixtools.py.

53 def where( filename, prepath = [] ):
54  """Search for <filename> in the python path and the given <prepath>."""
55 
56  # look in the given path and in the python path
57  pathlist = prepath + sys.path
58 
59  for ext in [ '', '.py', '.pyc', '.so' ]:
60  result = FindFile( filename + ext, pathlist, os.R_OK )
61  if result:
62  break
63 
64  return result
65 

◆ which()

def python.Utils.unixtools.which (   filename,
  env = os.environ 
)

UNIX-style which ---------------------------------------------------------—.

Search for <filename> through the PATH in environment <env>. Only executable
files will be returned.

Definition at line 39 of file unixtools.py.

39 def which( filename, env = os.environ ):
40  """Search for <filename> through the PATH in environment <env>. Only executable
41 files will be returned."""
42 
43  # retrieve the value of the PATH environment variable
44  try:
45  p = env[ 'PATH' ]
46  except KeyError:
47  p = os.defpath
48 
49  return FindFile( filename, p.split( os.pathsep ), os.X_OK )
50 
51 

Variable Documentation

◆ __all__

list python.Utils.unixtools.__all__
private
Initial value:
1 = [ 'FindFile', 'which', 'where',
2  'find_datafile',]

Definition at line 15 of file unixtools.py.

◆ __author__

string python.Utils.unixtools.__author__ = 'Wim Lavrijsen (WLavrijsen@lbl.gov)'
private

Definition at line 13 of file unixtools.py.

◆ __version__

string python.Utils.unixtools.__version__ = '1.0.0'
private

data ________________________________________________________________________

Definition at line 12 of file unixtools.py.

python.Utils.unixtools.FindFile
def FindFile(filename, pathlist, access)
helper -------------------------------------------------------------------—
Definition: unixtools.py:20
python.Utils.unixtools.where
def where(filename, prepath=[])
"which" for python files -------------------------------------------------—
Definition: unixtools.py:53
python.Utils.unixtools.which
def which(filename, env=os.environ)
UNIX-style which ---------------------------------------------------------—.
Definition: unixtools.py:39
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
python.Utils.unixtools.find_datafile
def find_datafile(fname, pathlist=None, access=os.R_OK)
pathresolver-like helper function --------------------------------------—
Definition: unixtools.py:67
Trk::split
@ split
Definition: LayerMaterialProperties.h:38