conf使用json存储

This commit is contained in:
EightyDollars 2024-12-04 19:05:49 +08:00
parent a2726b465d
commit 23f551fe18

View file

@ -1,25 +1,26 @@
import json
import os
import yaml
from yamlcore import CoreDumper, CoreLoader
from launcher.config.conf import Conf
from python.Lib.pathlib import Path
from pathlib import Path
conf_path = Path(os.path.join(os.getcwd(), "conf.yml"))
conf_path = Path(os.path.join(os.getcwd(), "conf.json"))
def save_conf():
with conf_path.open("w", encoding="utf8") as f:
# json.dump(conf.model_dump(), f, ensure_ascii=False, indent=4) # Use json.dump
yaml.dump(
conf.model_dump(),
f,
Dumper=CoreDumper,
encoding="utf-8",
default_flow_style=False,
allow_unicode=True,
)
json.dump(conf.model_dump(), f, ensure_ascii=False, indent=4) # Use json.dump
# yaml.dump(
# conf.model_dump(),
# f,
# Dumper=CoreDumper,
# encoding="utf-8",
# default_flow_style=False,
# allow_unicode=True,
# )
def load_conf():