]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
improve dict difference
authorCédric Aguerre <cedric.aguerre@edf.fr>
Mon, 11 May 2015 15:56:48 +0000 (17:56 +0200)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Fri, 5 Jun 2015 12:35:41 +0000 (14:35 +0200)
bin/salomeContextUtils.py.in

index a716b79f6460e6dfc448551e68b9a013698f6f16..464d21d250a9ea9133fe0c6aaa7099b57e289ef8 100644 (file)
@@ -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
 #