EnvConfig.Variable.List Class Reference
Inheritance diagram for EnvConfig.Variable.List:
Collaboration diagram for EnvConfig.Variable.List:

Public Member Functions

def __init__
 
def name (self)
 
def set
 
def unset
 
def value
 
def remove_regexp
 
def remove
 
def append
 
def prepend
 
def search (self, expr, regExp)
 
def __getitem__ (self, key)
 
def __setitem__ (self, key, value)
 
def __delitem__ (self, key)
 
def __iter__ (self)
 
def __contains__ (self, item)
 
def __len__ (self)
 
def __str__ (self)
 
- Public Member Functions inherited from EnvConfig.Variable.VariableBase
def __init__
 
def process (self, value, env)
 

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.

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

Member Function Documentation

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

Definition at line 285 of file Variable.py.

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

Definition at line 278 of file Variable.py.

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

Definition at line 269 of file Variable.py.

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

Definition at line 281 of file Variable.py.

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

Definition at line 288 of file Variable.py.

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

Definition at line 272 of file Variable.py.

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

Definition at line 291 of file Variable.py.

291  def __str__(self):
292  return ':'.join(self.val)
293 
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.

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

Definition at line 199 of file Variable.py.

199  def name(self):
200  '''Returns the name of the List.'''
201  return self.varName
202 
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.

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

224  def remove(self, value, separator=':', regexp=False):
225  '''Removes value(s) from List. If value is not found, removal is canceled.'''
226  if regexp:
227  value = self.search(value, True)
228 
229  elif isinstance(value,str):
230  value = value.split(separator)
231 
232  for i in range(len(value)):
233  val = value[i]
234  if val not in value:
235  self.log.info('Value "%s" not found in List: "%s". Removal canceled.', val, self.varName)
236  while val in self.val:
237  self.val.remove(val)
238 
239 
def search(self, expr, regExp)
Definition: Variable.py:253
NamedRange_< CONTAINER > range(const CONTAINER &cnt, const std::string &name)
simple function to create the named range form arbitrary container
Definition: NamedRange.h:133
def EnvConfig.Variable.List.remove_regexp (   self,
  value,
  separator = ':' 
)

Definition at line 221 of file Variable.py.

221  def remove_regexp(self, value, separator = ':'):
222  self.remove(value, separator, True)
223 
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.

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

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

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

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

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: