JOJ3-config-generator/joj3_config_generator/load.py
李衍志523370910113 9213e57ca3
All checks were successful
build / build (push) Successful in 2m32s
dev (#10)
## What I have done:

- basic generation of json files
  - supported parsers:
    - healthcheck
    - result-detail
    - result-status
    - file
    - log
    - dummy
    - keyword (keyword, clangtidy, cppcheck, cpplint)
    - diff
- `convert` functions is mature, tested in engr151-24fa last two homeworks and engr151-24fa p3
- teapot and healthcheck should be up to date

## TODO

- update all new comming parsers in future.

@bomingzh Could you please help me do a code review first then I shall fix all things and rebase? I checked the source code of JOJ3 currently, and find we have more parsers, such as plugin and tierscore, I haven''t added them yet, and some of the keys might have changed such as clang-tidy, can you help me take a look if current version is still up to date? I ll redo the fix tomorrow

Co-authored-by: Boming Zhang <bomingzh@sjtu.edu.cn>
Reviewed-on: #10
Reviewed-by: 张泊明518370910136 <bomingzh@sjtu.edu.cn>
Co-authored-by: jon-lee <jon-lee@sjtu.edu.cn>
Co-committed-by: jon-lee <jon-lee@sjtu.edu.cn>
2025-03-05 16:20:38 +08:00

40 lines
1.1 KiB
Python

from pathlib import Path
from typing import Dict, Tuple
import inquirer
import rtoml
import yaml
from joj3_config_generator.models import joj1, repo, task
def load_joj3_toml_answers() -> Dict[str, str]:
questions = [
inquirer.List(
"size",
message="What size do you need?",
choices=["Jumbo", "Large", "Standard", "Medium", "Small", "Micro"],
),
]
answers = inquirer.prompt(questions)
return answers
def load_joj1_yaml(yaml_path: Path) -> joj1.Config:
joj1_obj = yaml.safe_load(yaml_path.read_text())
return joj1.Config(**joj1_obj)
def load_joj3_toml(
root_path: Path, repo_toml_path: Path, task_toml_path: Path
) -> Tuple[repo.Config, task.Config]:
repo_obj = rtoml.loads(repo_toml_path.read_text())
task_obj = rtoml.loads(task_toml_path.read_text())
repo_conf = repo.Config(**repo_obj)
repo_conf.root = root_path
repo_conf.path = repo_toml_path.relative_to(root_path)
task_conf = task.Config(**task_obj)
task_conf.root = root_path
task_conf.path = task_toml_path.relative_to(root_path)
return repo_conf, task_conf