| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
EnvConfig.Variable.EnvExpander Class Reference
Inheritance diagram for EnvConfig.Variable.EnvExpander:
[legend]
Collaboration diagram for EnvConfig.Variable.EnvExpander:
[legend]

## Public Member Functions
def | __init__
def | isTarget
def | process
Public Member Functions inherited from EnvConfig.Variable.VariableProcessor
def | __init__
def | isTarget
def | process
def | __call__

## Private Member Functions
def | _repl

## Private Attributes
| _exp

## Detailed Description

    Variable processor to expand the reference to environment variables.

Definition at line 63 of file Variable.py.

## Constructor & Destructor Documentation

def EnvConfig.Variable.EnvExpander.__init__ | ( |  | self,
|  |  | env
| ) |  |

Definition at line 67 of file Variable.py.

67
68 def __init__(self, env):
69 super(EnvExpander, self).__init__(env)
70 self._exp = re.compile(r"\$([A-Za-z_][A-Za-z0-9_]*)|\$\(([A-Za-z_][A-Za-z0-9_]*)\)|\$\{([A-Za-z_][A-Za-z0-9_]*)\}|\$\{(\.)\}")

## Member Function Documentation

def EnvConfig.Variable.EnvExpander._repl | ( |  | self,
|  |  | value
| ) |  |
| private

Definition at line 75 of file Variable.py.

75
76 def _repl(self, value):
77 m = self._exp.search(value)
78 if m:
79 try:
80 value = (value[:m.start()]
81 + str(self._env[filter(None, m.groups())[0]])
82 + value[m.end():])
83 except KeyError, k:
84 logging.debug('KeyError: %s unknown while expanding %s', k, value)
85 return value
86 return self._repl(value)
87 else:
88 return value

def EnvConfig.Variable.EnvExpander.isTarget | ( |  | self,
|  |  | variable
| ) |  |

Definition at line 71 of file Variable.py.

71
72 def isTarget(self, variable):
73 return (super(EnvExpander, self).isTarget(variable)
74 and variable.expandVars)

def EnvConfig.Variable.EnvExpander.process | ( |  | self,
|  |  | variable,
|  |  | value
| ) |  |

Definition at line 89 of file Variable.py.

89
90 def process(self, variable, value):
91 if isinstance(value, str):
92 value = self._repl(value)
93 else:
94 # expand only in the elements that are new
95 old_values = set(variable.val)
96 value = map(lambda v: v if v in old_values else self._repl(v), value)
97 return value

## Member Data Documentation

EnvConfig.Variable.EnvExpander._exp
| private

Definition at line 69 of file Variable.py.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/cmake/EnvConfig/Variable.py