Changeset 166
- Timestamp:
- 03/22/06 12:57:41 (3 years ago)
- Files:
-
- trunk/pyramid/dictutils.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/pyramid/dictutils.py
r163 r166 3 3 import mergetrees 4 4 5 def merge(a, b,dir=None,partialbuild=False):5 def merge(a, b, dir=None, partialbuild=False): 6 6 7 if isinstance(a,Y.sectionnav) and isinstance(b,Y.sectionnav) and dir is not None: 8 # special case. If b is the same as a, it has been inhereited - sectionnav's 9 # should not inherit in this fashion however 10 # TODO: this fix might cause problems in the future. e.g. if the second level nav were exactly the same as the first level nav? 7 if (isinstance(a, Y.sectionnav) and 8 isinstance(b, Y.sectionnav) and dir is not None): 9 # special case. If b is the same as a, it has been inhereited - 10 # sectionnav's should not inherit in this fashion however 11 # TODO: this fix might cause problems in the future. e.g. if 12 # the second level nav were exactly the same as the first level nav? 11 13 if a == b: 12 14 b = [] … … 14 16 a = b 15 17 else: 16 mergetrees.merge(a, b,dir)18 mergetrees.merge(a, b, dir) 17 19 18 elif isinstance(b, dict) and isinstance(a,dict):20 elif isinstance(b, dict) and isinstance(a, dict): 19 21 for bkey in b.keys(): 20 22 if a.has_key(bkey): 21 a[bkey] = merge(a[bkey],b[bkey],dir,partialbuild=partialbuild) 23 a[bkey] = merge(a[bkey], b[bkey], dir, 24 partialbuild=partialbuild) 22 25 else: 23 26 a[bkey] = b[bkey] … … 33 36 if parent is not None: 34 37 self.parent = parent 35 merge(self, parent)38 merge(self, parent) 36 39 37 40 def popStack(self): … … 66 69 67 70 68 xd = syck.load(x, Loader=Y.Loader, implicit_typing=false)69 yd = syck.load(y, Loader=Y.Loader, implicit_typing=false)71 xd = syck.load(x, Loader=Y.Loader, implicit_typing=False) 72 yd = syck.load(y, Loader=Y.Loader, implicit_typing=False) 70 73 71 z = merge(xd, yd)74 z = merge(xd, yd) 72 75 73 76 print z … … 77 80 d = stackdict() 78 81 d['a'] = 1 79 d['b'] = {'x':1, 'y':2 }82 d['b'] = {'x':1, 'y':2 } 80 83 print d 81 84 … … 85 88 86 89 d = stackdict(d) 87 d['b'] = {'x':2, 'y': {'p':4 } }90 d['b'] = {'x':2, 'y': {'p':4 } } 88 91 d['c'] = 100 89 92 print d
