mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2026-02-06 06:25:06 +00:00
yaml dump支持ordered dict,支持config_info
This commit is contained in:
@@ -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编码器"""
|
||||
|
||||
Reference in New Issue
Block a user