Gaudi Framework, version v25r0

Home   Generated: Mon Feb 17 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 185 of file Variable.py.

Constructor & Destructor Documentation

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

Definition at line 193 of file Variable.py.

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

Member Function Documentation

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

Definition at line 283 of file Variable.py.

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

Definition at line 276 of file Variable.py.

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

Definition at line 267 of file Variable.py.

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

Definition at line 279 of file Variable.py.

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

Definition at line 286 of file Variable.py.

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

Definition at line 270 of file Variable.py.

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

Definition at line 289 of file Variable.py.

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

Definition at line 238 of file Variable.py.

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

Definition at line 197 of file Variable.py.

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

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

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

Definition at line 219 of file Variable.py.

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

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

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

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

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

Member Data Documentation

EnvConfig.Variable.List.val

Definition at line 195 of file Variable.py.


The documentation for this class was generated from the following file:
Generated at Mon Feb 17 2014 14:38:14 for Gaudi Framework, version v25r0 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004