From 288c09f9573a667c78fda238a3aba23fbf70d2c3 Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Thu, 10 Sep 2020 16:50:00 +0800 Subject: [PATCH] update config.py --- dygraph/utils/config.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dygraph/utils/config.py b/dygraph/utils/config.py index 5a7a6aac..e0577a6e 100644 --- a/dygraph/utils/config.py +++ b/dygraph/utils/config.py @@ -36,20 +36,22 @@ class Config(object): if path.endswith('yml') or path.endswith('yaml'): dic = self._parse_from_yaml(path) + print(dic) self._build(dic) else: raise RuntimeError('Config file should in yaml format!') def _update_dic(self, dic, base_dic): """ - update dic from base_dic + update config from dic based base_dic """ - dic = dic.copy() - for key, val in base_dic.items(): - if isinstance(val, dict) and key in dic: - dic[key] = self._update_dic(dic[key], val) + base_dic = base_dic.copy() + for key, val in dic.items(): + if isinstance(val, dict) and key in base_dic: + base_dic[key] = self._update_dic(val, base_dic[key]) else: - dic[key] = val + base_dic[key] = val + dic = base_dic return dic def _parse_from_yaml(self, path: str): -- GitLab