style: more robust code
This commit is contained in:
parent
dfe836109c
commit
55da1e8482
|
@ -1,5 +1,6 @@
|
|||
import re
|
||||
import shlex
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, Dict, List, Tuple
|
||||
|
||||
from joj3_config_generator.models import result, task
|
||||
|
@ -34,7 +35,10 @@ def get_conf_stage(
|
|||
fn(parser_model, conf_stage.parsers[idx])
|
||||
elif parser == "diff":
|
||||
fix_diff(
|
||||
task_stage, task_conf, conf_stage.parsers[idx], conf_stage.executor
|
||||
task_stage,
|
||||
conf_stage.parsers[idx],
|
||||
conf_stage.executor,
|
||||
JOJ3_CONFIG_ROOT / task_conf.path.parent,
|
||||
)
|
||||
else:
|
||||
continue
|
||||
|
@ -154,9 +158,9 @@ def fix_file(file_parser_config: task.ParserFile, file_parser: result.Parser) ->
|
|||
|
||||
def fix_diff(
|
||||
task_stage: task.Stage,
|
||||
task_conf: task.Config,
|
||||
diff_parser_config: result.Parser,
|
||||
diff_executor: result.Executor,
|
||||
base_dir: Path,
|
||||
) -> None:
|
||||
skip = task_stage.skip
|
||||
cases = task_stage.cases
|
||||
|
@ -180,7 +184,7 @@ def fix_diff(
|
|||
stage_cases.append(
|
||||
result.OptionalCmd(
|
||||
stdin=result.LocalFile(
|
||||
src=str(JOJ3_CONFIG_ROOT / task_conf.path.parent / stdin),
|
||||
src=str(base_dir / stdin),
|
||||
),
|
||||
args=shlex.split(command) if command else None,
|
||||
cpu_limit=cpu_limit,
|
||||
|
@ -203,9 +207,7 @@ def fix_diff(
|
|||
result.DiffOutputConfig(
|
||||
score=diff_output.score,
|
||||
file_name="stdout",
|
||||
answer_path=str(
|
||||
JOJ3_CONFIG_ROOT / task_conf.path.parent / stdout
|
||||
),
|
||||
answer_path=str(base_dir / stdout),
|
||||
force_quit_on_diff=diff_output.force_quit,
|
||||
always_hide=diff_output.hide,
|
||||
compare_space=not diff_output.ignore_spaces,
|
||||
|
|
Loading…
Reference in New Issue
Block a user