From: Cédric Aguerre Date: Mon, 11 May 2015 15:56:48 +0000 (+0200) Subject: improve dict difference X-Git-Tag: V7_7_0a1~35^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=245d59c5fcaae4ac3ea9f55f2a8610c6f0177a84;p=modules%2Fkernel.git improve dict difference --- diff --git a/bin/salomeContextUtils.py.in b/bin/salomeContextUtils.py.in index a716b79f6..464d21d25 100644 --- a/bin/salomeContextUtils.py.in +++ b/bin/salomeContextUtils.py.in @@ -144,8 +144,24 @@ def __get_environment_from_batch_command(env_cmd, initial=None): # def __subtract(ref, dic): result = {} - for item in set(ref).difference(set(dic)): - result[item] = ref[item] + for key,val in ref.items(): + if not dic.has_key(key): + result[key] = val + else: + # compare values types + if (type(dic[key]) != type(val)): + result[key] = val + else: + # compare values + if isinstance(val, basestring): + tolist1 = dic[key].split(os.pathsep) + tolist2 = val.split(os.pathsep) + diff = list(set(tolist2)-set(tolist1)) + if diff: + result[key] = os.pathsep.join(diff) + else: + result[key] = val + return result #