更换yaml库
This commit is contained in:
parent
145488e067
commit
0e784e4e6e
10
config.py
10
config.py
@ -1,7 +1,7 @@
|
||||
import os
|
||||
import json
|
||||
import yaml
|
||||
from loghelper import log
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
# 这个字段现在还没找好塞什么地方好,就先塞config这里了
|
||||
serverless = False
|
||||
@ -87,16 +87,14 @@ def update_config():
|
||||
|
||||
|
||||
def load_config():
|
||||
yaml = YAML()
|
||||
global config
|
||||
with open(config_Path, "r", encoding='utf-8') as f:
|
||||
config = yaml.load(f)
|
||||
config = yaml.load(f, Loader=yaml.FullLoader)
|
||||
log.info("Config加载完毕")
|
||||
|
||||
|
||||
def save_config():
|
||||
global serverless
|
||||
yaml = YAML()
|
||||
if serverless:
|
||||
log.info("云函数执行,无法保存")
|
||||
return None
|
||||
@ -104,7 +102,7 @@ def save_config():
|
||||
try:
|
||||
f.seek(0)
|
||||
f.truncate()
|
||||
yaml.dump(config, f)
|
||||
f.write(yaml.dump(config, Dumper=yaml.Dumper,sort_keys=False))
|
||||
f.flush()
|
||||
except OSError:
|
||||
serverless = True
|
||||
@ -130,7 +128,7 @@ def clear_cookies():
|
||||
try:
|
||||
f.seek(0)
|
||||
f.truncate()
|
||||
yaml.dump(config, f)
|
||||
f.write(yaml.dump(config, Dumper=yaml.Dumper,sort_keys=False))
|
||||
f.flush()
|
||||
except OSError:
|
||||
serverless = True
|
||||
|
@ -1,4 +1,4 @@
|
||||
httpx>=0.21.1
|
||||
requests>=2.26.0
|
||||
crontab~=0.23.0
|
||||
ruamel.yaml~=0.17.21
|
||||
PyYAML~=6.0
|
||||
|
Loading…
Reference in New Issue
Block a user