diff options
author | stark, steven <steven.stark@att.com> | 2018-12-17 12:43:02 -0800 |
---|---|---|
committer | stark, steven <steven.stark@att.com> | 2018-12-17 13:04:00 -0800 |
commit | 1f4df7c7ad27b23773ad9cdbe4db1632ce388cf1 (patch) | |
tree | 8092104f8be23051ff81c9f71ee34116df4d33ba /ice_validator/tests/utils/nested_dict.py | |
parent | ca9085f0f77d442d3741a8c754e65cc45b6a318d (diff) |
[VVP] updating validation scripts in dublin
- adding backlog of new validation scripts for dublin
- updating existing tests
- removing outdated tests
Issue-ID: VVP-123
Change-Id: Ib8260889ac957c1dd28d8ede450fc8edc6fb0ec0
Signed-off-by: stark, steven <steven.stark@att.com>
Diffstat (limited to 'ice_validator/tests/utils/nested_dict.py')
-rw-r--r-- | ice_validator/tests/utils/nested_dict.py | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/ice_validator/tests/utils/nested_dict.py b/ice_validator/tests/utils/nested_dict.py index 24f7e5e..692ef5f 100644 --- a/ice_validator/tests/utils/nested_dict.py +++ b/ice_validator/tests/utils/nested_dict.py @@ -38,28 +38,30 @@ # ECOMP is a trademark and service mark of AT&T Intellectual Property. # -'''nested_dict.get -''' +"""nested_dict.get +""" -VERSION = '1.0.0' +VERSION = "1.1.1" -def get(dic, *keys): - '''Return the value of the last key given a (nested) dict - and list of keys. If any key is missing, or if the value - of any key except the last is not a dict, then None is returned. - ''' +def get(dic, *keys, **kwargs): + """Return the value of the last key given a (nested) dict and + list of keys. If any key is missing, or if the value of any key + except the last is not a dict, then the default value is returned. + The default value may be passed in using the keyword 'default=', + otherwise the default value is None. + """ d = dic + default = kwargs.get("default", None) for key in keys: - if hasattr(d, 'get'): - d = d.get(key) + if hasattr(d, "get"): + d = d.get(key, default) else: - return None + return default return d def is_dict_has_key(obj, key): - '''return True/False `obj` is a dict and has `key` - ''' + """return True/False `obj` is a dict and has `key` + """ return isinstance(obj, dict) and key in obj - |