Helper class for environment variables using colon separated paths.
More...
|
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...
|
|
Helper class for environment variables using colon separated paths.
Definition at line 105 of file trfEnv.py.
◆ __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
114 self._value = [self._currentEnvironmentValue]
◆ __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.
138 for v
in self._value:
139 if v == self._currentEnvironmentValue:
140 if self._name
in os.environ:
141 valStr +=
"$" + self._name + self._separator
143 valStr += v + self._separator
◆ 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:
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))
131 self._value[0:0] = [value]
◆ _currentEnvironmentValue
python.trfEnv.pathVar._currentEnvironmentValue |
|
staticprivate |
◆ _name
python.trfEnv.pathVar._name |
|
private |
◆ _separator
python.trfEnv.pathVar._separator |
|
private |
◆ _testExistance
python.trfEnv.pathVar._testExistance |
|
private |
◆ _value
python.trfEnv.pathVar._value |
|
private |
The documentation for this class was generated from the following file: