CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
betterConfigParser.AdaptedDict Class Reference
Inheritance diagram for betterConfigParser.AdaptedDict:

Public Member Functions

def __getitem__ (self, key)
 
def __init__ (self, *args, **kwargs)
 
def __setitem__ (self, key, value, dict_setitem=collections.OrderedDict.__setitem__)
 
def items (self)
 

Public Attributes

 validationslist
 

Detailed Description

Dictionary which handles updates of values for already existing keys
in a modified way.
adapteddict[key] returns a list of all values associated with key
This dictionary is used in the class `BetterConfigParser` instead of the
default `dict_type` of the `ConfigParser` class.

Definition at line 15 of file betterConfigParser.py.

Constructor & Destructor Documentation

◆ __init__()

def betterConfigParser.AdaptedDict.__init__ (   self,
args,
**  kwargs 
)

Definition at line 24 of file betterConfigParser.py.

24  def __init__(self, *args, **kwargs):
25  self.validationslist = []
26  collections.OrderedDict.__init__(self, *args, **kwargs)
27 

Member Function Documentation

◆ __getitem__()

def betterConfigParser.AdaptedDict.__getitem__ (   self,
  key 
)

Definition at line 50 of file betterConfigParser.py.

50  def __getitem__(self, key):
51  if key != "__name__" and "__name__" in self and self["__name__"]=="validation":
52  return [validation[1] for validation in self.validationslist if validation[0] == key]
53  else:
54  return collections.OrderedDict.__getitem__(self, key)
55 

References betterConfigParser.AdaptedDict.validationslist.

◆ __setitem__()

def betterConfigParser.AdaptedDict.__setitem__ (   self,
  key,
  value,
  dict_setitem = collections.OrderedDict.__setitem__ 
)
od.__setitem__(i, y) <==> od[i]=y
Updating an existing key appends the new value to the old value
instead of replacing it.

Arguments:
- `key`: key part of the key-value pair
- `value`: value part of the key-value pair
- `dict_item`: method which is used for finally setting the item

Definition at line 28 of file betterConfigParser.py.

28  def __setitem__(self, key, value, dict_setitem=collections.OrderedDict.__setitem__):
29  """
30  od.__setitem__(i, y) <==> od[i]=y
31  Updating an existing key appends the new value to the old value
32  instead of replacing it.
33 
34  Arguments:
35  - `key`: key part of the key-value pair
36  - `value`: value part of the key-value pair
37  - `dict_item`: method which is used for finally setting the item
38  """
39 
40  if key != "__name__" and "__name__" in self and self["__name__"]=="validation":
41  if isinstance(value, (str, unicode)):
42  for index, item in enumerate(self.validationslist[:]):
43  if item == (key, value.split("\n")):
44  self.validationslist[index] = (key, value)
45  return
46  self.validationslist.append((key, value))
47  else:
48  dict_setitem(self, key, value)
49 

References mps_setup.append, and betterConfigParser.AdaptedDict.validationslist.

◆ items()

def betterConfigParser.AdaptedDict.items (   self)

Definition at line 56 of file betterConfigParser.py.

56  def items(self):
57  if "__name__" in self and self["__name__"]=="validation":
58  return self.validationslist
59  else:
60  return collections.OrderedDict.items(self)
61 

References betterConfigParser.AdaptedDict.validationslist.

Referenced by betterConfigParser.BetterConfigParser.exists(), submitPVValidationJobs.BetterConfigParser.exists(), crabConfigParser.CrabConfigParser.getSectionLines(), and python.rootplot.core.Options.kwarg_list().

Member Data Documentation

◆ validationslist

betterConfigParser.AdaptedDict.validationslist
mps_monitormerge.items
list items
Definition: mps_monitormerge.py:29
mps_setup.append
append
Definition: mps_setup.py:85