mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #24262 from basepi/dictupdatefix
More dictupdate after #24142
This commit is contained in:
commit
113eba34ec
1 changed files with 8 additions and 8 deletions
|
@ -10,7 +10,6 @@ import collections
|
|||
import copy
|
||||
import logging
|
||||
import salt.ext.six as six
|
||||
from salt.utils.odict import OrderedDict
|
||||
from salt.utils.serializers.yamlex \
|
||||
import merge_recursive as _yamlex_merge_recursive
|
||||
|
||||
|
@ -26,15 +25,16 @@ def update(dest, upd, recursive_update=True):
|
|||
If recursive_update=False, will use the classic dict.update, or fall back
|
||||
on a manual merge (helpful for non-dict types like FunctionWrapper)
|
||||
'''
|
||||
if dest is None:
|
||||
return upd
|
||||
if (not isinstance(dest, collections.Mapping)) \
|
||||
or (not isinstance(upd, collections.Mapping)):
|
||||
raise TypeError('Cannot update using non-dict types in dictupdate.update()')
|
||||
updkeys = list(upd.keys())
|
||||
if not set(list(dest.keys())) & set(updkeys):
|
||||
recursive_update = False
|
||||
if recursive_update:
|
||||
for key, val in six.iteritems(upd):
|
||||
for key in updkeys:
|
||||
val = upd[key]
|
||||
try:
|
||||
if isinstance(val, OrderedDict):
|
||||
valtype = OrderedDict
|
||||
else:
|
||||
valtype = dict
|
||||
dest_subkey = dest.get(key, None)
|
||||
except AttributeError:
|
||||
dest_subkey = None
|
||||
|
|
Loading…
Add table
Reference in a new issue