diff options
author | crupest <crupest@outlook.com> | 2024-11-11 01:12:29 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-01-20 22:34:18 +0800 |
commit | 5c76a1257b4a058bf919af3e31cc9461a39c2f33 (patch) | |
tree | cb32f0c22e5438a0ed9de4b29f58d0b7f142a58d /tools/cru-py/crupest/path.py | |
parent | 12e1272508ba0b5909069319007d677c1c76e355 (diff) | |
download | crupest-5c76a1257b4a058bf919af3e31cc9461a39c2f33.tar.gz crupest-5c76a1257b4a058bf919af3e31cc9461a39c2f33.tar.bz2 crupest-5c76a1257b4a058bf919af3e31cc9461a39c2f33.zip |
HALF WORK: 2024.1.20 - 2
Diffstat (limited to 'tools/cru-py/crupest/path.py')
-rw-r--r-- | tools/cru-py/crupest/path.py | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/tools/cru-py/crupest/path.py b/tools/cru-py/crupest/path.py deleted file mode 100644 index 0cfcfb8..0000000 --- a/tools/cru-py/crupest/path.py +++ /dev/null @@ -1,57 +0,0 @@ -import os -import os.path - -script_dir = os.path.relpath(os.path.dirname(__file__)) -project_dir = os.path.normpath(os.path.join(script_dir, "../../../")) -project_abs_path = os.path.abspath(project_dir) -template_dir = os.path.join(project_dir, "template") -nginx_template_dir = os.path.join(template_dir, "nginx") -data_dir = os.path.join(project_dir, "data") -tool_dir = os.path.join(project_dir, "tools") -tmp_dir = os.path.join(project_dir, "tmp") -backup_dir = os.path.join(project_dir, "backup") -config_file_path = os.path.join(data_dir, "config") -nginx_config_dir = os.path.join(project_dir, "nginx-config") -log_dir = os.path.join(project_dir, "log") - - -def ensure_file(path: str, /, must_exist: bool = True) -> bool: - if must_exist and not os.path.exists(path): - raise Exception(f"File {path} does not exist!") - if not os.path.exists(path): - return False - if not os.path.isfile(path): - raise Exception(f"{path} is not a file!") - return True - - -def ensure_dir(path: str, /, must_exist: bool = True) -> bool: - if must_exist and not os.path.exists(path): - raise Exception(f"Directory {path} does not exist!") - if not os.path.exists(path): - return False - if not os.path.isdir(path): - raise Exception(f"{path} is not a directory!") - return True - - -class Paths: - script_dir = os.path.relpath(os.path.dirname(__file__)) - project_dir = os.path.normpath(os.path.join(script_dir, "../../")) - project_abs_path = os.path.abspath(project_dir) - data_dir = os.path.join(project_dir, "data") - config_file_path = os.path.join(data_dir, "config") - template_dir = os.path.join(project_dir, "template") - tool_dir = os.path.join(project_dir, "tool") - tmp_dir = os.path.join(project_dir, "tmp") - backup_dir = os.path.join(project_dir, "backup") - log_dir = os.path.join(project_dir, "log") - template2_dir = os.path.join(project_dir, "template2") - nginx2_template_dir = os.path.join(template2_dir, "nginx") - generated_dir = os.path.join(project_dir, "generated") - nginx_generated_dir = os.path.join(generated_dir, "nginx") - - -def create_dir_if_not_exists(path: str) -> None: - if not ensure_dir(path, must_exist=False): - os.mkdir(path) |