JOJ3-config-generator/tests/convert_joj1/utils.py
张泊明518370910136 51b68b7c87
Some checks failed
build / build (push) Failing after 1m38s
refactor: re-organize tests & models
2024-10-22 06:17:09 -04:00

21 lines
673 B
Python

import os
from typing import Any, Dict, Tuple
import rtoml
import yaml
from joj3_config_generator.models import joj1
def read_convert_joj1_files(case_name: str) -> Tuple[joj1.Config, Dict[str, Any]]:
root = os.path.dirname(os.path.realpath(__file__))
task_yaml_path = os.path.join(root, case_name, "task.yaml")
task_toml_path = os.path.join(root, case_name, "task.toml")
with open(task_yaml_path) as repo_file:
task_yaml = repo_file.read()
with open(task_toml_path) as task_file:
task_toml = task_file.read()
joj1_obj = yaml.safe_load(task_yaml)
task_obj = rtoml.loads(task_toml)
return joj1.Config(**joj1_obj), task_obj