Gaudi Framework, version v25r2

Home   Generated: Wed Jun 4 2014
 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
 varName
 
 local
 
 expandVars
 
 log
 

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 187 of file Variable.py.

Constructor & Destructor Documentation

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

Definition at line 195 of file Variable.py.

196  def __init__(self, name, local=False):
197  super(List, self).__init__(name, local)
198  self.val = []

Member Function Documentation

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

Definition at line 285 of file Variable.py.

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

Definition at line 278 of file Variable.py.

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

Definition at line 269 of file Variable.py.

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

Definition at line 281 of file Variable.py.

282  def __iter__(self):
283  for i in self.val:
284  yield i
def EnvConfig.Variable.List.__len__ (   self)

Definition at line 288 of file Variable.py.

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

Definition at line 272 of file Variable.py.

273  def __setitem__(self, key, value):
274  if value in self.val:
275  self.log.info('Var: "%s" value: "%s". Addition canceled because of duplicate entry.', self.varName, value)
276  else:
277  self.val.insert(key, value)
def EnvConfig.Variable.List.__str__ (   self)

Definition at line 291 of file Variable.py.

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

Definition at line 240 of file Variable.py.

241  def append(self, value, separator=':', environment=None):
242  '''Adds value(s) at the end of the list.'''
243  if isinstance(value, str):
244  value = value.split(separator)
245  self.val = self.process(self.val + value, environment)
def EnvConfig.Variable.List.name (   self)
Returns the name of the List.

Definition at line 199 of file Variable.py.

200  def name(self):
201  '''Returns the name of the List.'''
202  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 246 of file Variable.py.

247  def prepend(self, value, separator=':', environment=None):
248  '''Adds value(s) at the beginning of the list.
249  resolve references and duplications'''
250  if isinstance(value, str):
251  value = value.split(separator)
252  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 224 of file Variable.py.

225  def remove(self, value, separator=':', regexp=False):
226  '''Removes value(s) from List. If value is not found, removal is canceled.'''
227  if regexp:
228  value = self.search(value, True)
229 
230  elif isinstance(value,str):
231  value = value.split(separator)
232 
233  for i in range(len(value)):
234  val = value[i]
235  if val not in value:
236  self.log.info('Value "%s" not found in List: "%s". Removal canceled.', val, self.varName)
237  while val in self.val:
238  self.val.remove(val)
239 
def EnvConfig.Variable.List.remove_regexp (   self,
  value,
  separator = ':' 
)

Definition at line 221 of file Variable.py.

222  def remove_regexp(self, value, separator = ':'):
223  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 253 of file Variable.py.

254  def search(self, expr, regExp):
255  '''Searches in List's values for a match
256 
257  Use string value or set regExp to True.
258  In the first case search is done only for an exact match for one of List`s value ('^' and '$' added).
259  '''
260  if not regExp:
261  expr = '^' + expr + '$'
262  v = re.compile(expr)
263  res = []
264  for val in self.val:
265  if v.search(val):
266  res.append(val)
267 
268  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 203 of file Variable.py.

204  def set(self, value, separator=':', environment=None):
205  '''Sets the value of the List. Any previous value is overwritten.'''
206  if isinstance(value, str):
207  value = value.split(separator)
208  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 209 of file Variable.py.

210  def unset(self, value, separator=':', environment=None):# pylint: disable=W0613
211  '''Sets the value of the List to empty. Any previous value is overwritten.'''
212  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 213 of file Variable.py.

214  def value(self, asString=False, separator=':'):
215  '''Returns values of the List. Either as a list or string with desired separator.'''
216  if asString:
217  return separator.join(self.val)
218  else:
219  # clone the list
220  return list(self.val)

Member Data Documentation

EnvConfig.Variable.List.val

Definition at line 197 of file Variable.py.


The documentation for this class was generated from the following file:
Generated at Wed Jun 4 2014 14:49:04 for Gaudi Framework, version v25r2 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004