diff options
| author | Eugene Triguba <eugenetriguba@gmail.com> | 2020-08-07 20:15:05 -0500 |
|---|---|---|
| committer | Eugene Triguba <eugenetriguba@gmail.com> | 2020-08-07 20:15:05 -0500 |
| commit | a0cdb32e3f8ae69bd1163e2d44e3d731d9e8594e (patch) | |
| tree | e1f263a316839c0d32a413c120a3c92426f36817 /config_file | |
| parent | Add all_strings template files (diff) | |
| download | config-file-a0cdb32e3f8ae69bd1163e2d44e3d731d9e8594e.zip | |
Fix ConfigFile default
Diffstat (limited to 'config_file')
| -rw-r--r-- | config_file/config_file.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/config_file/config_file.py b/config_file/config_file.py index 8cde5cb..2a8d9ae 100644 --- a/config_file/config_file.py +++ b/config_file/config_file.py @@ -3,7 +3,6 @@ from shutil import copyfile from typing import Any, Union from config_file.config_file_path import ConfigFilePath -from config_file.exceptions import ParsingError from config_file.parse_value import parse_value from config_file.utils import Default @@ -74,11 +73,11 @@ class ConfigFile: """ try: key_value = self.__parser.get(key) - except ParsingError as error: - if default is not type(Default): - key_value = default + except KeyError as error: + if isinstance(default, Default) and default.value is None: + raise KeyError(error) else: - raise ParsingError(error) + key_value = default if parse_types: key_value = parse_value(key_value) |