mirror of
https://github.com/ansible/awx.git
synced 2026-03-17 08:57:33 -02:30
[fix] Now with doctest that actually passes
This commit is contained in:
@@ -14,10 +14,12 @@ logger = logging.getLogger('awx.main.scheduler')
|
|||||||
|
|
||||||
def deepmerge(a, b):
|
def deepmerge(a, b):
|
||||||
"""
|
"""
|
||||||
>>> a = { 'first' : { 'all_rows' : { 'pass' : 'dog', 'number' : '1' } } }
|
Merge dict structures and return the result.
|
||||||
>>> b = { 'first' : { 'all_rows' : { 'fail' : 'cat', 'number' : '5' } } }
|
|
||||||
>>> deepmerge(b, a) == { 'first' : { 'all_rows' : { 'pass' : 'dog', 'fail' : 'cat', 'number' : '5' } } }
|
>>> a = {'first': {'all_rows': {'pass': 'dog', 'number': '1'}}}
|
||||||
True
|
>>> b = {'first': {'all_rows': {'fail': 'cat', 'number': '5'}}}
|
||||||
|
>>> import pprint; pprint.pprint(deepmerge(a, b))
|
||||||
|
{'first': {'all_rows': {'fail': 'cat', 'number': '5', 'pass': 'dog'}}}
|
||||||
"""
|
"""
|
||||||
if isinstance(a, dict) and isinstance(b, dict):
|
if isinstance(a, dict) and isinstance(b, dict):
|
||||||
return dict([(k, deepmerge(a.get(k), b.get(k)))
|
return dict([(k, deepmerge(a.get(k), b.get(k)))
|
||||||
|
|||||||
Reference in New Issue
Block a user