aboutsummaryrefslogtreecommitdiffstats
path: root/config_file/utils.py
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2020-08-01 17:58:32 -0500
committerEugene Triguba <eugenetriguba@gmail.com>2020-08-01 17:58:32 -0500
commit032196104a59761bd75b5d594440d1e8ef16965a (patch)
treeefd67c11ac11ba7a64dc09e53b1f329916384d06 /config_file/utils.py
parentRaise FileNotFoundError if the config file does not exist (diff)
downloadconfig-file-032196104a59761bd75b5d594440d1e8ef16965a.zip
Add ConfigFilePath to refactor out file specific code
Diffstat (limited to 'config_file/utils.py')
-rw-r--r--config_file/utils.py33
1 files changed, 0 insertions, 33 deletions
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))