From f24549096b376243b917e476cf5b8a3053a13cc1 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Thu, 5 Apr 2018 19:45:47 +0300 Subject: [PATCH] config: convert config back to configobj after validation Signed-off-by: Ruslan Kuprieiev --- dvc/config.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dvc/config.py b/dvc/config.py index c3401d9d6..d82b4041a 100644 --- a/dvc/config.py +++ b/dvc/config.py @@ -93,11 +93,16 @@ class Config(object): self.config_file = os.path.join(dvc_dir, self.CONFIG) try: - self._config = configobj.ConfigObj(self.config_file, write_empty_values=True) + self._config = configobj.ConfigObj(self.config_file) + # NOTE: schema doesn't support ConfigObj.Section validation, so we # need to convert our config to dict before passing it to schema. self._config = self._lower(self._config) self._config = schema.Schema(self.SCHEMA).validate(self._config) + + # NOTE: now converting back to ConfigObj + self._config = configobj.ConfigObj(self._config, write_empty_values=True) + self._config.filename = self.config_file except Exception as ex: raise ConfigError(ex)