yaml dump支持ordered dict,支持config_info

This commit is contained in:
Xuwznln
2025-07-19 01:54:53 +08:00
parent 862f250e49
commit ebe9e1b1f8
9 changed files with 152298 additions and 325 deletions

View File

@@ -1,5 +1,6 @@
import collections.abc
import json
from collections import OrderedDict
from typing import get_origin, get_args
import yaml
@@ -29,6 +30,14 @@ class NoAliasDumper(yaml.SafeDumper):
return True
# 为NoAliasDumper添加OrderedDict的representation方法
def represent_ordereddict(dumper, data):
return dumper.represent_mapping("tag:yaml.org,2002:map", data.items())
# 注册OrderedDict的representer
NoAliasDumper.add_representer(OrderedDict, represent_ordereddict)
class ResultInfoEncoder(json.JSONEncoder):
"""专门用于处理任务执行结果信息的JSON编码器"""