Alex | 0989ecf | 2022-03-29 13:43:21 -0500 | [diff] [blame] | 1 | # Author: Alex Savatieiev (osavatieiev@mirantis.com; a.savex@gmail.com) |
| 2 | # Copyright 2019-2022 Mirantis, Inc. |
Alex | 3bc95f6 | 2020-03-05 17:00:04 -0600 | [diff] [blame] | 3 | from cfg_checker.common.log import logger, logger_cli |
Alex Savatieiev | 5118de0 | 2019-02-20 15:50:42 -0600 | [diff] [blame] | 4 | |
Alex | 3bc95f6 | 2020-03-05 17:00:04 -0600 | [diff] [blame] | 5 | from cfg_checker.common.other import Utils |
Alex Savatieiev | 5118de0 | 2019-02-20 15:50:42 -0600 | [diff] [blame] | 6 | |
| 7 | |
Alex | 74dc135 | 2019-05-17 13:18:24 -0500 | [diff] [blame] | 8 | def nested_set(_d, _keys, _value): |
| 9 | # # import and deepcopy for safety |
| 10 | # from copy import deepcopy |
| 11 | # _d = deepcopy(_dict) |
| 12 | # process |
| 13 | for k in _keys[:-1]: |
| 14 | _d = _d.setdefault(k, {}) |
| 15 | _d[_keys[-1]] = _value |
| 16 | |
| 17 | |
Alex Savatieiev | 5118de0 | 2019-02-20 15:50:42 -0600 | [diff] [blame] | 18 | utils = Utils() |
Alex Savatieiev | 5118de0 | 2019-02-20 15:50:42 -0600 | [diff] [blame] | 19 | logger = logger |
| 20 | logger_cli = logger_cli |