From 0e784e4e6e7d43a8a0064f0c42fe943cf6692617 Mon Sep 17 00:00:00 2001 From: Womsxd <45663319+Womsxd@users.noreply.github.com> Date: Wed, 24 Aug 2022 01:18:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=8D=A2yaml=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 10 ++++------ requirements.txt | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/config.py b/config.py index cfb6e62..373d354 100644 --- a/config.py +++ b/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 diff --git a/requirements.txt b/requirements.txt index 2913da1..2fcce86 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ httpx>=0.21.1 requests>=2.26.0 crontab~=0.23.0 -ruamel.yaml~=0.17.21 +PyYAML~=6.0