zhenxun_bot/configs/path_config.py

48 lines
1.4 KiB
Python
Raw Normal View History

2021-05-20 18:37:51 +08:00
from pathlib import Path
2022-02-19 18:20:19 +08:00
import os
2021-05-20 18:37:51 +08:00
# 图片路径
2022-02-19 18:20:19 +08:00
IMAGE_PATH = Path() / "resources" / "image"
# 语音路径
RECORD_PATH = Path() / "resources" / "record"
2021-05-20 18:37:51 +08:00
# 文本路径
2022-02-19 18:20:19 +08:00
TEXT_PATH = Path() / "resources" / "text"
2021-05-20 18:37:51 +08:00
# 日志路径
2022-02-19 18:20:19 +08:00
LOG_PATH = Path() / "log"
2021-05-20 18:37:51 +08:00
# 字体路径
2022-02-19 18:20:19 +08:00
FONT_PATH = Path() / "resources" / "font"
2021-05-20 18:37:51 +08:00
# 数据路径
2022-02-19 18:20:19 +08:00
DATA_PATH = Path() / "data"
# 临时数据路径
TEMP_PATH = Path() / "resources" / "temp"
2022-12-11 23:34:54 +08:00
# 网页模板路径
TEMPLATE_PATH = Path() / "resources" / "template"
2022-02-19 18:20:19 +08:00
def load_path():
old_img_dir = Path() / "resources" / "img"
if not IMAGE_PATH.exists() and old_img_dir.exists():
os.rename(old_img_dir, IMAGE_PATH)
old_voice_dir = Path() / "resources" / "voice"
if not RECORD_PATH.exists() and old_voice_dir.exists():
os.rename(old_voice_dir, RECORD_PATH)
old_ttf_dir = Path() / "resources" / "ttf"
if not FONT_PATH.exists() and old_ttf_dir.exists():
os.rename(old_ttf_dir, FONT_PATH)
old_txt_dir = Path() / "resources" / "txt"
if not TEXT_PATH.exists() and old_txt_dir.exists():
os.rename(old_txt_dir, TEXT_PATH)
2021-05-20 18:37:51 +08:00
IMAGE_PATH.mkdir(parents=True, exist_ok=True)
2022-02-19 18:20:19 +08:00
RECORD_PATH.mkdir(parents=True, exist_ok=True)
2021-10-03 14:24:07 +08:00
TEXT_PATH.mkdir(parents=True, exist_ok=True)
2021-05-20 18:37:51 +08:00
LOG_PATH.mkdir(parents=True, exist_ok=True)
2021-10-03 14:24:07 +08:00
FONT_PATH.mkdir(parents=True, exist_ok=True)
2021-05-20 18:37:51 +08:00
DATA_PATH.mkdir(parents=True, exist_ok=True)
TEMP_PATH.mkdir(parents=True, exist_ok=True)
2022-02-19 18:20:19 +08:00
load_path()
2021-05-20 18:37:51 +08:00
2021-10-03 14:24:07 +08:00