refactor(parser/file): remove
This commit is contained in:
parent
3b24f4fd79
commit
e25cfa78f5
|
@ -6,7 +6,6 @@ import (
|
|||
_ "github.com/joint-online-judge/JOJ3/internal/parser/cpplint"
|
||||
_ "github.com/joint-online-judge/JOJ3/internal/parser/diff"
|
||||
_ "github.com/joint-online-judge/JOJ3/internal/parser/dummy"
|
||||
_ "github.com/joint-online-judge/JOJ3/internal/parser/file"
|
||||
_ "github.com/joint-online-judge/JOJ3/internal/parser/healthcheck"
|
||||
_ "github.com/joint-online-judge/JOJ3/internal/parser/keyword"
|
||||
_ "github.com/joint-online-judge/JOJ3/internal/parser/resultdetail"
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package file
|
||||
|
||||
import "github.com/joint-online-judge/JOJ3/internal/stage"
|
||||
|
||||
var name = "file"
|
||||
|
||||
func init() {
|
||||
stage.RegisterParser(name, &File{})
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package file
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/joint-online-judge/JOJ3/internal/stage"
|
||||
)
|
||||
|
||||
type Conf struct {
|
||||
Name string
|
||||
ForceQuitOnNonEmpty bool
|
||||
}
|
||||
|
||||
type File struct{}
|
||||
|
||||
func (*File) Run(results []stage.ExecutorResult, confAny any) (
|
||||
[]stage.ParserResult, bool, error,
|
||||
) {
|
||||
conf, err := stage.DecodeConf[Conf](confAny)
|
||||
if err != nil {
|
||||
return nil, true, err
|
||||
}
|
||||
var res []stage.ParserResult
|
||||
forceQuit := false
|
||||
for _, result := range results {
|
||||
content := result.Files[conf.Name]
|
||||
if conf.ForceQuitOnNonEmpty && content != "" {
|
||||
forceQuit = true
|
||||
}
|
||||
if !strings.HasSuffix(content, "\n") {
|
||||
content += "\n"
|
||||
}
|
||||
res = append(res, stage.ParserResult{Score: 0, Comment: content})
|
||||
}
|
||||
return res, forceQuit, nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user