diff options
| author | Eugene Triguba <eugenetriguba@gmail.com> | 2020-06-20 15:30:11 -0500 |
|---|---|---|
| committer | Eugene Triguba <eugenetriguba@gmail.com> | 2020-06-20 15:56:19 -0500 |
| commit | 58808235ea6880c3a0ecfa976a700c81431dc902 (patch) | |
| tree | e1ae59ec93f2bc00c5c9e8e7e3b812c033b001ae /config_file/config_file.py | |
| parent | Change path, parser, and contents to be properties (diff) | |
| download | config-file-58808235ea6880c3a0ecfa976a700c81431dc902.zip | |
Revert Python 3.5 support
Diffstat (limited to 'config_file/config_file.py')
| -rw-r--r-- | config_file/config_file.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/config_file/config_file.py b/config_file/config_file.py index d4131de..3af1083 100644 --- a/config_file/config_file.py +++ b/config_file/config_file.py @@ -55,9 +55,7 @@ class ConfigFile: file_path = ".".join(file_parts) if Path(file_path).is_dir(): - raise ValueError( - "The specified config file ({}) is a directory.".format(file_path) - ) + raise ValueError(f"The specified config file ({file_path}) is a directory.") return file_path @@ -74,7 +72,7 @@ class ConfigFile: return JsonParser(self.__contents) else: raise ValueError( - "File path contains an unrecognized file type: {}".format(file_path) + f"File path contains an unrecognized file type: {file_path}" ) def get(self, key: str, parse_types: bool = False, return_type=None, default=None): @@ -91,6 +89,8 @@ class ConfigFile: :param default: The default value to return if the value of the key is empty. :return: The value of the key. + + :raises ValueError: If the value is not able to be coerced into return_type """ if default is None: key_value = self.__parser.get(key, parse_types=parse_types) @@ -144,7 +144,7 @@ class ConfigFile: if not Path(original_file_path).exists(): raise FileNotFoundError( - "The {} file to restore to does not exist.".format(original_file_path) + f"The {original_file_path} file to restore to does not exist." ) self.__path.expanduser().unlink() |