ATLAS Offline Software
Loading...
Searching...
No Matches
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 Types

typedef HLT::TypeInformation::for_each_type_c< typenameEDMLIST::map, my_functor, my_result<>, my_arg< HLT::TypeInformation::get_cont, CONTAINER > >::type result

Public Member Functions

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

Protected Attributes

 _name = varname
 _separator = separator
 _testExistance = testForExistance
list _value = [self._currentEnvironmentValue]

Static Protected Attributes

str _currentEnvironmentValue = "+++CURRENT+++"

Detailed Description

Helper class for environment variables using colon separated paths.

Definition at line 105 of file trfEnv.py.

Member Typedef Documentation

◆ result

Definition at line 90 of file EDM_MasterSearch.h.

Constructor & Destructor Documentation

◆ __init__()

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):
109 self._name = varname
110 self._separator = separator
111 self._testExistance = testForExistance
112
113 # Note the special value @c _currentEnvironmentValue that will be expanded to the current
114 # setting in the environment (i.e., @c os.environ['self._name']), if it exists
115 self._value = [self._currentEnvironmentValue]
116

Member Function Documentation

◆ __str__()

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()

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
bool add(const std::string &hname, TKey *tobj)
Definition fastadd.cxx:55

Member Data Documentation

◆ _currentEnvironmentValue

str python.trfEnv.pathVar._currentEnvironmentValue = "+++CURRENT+++"
staticprotected

Definition at line 106 of file trfEnv.py.

◆ _name

python.trfEnv.pathVar._name = varname
protected

Definition at line 109 of file trfEnv.py.

◆ _separator

python.trfEnv.pathVar._separator = separator
protected

Definition at line 110 of file trfEnv.py.

◆ _testExistance

python.trfEnv.pathVar._testExistance = testForExistance
protected

Definition at line 111 of file trfEnv.py.

◆ _value

python.trfEnv.pathVar._value = [self._currentEnvironmentValue]
protected

Definition at line 115 of file trfEnv.py.


The documentation for this class was generated from the following file: