ATLAS Offline Software
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
python.trfEnv.pathVar Class Reference

Helper class for environment variables using colon separated paths. More...

Inheritance diagram for python.trfEnv.pathVar:
Collaboration diagram for python.trfEnv.pathVar:

Public Member Functions

def __init__ (self, varname, separator=":", testForExistance=True)
 
def add (self, value, prepend=True)
 Add a new element to the variable. More...
 
def __str__ (self)
 Return the correct string representing the value for the shell. More...
 

Private Attributes

 _name
 
 _separator
 
 _testExistance
 
 _value
 

Static Private Attributes

 _currentEnvironmentValue
 

Detailed Description

Helper class for environment variables using colon separated paths.

Definition at line 105 of file trfEnv.py.

Constructor & Destructor Documentation

◆ __init__()

def python.trfEnv.pathVar.__init__ (   self,
  varname,
  separator = ":",
  testForExistance = True 
)

Definition at line 108 of file trfEnv.py.

108  def __init__(self, varname, separator=":", testForExistance=True): self._name = varname
109  self._separator = separator
110  self._testExistance = testForExistance
111 
112  # Note the special value @c _currentEnvironmentValue that will be expanded to the current
113  # setting in the environment (i.e., @c os.environ['self._name']), if it exists
114  self._value = [self._currentEnvironmentValue]
115 
116 

Member Function Documentation

◆ __str__()

def python.trfEnv.pathVar.__str__ (   self)

Return the correct string representing the value for the shell.

Definition at line 136 of file trfEnv.py.

136  def __str__(self):
137  valStr = ""
138  for v in self._value:
139  if v == self._currentEnvironmentValue:
140  if self._name in os.environ:
141  valStr += "$" + self._name + self._separator
142  else:
143  valStr += v + self._separator
144  valStr = valStr[:-1]
145  return valStr

◆ add()

def python.trfEnv.pathVar.add (   self,
  value,
  prepend = True 
)

Add a new element to the variable.

Definition at line 118 of file trfEnv.py.

118  def add(self, value, prepend=True):
119  msg.debug('Adding new value "{0}" to envvar {1} (currently {2}'.format(value, self._name, self._value))
120  if value in self._value:
121  msg.warning('Attempt to add environment element {0} twice to {1}'.format(value, self._name))
122  if self._testExistance:
123  # expand environment variables (will only check current release, but this is the most common anyways)
124  test_value = value
125  if '$' in test_value:
126  test_value = os.path.join(os.environ[os.path.dirname(value)[1:]], os.path.basename(value))
127  if not os.access(test_value, os.R_OK):
128  msg.warning("Path to {0} is not readable - will not add it to {1}".format(value, self._name))
129  return
130  if prepend:
131  self._value[0:0] = [value]
132  else:
133  self._value.append(value)
134 

Member Data Documentation

◆ _currentEnvironmentValue

python.trfEnv.pathVar._currentEnvironmentValue
staticprivate

Definition at line 106 of file trfEnv.py.

◆ _name

python.trfEnv.pathVar._name
private

Definition at line 109 of file trfEnv.py.

◆ _separator

python.trfEnv.pathVar._separator
private

Definition at line 110 of file trfEnv.py.

◆ _testExistance

python.trfEnv.pathVar._testExistance
private

Definition at line 111 of file trfEnv.py.

◆ _value

python.trfEnv.pathVar._value
private

Definition at line 115 of file trfEnv.py.


The documentation for this class was generated from the following file:
vtune_athena.format
format
Definition: vtune_athena.py:14
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
add
bool add(const std::string &hname, TKey *tobj)
Definition: fastadd.cxx:55
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18