Gaudi Framework, version v23r6

Home   Generated: Wed Jan 30 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Public Attributes | List of all members
EnvConfig.Variable.List Class Reference
Inheritance diagram for EnvConfig.Variable.List:
Inheritance graph
[legend]
Collaboration diagram for EnvConfig.Variable.List:
Collaboration graph
[legend]

Public Member Functions

def __init__
 
def name
 
def set
 
def unset
 
def value
 
def remove_regexp
 
def remove
 
def append
 
def prepend
 
def search
 
def __getitem__
 
def __setitem__
 
def __delitem__
 
def __iter__
 
def __contains__
 
def __len__
 
def __str__
 
- Public Member Functions inherited from EnvConfig.Variable.VariableBase
def __init__
 
def process
 

Public Attributes

 val
 
- Public Attributes inherited from EnvConfig.Variable.VariableBase
 report
 
 varName
 
 local
 
 expandVars
 

Detailed Description

Class for manipulating with environment lists.

It holds its name and values represented by a list.
Some operations are done with separator, which is usually colon. For windows use semicolon.

Definition at line 180 of file Variable.py.

Constructor & Destructor Documentation

def EnvConfig.Variable.List.__init__ (   self,
  name,
  local = False,
  report = None 
)

Definition at line 188 of file Variable.py.

189  def __init__(self, name, local=False, report=None):
190  super(List, self).__init__(name, local, report)
191  self.val = []

Member Function Documentation

def EnvConfig.Variable.List.__contains__ (   self,
  item 
)

Definition at line 278 of file Variable.py.

279  def __contains__(self, item):
280  return item in self.val
def EnvConfig.Variable.List.__delitem__ (   self,
  key 
)

Definition at line 271 of file Variable.py.

272  def __delitem__(self, key):
273  self.remove(self.val[key])
def EnvConfig.Variable.List.__getitem__ (   self,
  key 
)

Definition at line 262 of file Variable.py.

263  def __getitem__(self, key):
264  return self.val[key]
def EnvConfig.Variable.List.__iter__ (   self)

Definition at line 274 of file Variable.py.

275  def __iter__(self):
276  for i in self.val:
277  yield i
def EnvConfig.Variable.List.__len__ (   self)

Definition at line 281 of file Variable.py.

282  def __len__(self):
283  return len(self.val)
def EnvConfig.Variable.List.__setitem__ (   self,
  key,
  value 
)

Definition at line 265 of file Variable.py.

266  def __setitem__(self, key, value):
267  if value in self.val:
268  self.report.addWarn('Var: "' + self.varName + '" value: "' + value + '". Addition canceled because of duplicate entry.')
269  else:
270  self.val.insert(key, value)
def EnvConfig.Variable.List.__str__ (   self)

Definition at line 284 of file Variable.py.

285  def __str__(self):
286  return ':'.join(self.val)
287 
def EnvConfig.Variable.List.append (   self,
  value,
  separator = ':',
  environment = None 
)
Adds value(s) at the end of the list.

Definition at line 233 of file Variable.py.

234  def append(self, value, separator=':', environment=None):
235  '''Adds value(s) at the end of the list.'''
236  if isinstance(value, str):
237  value = value.split(separator)
238  self.val = self.process(self.val + value, environment)
def EnvConfig.Variable.List.name (   self)
Returns the name of the List.

Definition at line 192 of file Variable.py.

193  def name(self):
194  '''Returns the name of the List.'''
195  return self.varName
def EnvConfig.Variable.List.prepend (   self,
  value,
  separator = ':',
  environment = None 
)
Adds value(s) at the beginning of the list.
resolve references and duplications

Definition at line 239 of file Variable.py.

240  def prepend(self, value, separator=':', environment=None):
241  '''Adds value(s) at the beginning of the list.
242  resolve references and duplications'''
243  if isinstance(value, str):
244  value = value.split(separator)
245  self.val = self.process(value + self.val, environment)
def EnvConfig.Variable.List.remove (   self,
  value,
  separator = ':',
  regexp = False 
)
Removes value(s) from List. If value is not found, removal is canceled.

Definition at line 217 of file Variable.py.

218  def remove(self, value, separator=':', regexp=False):
219  '''Removes value(s) from List. If value is not found, removal is canceled.'''
220  if regexp:
221  value = self.search(value, True)
222 
223  elif isinstance(value,str):
224  value = value.split(separator)
225 
226  for i in range(len(value)):
227  val = value[i]
228  if val not in value:
229  self.report.addWarn('Value "'+val+'" not found in List: "'+self.varName+'". Removal canceled.')
230  while val in self.val:
231  self.val.remove(val)
232 
def EnvConfig.Variable.List.remove_regexp (   self,
  value,
  separator = ':' 
)

Definition at line 214 of file Variable.py.

215  def remove_regexp(self, value, separator = ':'):
216  self.remove(value, separator, True)
def EnvConfig.Variable.List.search (   self,
  expr,
  regExp 
)
Searches in List's values for a match

Use string value or set regExp to True.
In the first case search is done only for an exact match for one of List`s value ('^' and '$' added).

Definition at line 246 of file Variable.py.

247  def search(self, expr, regExp):
248  '''Searches in List's values for a match
249 
250  Use string value or set regExp to True.
251  In the first case search is done only for an exact match for one of List`s value ('^' and '$' added).
252  '''
253  if not regExp:
254  expr = '^' + expr + '$'
255  v = re.compile(expr)
256  res = []
257  for val in self.val:
258  if v.search(val):
259  res.append(val)
260 
261  return res
def EnvConfig.Variable.List.set (   self,
  value,
  separator = ':',
  environment = None 
)
Sets the value of the List. Any previous value is overwritten.

Definition at line 196 of file Variable.py.

197  def set(self, value, separator=':', environment=None):
198  '''Sets the value of the List. Any previous value is overwritten.'''
199  if isinstance(value, str):
200  value = value.split(separator)
201  self.val = self.process(value, environment)
def EnvConfig.Variable.List.unset (   self,
  value,
  separator = ':',
  environment = None 
)
Sets the value of the List to empty. Any previous value is overwritten.

Definition at line 202 of file Variable.py.

203  def unset(self, value, separator=':', environment=None):# pylint: disable=W0613
204  '''Sets the value of the List to empty. Any previous value is overwritten.'''
205  self.val = []
def EnvConfig.Variable.List.value (   self,
  asString = False,
  separator = ':' 
)
Returns values of the List. Either as a list or string with desired separator.

Definition at line 206 of file Variable.py.

207  def value(self, asString=False, separator=':'):
208  '''Returns values of the List. Either as a list or string with desired separator.'''
209  if asString:
210  return separator.join(self.val)
211  else:
212  # clone the list
213  return list(self.val)

Member Data Documentation

EnvConfig.Variable.List.val

Definition at line 190 of file Variable.py.


The documentation for this class was generated from the following file:
Generated at Wed Jan 30 2013 17:13:49 for Gaudi Framework, version v23r6 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004