dev #10
|
@ -6,7 +6,7 @@ from typing import Any, Callable, Dict, List, Tuple
|
|||
from joj3_config_generator.models import result, task
|
||||
from joj3_config_generator.models.common import Memory, Time
|
||||
from joj3_config_generator.models.const import JOJ3_CONFIG_ROOT
|
||||
from joj3_config_generator.models.task import Parser as parser_enum
|
||||
from joj3_config_generator.models.task import Parser as ParserEnum
|
||||
jon-lee marked this conversation as resolved
Outdated
|
||||
|
||||
|
||||
def get_conf_stage(
|
||||
|
@ -33,7 +33,7 @@ def get_conf_stage(
|
|||
if parser in processed_dict:
|
||||
fn, parser_model = processed_dict[parser]
|
||||
jon-lee marked this conversation as resolved
Outdated
张泊明518370910136
commented
should loop through should loop through `conf_stage.parsers` here and update the `with` field according to the parser name.
李衍志523370910113
commented
I think its already implemented in each of the I think its already implemented in each of the `fix_parsers` functions
张泊明518370910136
commented
No, do not find the parser in the No, do not find the parser in the `fix_xxx` function. Instead, iterate through the parsers here and decide how to fill in the `with`.
李衍志523370910113
commented
resolved. resolved.
张泊明518370910136
commented
Use a dict to store parser name, field, function to process.
Use a dict to store parser name, field, function to process.
```
process_dict: Dict[
str, Tuple[Callable[[result.ParserConfig, BaseModel], None], BaseModel]
] = {
"clangtidy": (fix_keyword, task_stage.clangtidy),
"keyword": (fix_keyword, task_stage.keyword),
"diff": (fix_diff, task_stage.diff),
}
for i, parser in enumerate(task_stage.parsers):
if parser in process_dict:
func, parser_model = process_dict[parser]
func(conf_stage.parsers[i], parser_model)
```
李衍志523370910113
commented
resolved. resolved.
|
||||
fn(parser_model, conf_stage.parsers[idx])
|
||||
jon-lee marked this conversation as resolved
Outdated
张泊明518370910136
commented
Do we need to support both kinds of names? Do we need to support both kinds of names?
李衍志523370910113
commented
probably yes, since it is easy for new ta to type it wrong probably yes, since it is easy for new ta to type it wrong
张泊明518370910136
commented
parsers name should be a str enum, force them to use the correct names parsers name should be a str enum, force them to use the correct names
李衍志523370910113
commented
ok, then removed. ok, then removed.
|
||||
elif parser == parser_enum.DIFF:
|
||||
elif parser == ParserEnum.DIFF:
|
||||
jon-lee marked this conversation as resolved
Outdated
张泊明518370910136
commented
underscore underscore
李衍志523370910113
commented
fixed fixed
|
||||
fix_diff(
|
||||
task_stage,
|
||||
conf_stage.parsers[idx],
|
||||
|
@ -47,18 +47,18 @@ def get_conf_stage(
|
|||
|
||||
def get_processed_dict(
|
||||
task_stage: task.Stage,
|
||||
) -> Dict[parser_enum, Tuple[Callable[[Any, result.Parser], None], Any]]:
|
||||
) -> Dict[ParserEnum, Tuple[Callable[[Any, result.Parser], None], Any]]:
|
||||
processed_dict: Dict[
|
||||
parser_enum, Tuple[Callable[[Any, result.Parser], None], Any]
|
||||
ParserEnum, Tuple[Callable[[Any, result.Parser], None], Any]
|
||||
] = {
|
||||
parser_enum.CLANG_TIDY: (fix_keyword, task_stage.clangtidy),
|
||||
parser_enum.KEYWORD: (fix_keyword, task_stage.keyword),
|
||||
parser_enum.CPPCHECK: (fix_keyword, task_stage.cppcheck),
|
||||
parser_enum.CPPLINT: (fix_keyword, task_stage.cpplint),
|
||||
parser_enum.RESULT_DETAIL: (fix_result_detail, task_stage.result_detail),
|
||||
parser_enum.DUMMY: (fix_dummy, task_stage.dummy),
|
||||
parser_enum.RESULT_STATUS: (fix_dummy, task_stage.result_status),
|
||||
parser_enum.FILE: (fix_file, task_stage.file),
|
||||
ParserEnum.CLANG_TIDY: (fix_keyword, task_stage.clangtidy),
|
||||
ParserEnum.KEYWORD: (fix_keyword, task_stage.keyword),
|
||||
ParserEnum.CPPCHECK: (fix_keyword, task_stage.cppcheck),
|
||||
ParserEnum.CPPLINT: (fix_keyword, task_stage.cpplint),
|
||||
ParserEnum.RESULT_DETAIL: (fix_result_detail, task_stage.result_detail),
|
||||
ParserEnum.DUMMY: (fix_dummy, task_stage.dummy),
|
||||
ParserEnum.RESULT_STATUS: (fix_dummy, task_stage.result_status),
|
||||
ParserEnum.FILE: (fix_file, task_stage.file),
|
||||
}
|
||||
return processed_dict
|
||||
jon-lee marked this conversation as resolved
Outdated
张泊明518370910136
commented
not necessary not necessary
李衍志523370910113
commented
resolved. resolved.
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user
ParserEnum