refactor(files): 优化项目

- 重构files
- 新增yaml_processor(优化读取文件逻辑)
- 修复bug
This commit is contained in:
2025-03-05 18:11:28 +08:00
parent 698a95ac83
commit b8903798b8
11 changed files with 370 additions and 45 deletions

View File

@@ -21,6 +21,12 @@ from commons.models import CaseInfo
class CaseParser:
@staticmethod
def to_yaml(case_data: dict) -> str:
try:
CaseInfo(**case_data)
except TypeError as error:
logging.error(error)
raise error
return yaml.safe_dump(case_data, allow_unicode=True, sort_keys=False)
@staticmethod
@@ -38,5 +44,5 @@ if __name__ == '__main__':
case_parser = CaseParser()
case_data_ = case_parser.to_yaml(data)
# print(case_data_)
case_parser.from_yaml(case_data_)
# case_parser.from_yaml(case_data_)
# print(type(case_data_))