-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: textables refactor + bump go/linter versions
- Loading branch information
Showing
11 changed files
with
114 additions
and
64 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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module github.com/Gornak40/algolymp | ||
|
||
go 1.20 | ||
go 1.22 | ||
|
||
require ( | ||
github.com/PuerkitoBio/goquery v1.8.1 | ||
|
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,56 @@ | ||
package textables | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
// If cntVars != 0 works only in PDF render. | ||
// Otherwise works both in HTML and PDF render. | ||
type MoscowTable struct { | ||
groups []string | ||
cntVars int | ||
} | ||
|
||
var _ Table = &MoscowTable{} | ||
|
||
func NewMoscowTable(cntVars int) *MoscowTable { | ||
return &MoscowTable{ | ||
cntVars: cntVars, | ||
} | ||
} | ||
|
||
func (t *MoscowTable) AddGroup(info GroupInfo) { | ||
var comment, limits string | ||
if info.Type == Group0 { | ||
comment = "Тесты из условия." | ||
} | ||
row := fmt.Sprintf("%s & %d & %s & %s & %s \\\\ \\hline", | ||
info.Name, | ||
info.Score, | ||
limits, | ||
strings.Join(info.Dependencies, ", "), | ||
comment, | ||
) | ||
t.groups = append(t.groups, row) | ||
} | ||
|
||
func (t *MoscowTable) String() string { | ||
table := []string{ | ||
"\\begin{center}", | ||
"\\renewcommand{\\arraystretch}{1.5}", | ||
"\\begin{tabular}{|c|c|c|c|c|}", | ||
"\\hline", | ||
"Группа", | ||
"& Баллы", | ||
"& Доп. ограничения", | ||
"& Необх. группы", | ||
"& Комментарий", | ||
"\\\\", | ||
"\\hline", | ||
} | ||
table = append(table, t.groups...) | ||
table = append(table, "\\end{tabular}", "\\end{center}") | ||
|
||
return strings.Join(table, "\n") | ||
} |
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 |
---|---|---|
@@ -1,28 +1,21 @@ | ||
package textables | ||
|
||
import "github.com/sirupsen/logrus" | ||
type GroupType int | ||
|
||
const ( | ||
Group0 GroupType = iota | ||
GroupRegular | ||
GroupLast | ||
) | ||
|
||
type GroupInfo struct { | ||
Group string | ||
Name string | ||
Score int | ||
Dependencies []string | ||
Type GroupType | ||
} | ||
|
||
type Table interface { | ||
AddGroup0(info GroupInfo) | ||
AddGroup(info GroupInfo) | ||
AddLastGroup(info GroupInfo) | ||
|
||
String() string | ||
} | ||
|
||
func GetTexTable(tableTyp string, cntVars int) Table { //nolint:ireturn | ||
logrus.WithFields(logrus.Fields{"type": tableTyp, "vars": cntVars}).Info("select textable") | ||
|
||
switch tableTyp { | ||
case UniversalTag: | ||
return &UniversalTable{} | ||
default: | ||
return nil | ||
} | ||
} |
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