From 684a16b2ff914cd681e0089f22f886f23b27508f Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Mon, 11 May 2015 17:56:48 +0200 Subject: [PATCH] improve dict difference --- bin/salomeContextUtils.py.in | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) 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 # -- 2.39.2