The plist templates can have different values for the same key.
If the value is a list (plist array), merge should be the concatenation.
Don't compute union as as list can contain dicts.

BUG=692552

Review-Url: https://codereview.chromium.org/2715543002
Cr-Original-Commit-Position: refs/heads/master@{#452083}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 0cf3dac55d77555df465f3809e8f8636efef303d
This commit is contained in:
olivierrobin 2017-02-22 08:43:01 -08:00 коммит произвёл Commit bot
Родитель dda9979a24
Коммит 04f3802a94
1 изменённых файлов: 5 добавлений и 2 удалений

Просмотреть файл

@ -141,7 +141,7 @@ def MergePList(plist1, plist2):
Creates a new dictionary representing a Property List (.plist) files by
merging the two dictionary |plist1| and |plist2| recursively (only for
dictionary values).
dictionary values). List value will be concatenated.
Args:
plist1: a dictionary representing a Property List (.plist) file
@ -150,7 +150,8 @@ def MergePList(plist1, plist2):
Returns:
A new dictionary representing a Property List (.plist) file by merging
|plist1| with |plist2|. If any value is a dictionary, they are merged
recursively, otherwise |plist2| value is used.
recursively, otherwise |plist2| value is used. If values are list, they
are concatenated.
"""
if not isinstance(plist1, dict) or not isinstance(plist2, dict):
if plist2 is not None:
@ -165,6 +166,8 @@ def MergePList(plist1, plist2):
value = plist1[key]
if isinstance(value, dict):
value = MergePList(plist1.get(key, None), plist2.get(key, None))
if isinstance(value, list):
value = plist1.get(key, []) + plist2.get(key, [])
result[key] = value
return result