2022-07-16 22:05:15 +02:00
|
|
|
// Copyright 2022 wanderer <a_mirre at utb dot cz>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
package report
|
|
|
|
|
|
|
|
import (
|
2022-07-17 11:36:59 +02:00
|
|
|
_ "embed"
|
2022-07-16 22:05:15 +02:00
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"text/template"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// picTexFiles holds paths to tex files including pics of a certain algo.
|
|
|
|
type picTexFiles struct {
|
|
|
|
Algo string
|
|
|
|
FilePaths []string
|
|
|
|
}
|
|
|
|
|
|
|
|
// allThePics contains a slice of picTexFiles and consequently paths to all pic
|
|
|
|
// tex files generated during a single run of the program.
|
|
|
|
type allThePics struct {
|
|
|
|
TexFiles []picTexFiles
|
|
|
|
}
|
|
|
|
|
2022-07-17 11:36:59 +02:00
|
|
|
var (
|
|
|
|
allPics = &allThePics{}
|
|
|
|
//go:embed allpics.tmpl
|
|
|
|
tmplAllPicsFile []byte
|
|
|
|
)
|
2022-07-16 22:05:15 +02:00
|
|
|
|
|
|
|
// SaveTexAllPics feeds all paths of generated pics to a template that creates
|
|
|
|
// `allpics.tex` file, which then aggregates all tex files tracking plot pics
|
|
|
|
// in one place.
|
|
|
|
func SaveTexAllPics() {
|
|
|
|
a := allPics
|
|
|
|
texAllPicsFile := GetTexDir() + "allpics" + ".tex"
|
|
|
|
|
2022-07-17 11:36:59 +02:00
|
|
|
tmplAllPics := template.New("allpics")
|
|
|
|
tmplAllPics = template.Must(tmplAllPics.Parse(string(tmplAllPicsFile)))
|
2022-07-16 22:05:15 +02:00
|
|
|
|
|
|
|
f, err := os.Create(texAllPicsFile)
|
|
|
|
if err != nil {
|
|
|
|
log.Println(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
defer f.Close()
|
|
|
|
|
|
|
|
err = tmplAllPics.Execute(f, struct {
|
|
|
|
AllPics allThePics
|
|
|
|
Timestamp time.Time
|
|
|
|
}{
|
|
|
|
AllPics: *a,
|
|
|
|
Timestamp: time.Now(),
|
|
|
|
})
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Println(err)
|
|
|
|
}
|
|
|
|
}
|