forked from ipython/traitlets
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Closes ipython#688 * Allows fine configuration of logging via a `logging.config.dictConfig`. * Changes the default log level from WARN to DEBUG and the default log handler level from undefined to WARN.
- Loading branch information
1 parent
47c5837
commit b5b5085
Showing
5 changed files
with
218 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright (c) IPython Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
|
||
|
||
def nested_update(this, that): | ||
"""Merge two nested dictionaries. | ||
Effectively a recursive ``dict.update``. | ||
Examples | ||
-------- | ||
Merge two flat dictionaries: | ||
>>> nested_update( | ||
... {'a': 1, 'b': 2}, | ||
... {'b': 3, 'c': 4} | ||
... ) | ||
{'a': 1, 'b': 3, 'c': 4} | ||
Merge two nested dictionaries: | ||
>>> nested_update( | ||
... {'x': {'a': 1, 'b': 2}, 'y': 5, 'z': 6}, | ||
... {'x': {'b': 3, 'c': 4}, 'z': 7, '0': 8}, | ||
... ) | ||
{'x': {'a': 1, 'b': 3, 'c': 4}, 'y': 5, 'z': 7, '0': 8} | ||
""" | ||
for key, value in this.items(): | ||
if isinstance(value, dict): | ||
if key in that and isinstance(that[key], dict): | ||
nested_update(this[key], that[key]) | ||
elif key in that: | ||
this[key] = that[key] | ||
|
||
for key, value in that.items(): | ||
if key not in this: | ||
this[key] = value | ||
|
||
return this |