- 创建了基本的项目结构 - 添加了 .gitignore 文件 - 配置了基本的开发环境 - 添加清华镜像源 - 设置了基础的文件夹和文件(如 commons, utils, POM, pytest.ini) 项目说明: - [项目名称]:Web自动化测试 - [项目描述]:基于pytest,selenium的自动化测试工具 - [开发环境]:Python
43 lines
982 B
Python
43 lines
982 B
Python
#!/usr/bin/env python
|
|
# coding=utf-8
|
|
|
|
"""
|
|
@author: CNWei
|
|
@Software: PyCharm
|
|
@contact: t6i888@163.com
|
|
@file: file_handle
|
|
@date: 2025/3/7 09:31
|
|
@desc:
|
|
"""
|
|
|
|
from utils.file_processors.toml_processor import TomlProcessor
|
|
from utils.file_processors.yaml_processor import YamlProcessor
|
|
from utils.file_processors.json_processor import JsonProcessor
|
|
from commons.settings import configs
|
|
processors = {
|
|
'toml': TomlProcessor,# 暂不支持
|
|
'yaml': YamlProcessor,
|
|
'yml': YamlProcessor,
|
|
'json': JsonProcessor,
|
|
|
|
}
|
|
|
|
|
|
def get_processor(ext):
|
|
agent_model = processors.get(ext, YamlProcessor) # 代理模式
|
|
|
|
return agent_model # 默认回退到 Yaml
|
|
|
|
|
|
FileHandle = get_processor("yaml")
|
|
|
|
if __name__ == '__main__':
|
|
# 示例用法
|
|
yaml_file = FileHandle(configs.variable)
|
|
print(yaml_file)
|
|
print(type(yaml_file))
|
|
file_string = FileHandle.to_string(yaml_file)
|
|
print(file_string)
|
|
file_dict = FileHandle.to_dict(file_string)
|
|
print(file_dict)
|