-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
xzyaoi
committed
Sep 11, 2018
1 parent
59036e4
commit 5da39e7
Showing
6 changed files
with
94 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"io/ioutil" | ||
"path/filepath" | ||
"net/http" | ||
"strings" | ||
"github.com/flosch/pongo2" | ||
) | ||
|
||
func _getRunnerTpl () string { | ||
var runnerTpl = "https://tpl.cvtron.xyz/runners/runner.tpl" | ||
resp, err := http.Get(runnerTpl) | ||
body, err := ioutil.ReadAll(resp.Body) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
return string(body) | ||
} | ||
|
||
func renderRunnerTpl (localFolder string, mysolvers solvers) { | ||
tpl, err := pongo2.FromString(_getRunnerTpl()) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
for _, solver := range mysolvers.Solvers { | ||
writeRunner(tpl, localFolder, solver) | ||
} | ||
} | ||
|
||
func writeRunner (tpl *pongo2.Template, localFolder string, Solver solver) { | ||
filename := "runner_" + Solver.Name + ".py" | ||
fileFullPath := filepath.Join(localFolder, filename) | ||
tplContext := strings.Split(Solver.Class, "/") | ||
out, err := tpl.Execute(pongo2.Context{"Package":tplContext[0],"Filename":tplContext[1], "Classname": tplContext[2]}) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
err = ioutil.WriteFile(fileFullPath, []byte(out), 0644) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.