CMS 3D CMS Logo

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

Public Member Functions

def __setitem__
 
def getSep
 

Detailed Description

Dictionary which handles updates of values for already existing keys
in a modified way.
Instead of replacing the old value, the new value is appended to the
value string separated by `self.getSep()`.
This dictionary is used in the class `BetterConfigParser` instead of the
default `dict_type` of the `ConfigParser` class.

Definition at line 7 of file betterConfigParser.py.

Member Function Documentation

def betterConfigParser.AdaptedDict.__setitem__ (   self,
  key,
  value,
  dict_setitem = dict.__setitem__ 
)
od.__setitem__(i, y) <==> od[i]=y
Updating an existing key appends the new value to the old value
separated by `self.getSep()` 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 24 of file betterConfigParser.py.

References betterConfigParser.AdaptedDict.getSep().

Referenced by python.seqvaluedict.seqdict.update().

24 
25  def __setitem__(self, key, value, dict_setitem=dict.__setitem__):
26  """
27  od.__setitem__(i, y) <==> od[i]=y
28  Updating an existing key appends the new value to the old value
29  separated by `self.getSep()` instead of replacing it.
30 
31  Arguments:
32  - `key`: key part of the key-value pair
33  - `value`: value part of the key-value pair
34  - `dict_item`: method which is used for finally setting the item
35  """
36 
37  if "__name__" in self and self["__name__"]=="validation" \
38  and key in self and value!=self[key][0]:
39  the_value = [self[key][0]+self.getSep()+value[0]]
40  else:
41  the_value = value
42  dict_setitem(self, key, the_value)
43 
def betterConfigParser.AdaptedDict.getSep (   self)
This method returns the separator used to separate the values for 
duplicate options in a config.

Definition at line 17 of file betterConfigParser.py.

Referenced by betterConfigParser.AdaptedDict.__setitem__().

17 
18  def getSep(self):
19  """
20  This method returns the separator used to separate the values for
21  duplicate options in a config.
22  """
23  return " |/| "