Gaudi Framework, version v23r8

Home   Generated: Fri May 31 2013
 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:
Inheritance graph
[legend]
Collaboration diagram for EnvConfig.Variable.EnvExpander:
Collaboration graph
[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:
Generated at Fri May 31 2013 15:09:23 for Gaudi Framework, version v23r8 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004