1
0

j2cfg: allow empty list/map overrides

This commit is contained in:
Konstantin Demin 2024-11-08 14:19:37 +03:00
parent 4237fb1742
commit e190393397
Signed by: krd
GPG Key ID: 4D56F87A8BA65FD0

View File

@ -278,11 +278,19 @@ def merge_dict_recurse(d1, d2: dict) -> dict:
map_common = {k for k in map1 if is_mapping(d2.get(k))} map_common = {k for k in map1 if is_mapping(d2.get(k))}
for k in map_common: for k in map_common:
x[k] = merge_dict_recurse(x.get(k), d2.get(k)) y = d2.get(k)
if not y:
x[k] = {}
continue
x[k] = merge_dict_recurse(x.get(k), y)
seq_common = {k for k in seq1 if is_sequence(d2.get(k))} seq_common = {k for k in seq1 if is_sequence(d2.get(k))}
for k in seq_common: for k in seq_common:
x[k] = uniq(list(x.get(k)) + list(d2.get(k))) y = d2.get(k)
if not y:
x[k] = []
continue
x[k] = uniq(list(x.get(k)) + list(y))
unmerged = (map1 - map_common) | (seq1 - seq_common) unmerged = (map1 - map_common) | (seq1 - seq_common)
for k in unmerged: for k in unmerged: