Sfoglia il codice sorgente

dict_merge(): merge lists, too

Helge Jung 10 anni fa
parent
commit
0686f0caf2
1 ha cambiato i file con 2 aggiunte e 0 eliminazioni
  1. 2 0
      ffstatus/__init__.py

+ 2 - 0
ffstatus/__init__.py

@@ -26,6 +26,8 @@ def dict_merge(a, b):
     for k, v in b.iteritems():
         if k in result and isinstance(result[k], dict):
                 result[k] = dict_merge(result[k], v)
+        elif k in result and isinstance(result[k], list):
+                result[k] = result[k] + [ deepcopy(x) for x in v if x not in result[k] ]
         else:
             result[k] = deepcopy(v)
     return result