Module config :: Class ConfigMerger
[show private | hide private]
[frames | no frames]

Type ConfigMerger

object --+
         |
        ConfigMerger


This class is used for merging two configurations. If a key exists in the merge operand but not the merge target, then the entry is copied from the merge operand to the merge target. If a key exists in both configurations, then a resolver (a callable) is called to decide how to handle the conflict.
Method Summary
  __init__(self, resolver)
Initialise an instance.
  handleMismatch(self, obj1, obj2)
Handle a mismatch between two objects.
  merge(self, merged, mergee)
Merge two configurations.
  mergeMapping(self, map1, map2)
Merge two mappings recursively.
  mergeSequence(self, seq1, seq2)
Merge two sequences.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
Return hash(x)...
  __new__(T, S, ...)
Return a new object with type S, a subtype of T...
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
Return repr(x)...
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
Return str(x)...

Method Details

__init__(self, resolver=<function defaultMergeResolve at 0x00B63B70>)
(Constructor)

Initialise an instance.
Parameters:
resolver -
           (type=A callable which takes the argument list (map1, map2, key) where map1 is the mapping being merged into, map2 is the merge operand and key is the clashing key. The callable should return a string indicating how the conflict should be resolved. For possible return values, see defaultMergeResolve. The default value preserves the old behaviour)
Overrides:
__builtin__.object.__init__

handleMismatch(self, obj1, obj2)

Handle a mismatch between two objects.
Parameters:
obj1 - The object to merge into.
           (type=any)
obj2 - The object to merge.
           (type=any)

merge(self, merged, mergee)

Merge two configurations. The second configuration is unchanged, and the first is changed to reflect the results of the merge.
Parameters:
merged - The configuration to merge into.
           (type=Config.)
mergee - The configuration to merge.
           (type=Config.)

mergeMapping(self, map1, map2)

Merge two mappings recursively. The second mapping is unchanged, and the first is changed to reflect the results of the merge.
Parameters:
map1 - The mapping to merge into.
           (type=Mapping.)
map2 - The mapping to merge.
           (type=Mapping.)

mergeSequence(self, seq1, seq2)

Merge two sequences. The second sequence is unchanged, and the first is changed to have the elements of the second appended to it.
Parameters:
seq1 - The sequence to merge into.
           (type=Sequence.)
seq2 - The sequence to merge.
           (type=Sequence.)