Commit 4dbec911 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 7a436584
...@@ -81,6 +81,15 @@ def kvDecode(kvText, vdecode): # -> kvDict ...@@ -81,6 +81,15 @@ def kvDecode(kvText, vdecode): # -> kvDict
# diff computes difference in between mappings d1 and d2. # diff computes difference in between mappings d1 and d2.
DEL = 'ø' DEL = 'ø'
def diff(d1, d2): # -> [] of (k,v) to change; DEL means del[k] def diff(d1, d2): # -> [] of (k,v) to change; DEL means del[k]
delta = []
keys = set(d1.keys())
keys.union(d2.keys())
for k in sorted(keys):
v1 = d1.get(k, DEL)
v2 = d2.get(k, DEL)
if v1 is not v2:
delta.append((k,v2))
return delta
# patch changes mapping d according to diff. # patch changes mapping d according to diff.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment