summaryrefslogtreecommitdiffstats
path: root/pykolab/xml/utils.py
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2015-03-28 23:43:17 +0100
committerThomas Bruederli <bruederli@kolabsys.com>2015-03-28 23:43:17 +0100
commitfff814d60954eacc42403e3799c030660c1ba4da (patch)
treed67d997238c9be4ae8e5ba8bfe4b8db7c013ea54 /pykolab/xml/utils.py
parent821e6de04a968f98363503f83705bf350a41a3bd (diff)
downloadpykolab-fff814d60954eacc42403e3799c030660c1ba4da.tar.gz
Improve proplist ordering routine
Diffstat (limited to 'pykolab/xml/utils.py')
-rw-r--r--pykolab/xml/utils.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/pykolab/xml/utils.py b/pykolab/xml/utils.py
index 9d80f9c..d98575e 100644
--- a/pykolab/xml/utils.py
+++ b/pykolab/xml/utils.py
@@ -318,7 +318,7 @@ def order_proplists(a, b):
# find a matching entry in base
for j, aa in enumerate(base):
- if compare_values(aa, bb):
+ if compare_values(aa, bb, True):
index = j
break
@@ -335,7 +335,7 @@ def order_proplists(a, b):
return (comp, base) if flip else (base, comp)
-def compare_values(aa, bb):
+def compare_values(aa, bb, partial=False):
ignore_keys = ['rsvp']
if not aa.__class__ == bb.__class__:
return False
@@ -348,6 +348,14 @@ def compare_values(aa, bb):
aa.pop(k, None)
bb.pop(k, None)
+ # accept partial match
+ if partial:
+ for k,v in aa.iteritems():
+ if bb.has_key(k) and bb[k] == v:
+ return True
+
+ return False
+
return aa == bb