diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2018-11-01 14:25:57 +0000 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2018-11-01 14:25:57 +0000 |
commit | 7f79b9ce511f1421851821bf2928352ba569b8f0 (patch) | |
tree | cecc6345b157c118c47819cdfa218a2a775aedb9 | |
parent | 48860aacdd619a1d8692dcb39919a58a3a6d2349 (diff) | |
parent | d868b409c66e788c1f6f0ad551573a5d72bc8a28 (diff) | |
download | buildstream-7f79b9ce511f1421851821bf2928352ba569b8f0.tar.gz |
Merge branch 'danielsilverstone-ct/improve-chainmap-get' into 'master'
_yaml.py: Implement `get()` for `ChainMap`
See merge request BuildStream/buildstream!919
-rw-r--r-- | buildstream/_yaml.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/buildstream/_yaml.py b/buildstream/_yaml.py index ca12acae9..f44572ca5 100644 --- a/buildstream/_yaml.py +++ b/buildstream/_yaml.py @@ -1049,6 +1049,12 @@ class ChainMap(collections.ChainMap): for key in clearable: del self[key] + def get(self, key, default=None): + try: + return self[key] + except KeyError: + return default + def node_chain_copy(source): copy = ChainMap({}, source) |