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:30:11 -0500 |
| commit | a4d252e5dbcf8d366707ab0c4ddac8a81963a801 (patch) | |
| tree | 4cd1487bb27d96018f4763fa0d35a80e799ab2ed /config_file/utils.py | |
| parent | Change path, parser, and contents to be properties (diff) | |
| download | config-file-a4d252e5dbcf8d366707ab0c4ddac8a81963a801.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() |