Skip to content

Commit

Permalink
fix: follow changes of UpdateWithReplaceDict._update and make compatible
Browse files Browse the repository at this point in the history
with it in UpdateWoReplaceDict._update and UpdateWithMergeDict._update.
  • Loading branch information
ssato committed Dec 25, 2015
1 parent b9591cc commit 6b2bce9
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions anyconfig/mergeabledict.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,15 @@ class UpdateWoReplaceDict(UpdateWithReplaceDict):
>>> all(md0[k] == ref[k] for k in ref.keys())
True
"""
def _update(self, other, key, val=None):
def _update(self, other, key, *args):
"""
:param other:
dict or dict-like object or a list of (key, value) pair tuples
:param key: object key
:param val: object value
:param args: [] or (value, ...)
"""
if key not in self:
self[key] = other[key] if val is None else val
self[key] = args[0] if args else other[key]


class UpdateWithMergeDict(UpdateWithReplaceDict):
Expand Down Expand Up @@ -303,16 +303,14 @@ class variables:
merge_lists = False
keep = False

def _update(self, other, key, val=None):
def _update(self, other, key, *args):
"""
:param other:
dict or dict-like object or a list of (key, value) pair tuples
:param key: object key
:param val: object value
:param args: [] or (value, ...)
"""
if val is None:
val = other[key]

val = args[0] if args else other[key]
if key in self:
val0 = self[key] # Original value
if is_dict_like(val0): # It needs recursive updates.
Expand Down

0 comments on commit 6b2bce9

Please sign in to comment.