From 032196104a59761bd75b5d594440d1e8ef16965a Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 1 Aug 2020 17:58:32 -0500 Subject: Add ConfigFilePath to refactor out file specific code --- config_file/utils.py | 33 --------------------------------- 1 file changed, 33 deletions(-) (limited to 'config_file/utils.py') diff --git a/config_file/utils.py b/config_file/utils.py index 4d8bb36..c6c3d24 100644 --- a/config_file/utils.py +++ b/config_file/utils.py @@ -20,36 +20,3 @@ def split_on_dot(line: Union[str, Path], only_last_dot=False) -> List[str]: 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]) -> str: - with open(path, "r") as file: - return file.read() - - -def create_config_path(file_path: Path, original: bool = False) -> Path: - if len(file_path.parts) >= 1 and file_path.parts[0] == "~": - return file_path.expanduser() - - if original: - file_parts = split_on_dot(file_path, only_last_dot=True) - file_parts.insert(-1, "original") - file_path = Path(".".join(file_parts)) - - if file_path.is_dir(): - raise ValueError(f"The specified config file ({file_path}) is a directory.") - - if not file_path.exists(): - raise FileNotFoundError( - f"The specified config file ({file_path}) does not exist." - ) - - return file_path - - -class Default: - def __init__(self, value): - self.value = value - - def __repr__(self): - return "Default Value: {} ({})".format(self.value, type(self.value)) -- cgit v1.2.3