CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Public Attributes
betterConfigParser.AdaptedDict Class Reference
Inheritance diagram for betterConfigParser.AdaptedDict:

Public Member Functions

def __getitem__
 
def __init__
 
def __setitem__
 
def items
 

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

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

Definition at line 24 of file betterConfigParser.py.

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

Member Function Documentation

def betterConfigParser.AdaptedDict.__getitem__ (   self,
  key 
)

Definition at line 50 of file betterConfigParser.py.

References betterConfigParser.AdaptedDict.validationslist.

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

References betterConfigParser.AdaptedDict.validationslist.

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

Definition at line 56 of file betterConfigParser.py.

References betterConfigParser.AdaptedDict.validationslist.

Referenced by DictTypes.SortedKeysDict.__repr__(), event.Event.__str__(), config.CFG.__str__(), generateEDF.LumiInfoCont.__str__(), generateEDF.LumiInfoCont._integrateContainer(), betterConfigParser.BetterConfigParser.exists(), submitPVValidationJobs.BetterConfigParser.exists(), crabConfigParser.CrabConfigParser.getSectionLines(), and python.rootplot.core.Options.kwarg_list().

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

Member Data Documentation

betterConfigParser.AdaptedDict.validationslist

Definition at line 25 of file betterConfigParser.py.

Referenced by betterConfigParser.AdaptedDict.__getitem__(), betterConfigParser.AdaptedDict.__setitem__(), and betterConfigParser.AdaptedDict.items().