data_process_ui/app/config.py

35 lines
938 B
Python
Raw Permalink Normal View History

2026-01-12 09:21:42 +08:00
import os
import sys
import yaml
# if os.path.exists("_internal"):
# base_path = "./_internal"
# else:
# base_path = "./"
base_path = "./"
config_path = os.path.join(base_path, "config")
default_file = os.path.join(config_path, "default.yml")
config_file = os.path.join(config_path, "config.yml")
if not os.path.exists(config_path):
os.mkdir(config_path)
if os.path.exists(default_file):
with open(default_file, "r", encoding = "utf-8") as fobj:
config = yaml.safe_load(fobj)
if config is None:
config = {}
else:
config = {}
if os.path.exists(config_file):
with open(config_file, "r", encoding = "utf-8") as fobj:
config_new = yaml.safe_load(fobj)
if not (config_new is None):
for key, value in config_new.items():
config[key] = value
image_path = os.path.join(base_path, "image")
script_path = os.path.join(base_path, "script")
data_path = os.path.join(base_path, "data")
doc_path = os.path.join(base_path, "doc")