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/utils.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/utils.py')
| -rw-r--r-- | config_file/utils.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/config_file/utils.py b/config_file/utils.py index 05c3a7a..9ed09b5 100644 --- a/config_file/utils.py +++ b/config_file/utils.py @@ -1,8 +1,8 @@ -from pathlib import Path -from typing import Union +from pathlib import PurePath +from typing import Type, Union -def split_on_dot(line: Union[str, Path], only_last_dot=False): +def split_on_dot(line: Union[str, Type[PurePath]], only_last_dot=False): """ Split a string on the dot character (.). @@ -11,17 +11,15 @@ def split_on_dot(line: Union[str, Path], only_last_dot=False): :raises ValueError: if the line does not have a dot. """ - if isinstance(line, Path): + if isinstance(line, PurePath): line = str(line) if "." not in line: - raise ValueError( - "The given string does not have a dot to split on: {}".format(line) - ) + raise ValueError(f"The given string does not have a dot to split on: {line}") return line.rsplit(".", 1) if only_last_dot else line.split(".") -def read_file(path: Union[str, Path]): +def read_file(path: Union[str, Type[PurePath]]): with open(path, "r") as file: return file.read() |