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