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 os
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
from yamlcore import CoreDumper, CoreLoader
|
from yamlcore import CoreDumper, CoreLoader
|
||||||
|
|
||||||
from launcher.config.conf import Conf
|
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():
|
def save_conf():
|
||||||
with conf_path.open("w", encoding="utf8") as f:
|
with conf_path.open("w", encoding="utf8") as f:
|
||||||
# json.dump(conf.model_dump(), f, ensure_ascii=False, indent=4) # Use json.dump
|
json.dump(conf.model_dump(), f, ensure_ascii=False, indent=4) # Use json.dump
|
||||||
yaml.dump(
|
# yaml.dump(
|
||||||
conf.model_dump(),
|
# conf.model_dump(),
|
||||||
f,
|
# f,
|
||||||
Dumper=CoreDumper,
|
# Dumper=CoreDumper,
|
||||||
encoding="utf-8",
|
# encoding="utf-8",
|
||||||
default_flow_style=False,
|
# default_flow_style=False,
|
||||||
allow_unicode=True,
|
# allow_unicode=True,
|
||||||
)
|
# )
|
||||||
|
|
||||||
|
|
||||||
def load_conf():
|
def load_conf():
|
||||||
|
|
Loading…
Add table
Reference in a new issue