conf使用json存储
This commit is contained in:
parent
a2726b465d
commit
23f551fe18
1 changed files with 12 additions and 11 deletions
|
@ -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():
|
||||
|
|
Loading…
Reference in a new issue