Fixed imports in types package
This commit is contained in:
parent
b78b964a55
commit
345d060afa
@ -5,393 +5,21 @@ from .. import competition_class
|
||||
|
||||
|
||||
from .csvResultRow import CSVResultRow
|
||||
|
||||
|
||||
class HtmlPreviewParticipant:
|
||||
def __init__(self, name, id, group_):
|
||||
self.name = name
|
||||
self.id = id
|
||||
groupParser = group.GroupParser()
|
||||
self.group = groupParser.parseGroup(group_)
|
||||
self.finalist = None
|
||||
|
||||
def __eq__(self, o):
|
||||
if type(o) != HtmlPreviewParticipant:
|
||||
return False
|
||||
|
||||
return all(
|
||||
map(
|
||||
lambda x, y: x == y,
|
||||
(self.name, self.id, self.group),
|
||||
(o.name, o.id, o.group),
|
||||
)
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
return f"{self.id} ({self.name}, {self.group})"
|
||||
|
||||
def __hash__(self):
|
||||
return hash((self.id, self.name, self.group))
|
||||
|
||||
def __gt__(self, other):
|
||||
return self.id >= other.id
|
||||
|
||||
|
||||
class HtmlParticipant:
|
||||
def __init__(self, name, id):
|
||||
self.name = name
|
||||
self.id = id
|
||||
self.finalist = None
|
||||
|
||||
def __eq__(self, o):
|
||||
if type(o) != HtmlPreviewParticipant:
|
||||
return False
|
||||
|
||||
return all(
|
||||
map(
|
||||
lambda x, y: x == y,
|
||||
(self.name, self.id, self.group),
|
||||
(o.name, o.id, o.group),
|
||||
)
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
return f"{self.id}: {self.name}"
|
||||
|
||||
def __hash__(self):
|
||||
return hash((self.id, self.name))
|
||||
|
||||
def __gt__(self, other):
|
||||
return self.id >= other.id
|
||||
|
||||
|
||||
class HtmlPreviewImport:
|
||||
def __init__(
|
||||
self,
|
||||
participants: dict[int, list[HtmlPreviewParticipant]],
|
||||
results: dict[
|
||||
HtmlPreviewParticipant, dict[str, competition_class.CompetitionClass]
|
||||
],
|
||||
):
|
||||
self.participants = participants
|
||||
self.results = results
|
||||
|
||||
def __repr__(self):
|
||||
return (str(self.participants), str(self.results))
|
||||
|
||||
|
||||
class HtmlResultImport:
|
||||
def __init__(self, results: dict[HtmlParticipant, str]):
|
||||
self.results = results
|
||||
|
||||
def __repr__(self):
|
||||
return str(self.results)
|
||||
|
||||
|
||||
class HtmlResultTotalTable:
|
||||
def __init__(self, participants):
|
||||
self.participants = participants
|
||||
|
||||
def __repr__(self):
|
||||
return str(self.participants)
|
||||
|
||||
|
||||
class HtmlCompetitionResultRow:
|
||||
def __init__(self, name, id, dance, group, class_, place, placeTo, finalist):
|
||||
self.dance = dance
|
||||
self.group = group
|
||||
self.class_ = class_
|
||||
self.place = place
|
||||
self.placeTo = placeTo
|
||||
self.id = int(id)
|
||||
self.name = name
|
||||
self.finalist = finalist
|
||||
|
||||
def __repr__(self):
|
||||
if self.place == self.placeTo:
|
||||
result = f"{self.place}."
|
||||
else:
|
||||
result = f"{self.place}.-{self.placeTo}."
|
||||
|
||||
if self.finalist == True:
|
||||
finalist = "[F]"
|
||||
else:
|
||||
finalist = ""
|
||||
return f"Result[{self.id}]({self.group} {self.class_} {self.dance} as {result}{finalist})"
|
||||
|
||||
def __eq__(self, o):
|
||||
if not isinstance(o, CompetitionResult):
|
||||
return False
|
||||
|
||||
return (
|
||||
self.dance == o.dance
|
||||
and self.competitionClass == o.competitionClass
|
||||
and self.competitionGroup == o.competitionGroup
|
||||
and self.place == o.place
|
||||
and self.placeTo == o.placeTo
|
||||
and self.id == o.id
|
||||
)
|
||||
|
||||
|
||||
class HtmlSingleCompetitionResult:
|
||||
def __init__(self, name, place, placeTo, finalist):
|
||||
self.name = name
|
||||
self.place = place
|
||||
self.placeTo = placeTo
|
||||
self.finalist = finalist
|
||||
|
||||
def __repr__(self):
|
||||
if self.placeTo is None:
|
||||
place = self.place
|
||||
else:
|
||||
place = f"{self.place}-{self.placeTo}"
|
||||
|
||||
if self.finalist:
|
||||
return f"Res({self.name} [F], placed {place})"
|
||||
else:
|
||||
return f"Res({self.name}, placed {place})"
|
||||
|
||||
def __gt__(self, other):
|
||||
return self.id > other.id
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.id == other.id
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self.id)
|
||||
|
||||
|
||||
class HtmlCompetitionTotalResults:
|
||||
def __init__(self):
|
||||
self.results = {}
|
||||
self.tabges = {}
|
||||
|
||||
def __getTuple(
|
||||
self,
|
||||
group: group.Group_t,
|
||||
class_: competition_class.Class_t,
|
||||
dance: str,
|
||||
id: int,
|
||||
):
|
||||
return (group, class_, dance, id)
|
||||
|
||||
def get(
|
||||
self,
|
||||
group: group.Group_t,
|
||||
class_: competition_class.Class_t,
|
||||
dance: str,
|
||||
id: int,
|
||||
) -> list[HtmlSingleCompetitionResult]:
|
||||
return self.results[self.__getTuple(group, class_, dance, id)]
|
||||
|
||||
def getById(
|
||||
self, id: int
|
||||
) -> dict[
|
||||
tuple[str, group.Group_t, competition_class.Class_t],
|
||||
HtmlSingleCompetitionResult,
|
||||
]:
|
||||
ret = {}
|
||||
|
||||
for k in self.results:
|
||||
if int(k[3]) != id:
|
||||
continue
|
||||
# ret = ret + self.results[k]
|
||||
# Dance, Group, Class
|
||||
key = (k[2], k[0], k[1])
|
||||
ret[key] = self.results[k]
|
||||
|
||||
return ret
|
||||
|
||||
def add(self, group, class_, dance, id, result: HtmlSingleCompetitionResult):
|
||||
tup = self.__getTuple(group, class_, dance, id)
|
||||
l = self.results.get(tup, [])
|
||||
l.append(result)
|
||||
self.results[tup] = l
|
||||
|
||||
|
||||
class SingleParticipantResult:
|
||||
def __init__(
|
||||
self,
|
||||
competitionClass: competition_class.Class_t,
|
||||
nativeClass: competition_class.CompetitionClass,
|
||||
dance: str,
|
||||
finalist: bool,
|
||||
place: int,
|
||||
placeTo: int | None,
|
||||
):
|
||||
self.competitionClass = competitionClass
|
||||
self.nativeClass = nativeClass
|
||||
self.dance = dance
|
||||
self.finalist = finalist
|
||||
self.place = place
|
||||
self.placeTo = placeTo
|
||||
|
||||
if placeTo == place:
|
||||
self.placeTo = None
|
||||
|
||||
self.placeNative = None
|
||||
self.placeNativeTo = None
|
||||
|
||||
def __repr__(self):
|
||||
asFinalist = " as finalist" if self.finalist else ""
|
||||
|
||||
if self.placeTo is None:
|
||||
return f"SR[{self.place} in {self.dance} {self.competitionClass} ({self.placeNative}-{self.placeNativeTo}, {self.nativeClass}){asFinalist}]"
|
||||
|
||||
return f"SR[{self.place}-{self.placeTo} in {self.dance} {self.competitionClass} ({self.placeNative}-{self.placeNativeTo}, {self.nativeClass}){asFinalist}]"
|
||||
|
||||
def getPlace(self):
|
||||
if self.placeTo is None:
|
||||
return f"{self.place}."
|
||||
else:
|
||||
return f"{self.place}.-{self.placeTo}."
|
||||
|
||||
def getNativePlace(self):
|
||||
if self.placeNativeTo is None:
|
||||
return f"{self.placeNative}."
|
||||
else:
|
||||
return f"{self.placeNative}.-{self.placeNativeTo}."
|
||||
|
||||
|
||||
class TotalGroupResult:
|
||||
def __init__(
|
||||
self,
|
||||
dances: list[str],
|
||||
results: dict[HtmlPreviewParticipant, list[SingleParticipantResult]],
|
||||
):
|
||||
self.dances = dances
|
||||
self.results = results
|
||||
|
||||
def __repr__(self):
|
||||
return f"TotalGroupResult({self.dances}, {self.results})"
|
||||
|
||||
|
||||
class State4:
|
||||
def __init__(self, resultPerGroup: dict[group.Group, TotalGroupResult]):
|
||||
parser = group.GroupParser()
|
||||
self.groups = parser.getGroupsAsSortedList(resultPerGroup.keys())
|
||||
self.results = resultPerGroup
|
||||
|
||||
|
||||
class State3:
|
||||
def __init__(self, htmlResults: HtmlCompetitionTotalResults):
|
||||
self.htmlResults = htmlResults
|
||||
|
||||
|
||||
class Participant:
|
||||
def __init__(
|
||||
self,
|
||||
firstName: str,
|
||||
lastName: str,
|
||||
club: str,
|
||||
group: group.Group,
|
||||
class_: competition_class.CompetitionClass,
|
||||
):
|
||||
self.firstName = firstName
|
||||
self.lastName = lastName
|
||||
self.club = club
|
||||
self.group = group
|
||||
self.class_ = class_
|
||||
|
||||
|
||||
class ParticipantResult:
|
||||
def __init__(
|
||||
self,
|
||||
id: int,
|
||||
finalist: bool,
|
||||
cancelled: bool,
|
||||
group: group.Group_t,
|
||||
class_: competition_class.Class_t,
|
||||
dance: str,
|
||||
place,
|
||||
placeTo,
|
||||
):
|
||||
self.id = id
|
||||
self.finalist = finalist
|
||||
self.cancelled = cancelled
|
||||
self.group = group
|
||||
self.class_ = class_
|
||||
self.dance = dance
|
||||
self.place = place
|
||||
self.placeTo = placeTo
|
||||
|
||||
|
||||
class Stage2:
|
||||
def __init__(self, results: dict[Participant, list[ParticipantResult]]):
|
||||
self.results = results
|
||||
|
||||
|
||||
class TableCompetitionEntry:
|
||||
def __init__(
|
||||
self,
|
||||
cancelled: bool,
|
||||
finalist: bool,
|
||||
class_: competition_class.Class_t,
|
||||
place: int = -1,
|
||||
placeTo: int = -1,
|
||||
group: group.Group_t = None,
|
||||
id: int = None,
|
||||
):
|
||||
self.finalist = finalist
|
||||
self.cancelled = cancelled
|
||||
self.group = group
|
||||
self.class_ = class_
|
||||
self.place = place
|
||||
self.placeTo = placeTo
|
||||
|
||||
def __repr__(self):
|
||||
def paramMerging(l):
|
||||
return ", ".join(filter(lambda x: x is not None, l))
|
||||
|
||||
if self.cancelled:
|
||||
params = paramMerging([self.group, self.class_, self.id])
|
||||
if len(params) > 0:
|
||||
return f"- ({params})"
|
||||
else:
|
||||
return "-"
|
||||
elif not self.finalist:
|
||||
params = paramMerging([self.group, self.class_, self.id])
|
||||
if len(params) > 0:
|
||||
return f"x ({params})"
|
||||
else:
|
||||
return "x"
|
||||
else:
|
||||
if self.place == self.placeTo:
|
||||
place = f"{self.place}."
|
||||
else:
|
||||
place = f"{self.place}.-{self.placeTo}."
|
||||
params = paramMerging([self.group, self.class_, self.id])
|
||||
return f"{place} ({params})"
|
||||
|
||||
|
||||
class TableEntry:
|
||||
def __init__(self, competitions: list[TableCompetitionEntry]):
|
||||
self.competitions = competitions
|
||||
|
||||
def __repr__(self):
|
||||
return ", ".join(self.competitions)
|
||||
|
||||
|
||||
class TableRow:
|
||||
def __init__(self, participant: Participant, id: int, entries: list[TableEntry]):
|
||||
self.participant = participant
|
||||
self.id = id
|
||||
self.entries = entries
|
||||
|
||||
def getRowList(self):
|
||||
if self.id is not None:
|
||||
first = f"{self.id}. {self.participant.firstName} {self.participant.lastName} ({self.participant.club})"
|
||||
else:
|
||||
first = f"{self.participant.firstName} {self.participant.lastName} ({self.participant.club})"
|
||||
return [first] + map(str, self.entries)
|
||||
|
||||
|
||||
class OutputTable:
|
||||
def __init__(self, dances: list[str], rows: list[TableRow]):
|
||||
self.dances = dances
|
||||
self.rows = rows
|
||||
|
||||
|
||||
class Stage1:
|
||||
def __init__(self, tables: dict[group.Group, OutputTable]):
|
||||
self.tables = tables
|
||||
from .htmlPreviewParticipant import HtmlPreviewParticipant
|
||||
from .htmlParticipant import HtmlParticipant
|
||||
from .htmlPreviewImport import HtmlPreviewImport
|
||||
from .htmlResultImport import HtmlResultImport
|
||||
from .htmlResultTotalTable import HtmlResultTotalTable
|
||||
from .htmlCompetitionResultRow import HtmlCompetitionResultRow
|
||||
from .htmlSingleCompetitionResult import HtmlSingleCompetitionResult
|
||||
from .htmlCompetitionTotalResults import HtmlCompetitionTotalResults
|
||||
from .singleParticipantResult import SingleParticipantResult
|
||||
from .totalGroupResult import TotalGroupResult
|
||||
from .participant import Participant
|
||||
from .participantResult import ParticipantResult
|
||||
from .tableCompetitionEntry import TableCompetitionEntry
|
||||
from .tableEntry import TableEntry
|
||||
from .tableRow import TableRow
|
||||
from .outputTable import OutputTable
|
||||
|
||||
from .stages import *
|
||||
|
35
src/solo_turnier/types/htmlCompetitionResultRow.py
Normal file
35
src/solo_turnier/types/htmlCompetitionResultRow.py
Normal file
@ -0,0 +1,35 @@
|
||||
class HtmlCompetitionResultRow:
|
||||
def __init__(self, name, id, dance, group, class_, place, placeTo, finalist):
|
||||
self.dance = dance
|
||||
self.group = group
|
||||
self.class_ = class_
|
||||
self.place = place
|
||||
self.placeTo = placeTo
|
||||
self.id = int(id)
|
||||
self.name = name
|
||||
self.finalist = finalist
|
||||
|
||||
def __repr__(self):
|
||||
if self.place == self.placeTo:
|
||||
result = f"{self.place}."
|
||||
else:
|
||||
result = f"{self.place}.-{self.placeTo}."
|
||||
|
||||
if self.finalist == True:
|
||||
finalist = "[F]"
|
||||
else:
|
||||
finalist = ""
|
||||
return f"Result[{self.id}]({self.group} {self.class_} {self.dance} as {result}{finalist})"
|
||||
|
||||
def __eq__(self, o):
|
||||
if not isinstance(o, CompetitionResult):
|
||||
return False
|
||||
|
||||
return (
|
||||
self.dance == o.dance
|
||||
and self.competitionClass == o.competitionClass
|
||||
and self.competitionGroup == o.competitionGroup
|
||||
and self.place == o.place
|
||||
and self.placeTo == o.placeTo
|
||||
and self.id == o.id
|
||||
)
|
50
src/solo_turnier/types/htmlCompetitionTotalResults.py
Normal file
50
src/solo_turnier/types/htmlCompetitionTotalResults.py
Normal file
@ -0,0 +1,50 @@
|
||||
import solo_turnier
|
||||
from .htmlSingleCompetitionResult import HtmlSingleCompetitionResult
|
||||
|
||||
|
||||
class HtmlCompetitionTotalResults:
|
||||
def __init__(self):
|
||||
self.results = {}
|
||||
self.tabges = {}
|
||||
|
||||
def __getTuple(
|
||||
self,
|
||||
group: solo_turnier.group.Group_t,
|
||||
class_: solo_turnier.competition_class.Class_t,
|
||||
dance: str,
|
||||
id: int,
|
||||
):
|
||||
return (group, class_, dance, id)
|
||||
|
||||
def get(
|
||||
self,
|
||||
group: solo_turnier.group.Group_t,
|
||||
class_: solo_turnier.competition_class.Class_t,
|
||||
dance: str,
|
||||
id: int,
|
||||
) -> list[HtmlSingleCompetitionResult]:
|
||||
return self.results[self.__getTuple(group, class_, dance, id)]
|
||||
|
||||
def getById(
|
||||
self, id: int
|
||||
) -> dict[
|
||||
tuple[str, solo_turnier.group.Group_t, solo_turnier.competition_class.Class_t],
|
||||
HtmlSingleCompetitionResult,
|
||||
]:
|
||||
ret = {}
|
||||
|
||||
for k in self.results:
|
||||
if int(k[3]) != id:
|
||||
continue
|
||||
# ret = ret + self.results[k]
|
||||
# Dance, Group, Class
|
||||
key = (k[2], k[0], k[1])
|
||||
ret[key] = self.results[k]
|
||||
|
||||
return ret
|
||||
|
||||
def add(self, group, class_, dance, id, result: HtmlSingleCompetitionResult):
|
||||
tup = self.__getTuple(group, class_, dance, id)
|
||||
l = self.results.get(tup, [])
|
||||
l.append(result)
|
||||
self.results[tup] = l
|
26
src/solo_turnier/types/htmlParticipant.py
Normal file
26
src/solo_turnier/types/htmlParticipant.py
Normal file
@ -0,0 +1,26 @@
|
||||
class HtmlParticipant:
|
||||
def __init__(self, name, id):
|
||||
self.name = name
|
||||
self.id = id
|
||||
self.finalist = None
|
||||
|
||||
def __eq__(self, o):
|
||||
if type(o) != HtmlPreviewParticipant:
|
||||
return False
|
||||
|
||||
return all(
|
||||
map(
|
||||
lambda x, y: x == y,
|
||||
(self.name, self.id, self.group),
|
||||
(o.name, o.id, o.group),
|
||||
)
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
return f"{self.id}: {self.name}"
|
||||
|
||||
def __hash__(self):
|
||||
return hash((self.id, self.name))
|
||||
|
||||
def __gt__(self, other):
|
||||
return self.id >= other.id
|
18
src/solo_turnier/types/htmlPreviewImport.py
Normal file
18
src/solo_turnier/types/htmlPreviewImport.py
Normal file
@ -0,0 +1,18 @@
|
||||
from .htmlPreviewParticipant import HtmlPreviewParticipant
|
||||
import solo_turnier
|
||||
|
||||
|
||||
class HtmlPreviewImport:
|
||||
def __init__(
|
||||
self,
|
||||
participants: dict[int, list[HtmlPreviewParticipant]],
|
||||
results: dict[
|
||||
HtmlPreviewParticipant,
|
||||
dict[str, solo_turnier.competition_class.CompetitionClass],
|
||||
],
|
||||
):
|
||||
self.participants = participants
|
||||
self.results = results
|
||||
|
||||
def __repr__(self):
|
||||
return (str(self.participants), str(self.results))
|
28
src/solo_turnier/types/htmlPreviewParticipant.py
Normal file
28
src/solo_turnier/types/htmlPreviewParticipant.py
Normal file
@ -0,0 +1,28 @@
|
||||
class HtmlPreviewParticipant:
|
||||
def __init__(self, name, id, group_):
|
||||
self.name = name
|
||||
self.id = id
|
||||
groupParser = group.GroupParser()
|
||||
self.group = groupParser.parseGroup(group_)
|
||||
self.finalist = None
|
||||
|
||||
def __eq__(self, o):
|
||||
if type(o) != HtmlPreviewParticipant:
|
||||
return False
|
||||
|
||||
return all(
|
||||
map(
|
||||
lambda x, y: x == y,
|
||||
(self.name, self.id, self.group),
|
||||
(o.name, o.id, o.group),
|
||||
)
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
return f"{self.id} ({self.name}, {self.group})"
|
||||
|
||||
def __hash__(self):
|
||||
return hash((self.id, self.name, self.group))
|
||||
|
||||
def __gt__(self, other):
|
||||
return self.id >= other.id
|
9
src/solo_turnier/types/htmlResultImport.py
Normal file
9
src/solo_turnier/types/htmlResultImport.py
Normal file
@ -0,0 +1,9 @@
|
||||
from .htmlParticipant import HtmlParticipant
|
||||
|
||||
|
||||
class HtmlResultImport:
|
||||
def __init__(self, results: dict[HtmlParticipant, str]):
|
||||
self.results = results
|
||||
|
||||
def __repr__(self):
|
||||
return str(self.results)
|
6
src/solo_turnier/types/htmlResultTotalTable.py
Normal file
6
src/solo_turnier/types/htmlResultTotalTable.py
Normal file
@ -0,0 +1,6 @@
|
||||
class HtmlResultTotalTable:
|
||||
def __init__(self, participants):
|
||||
self.participants = participants
|
||||
|
||||
def __repr__(self):
|
||||
return str(self.participants)
|
26
src/solo_turnier/types/htmlSingleCompetitionResult.py
Normal file
26
src/solo_turnier/types/htmlSingleCompetitionResult.py
Normal file
@ -0,0 +1,26 @@
|
||||
class HtmlSingleCompetitionResult:
|
||||
def __init__(self, name, place, placeTo, finalist):
|
||||
self.name = name
|
||||
self.place = place
|
||||
self.placeTo = placeTo
|
||||
self.finalist = finalist
|
||||
|
||||
def __repr__(self):
|
||||
if self.placeTo is None:
|
||||
place = self.place
|
||||
else:
|
||||
place = f"{self.place}-{self.placeTo}"
|
||||
|
||||
if self.finalist:
|
||||
return f"Res({self.name} [F], placed {place})"
|
||||
else:
|
||||
return f"Res({self.name}, placed {place})"
|
||||
|
||||
def __gt__(self, other):
|
||||
return self.id > other.id
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.id == other.id
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self.id)
|
7
src/solo_turnier/types/outputTable.py
Normal file
7
src/solo_turnier/types/outputTable.py
Normal file
@ -0,0 +1,7 @@
|
||||
from .tableRow import TableRow
|
||||
|
||||
|
||||
class OutputTable:
|
||||
def __init__(self, dances: list[str], rows: list[TableRow]):
|
||||
self.dances = dances
|
||||
self.rows = rows
|
17
src/solo_turnier/types/participant.py
Normal file
17
src/solo_turnier/types/participant.py
Normal file
@ -0,0 +1,17 @@
|
||||
import solo_turnier
|
||||
|
||||
|
||||
class Participant:
|
||||
def __init__(
|
||||
self,
|
||||
firstName: str,
|
||||
lastName: str,
|
||||
club: str,
|
||||
group: solo_turnier.group.Group,
|
||||
class_: solo_turnier.competition_class.CompetitionClass,
|
||||
):
|
||||
self.firstName = firstName
|
||||
self.lastName = lastName
|
||||
self.club = club
|
||||
self.group = group
|
||||
self.class_ = class_
|
23
src/solo_turnier/types/participantResult.py
Normal file
23
src/solo_turnier/types/participantResult.py
Normal file
@ -0,0 +1,23 @@
|
||||
import solo_turnier
|
||||
|
||||
|
||||
class ParticipantResult:
|
||||
def __init__(
|
||||
self,
|
||||
id: int,
|
||||
finalist: bool,
|
||||
cancelled: bool,
|
||||
group: solo_turnier.group.Group_t,
|
||||
class_: solo_turnier.competition_class.Class_t,
|
||||
dance: str,
|
||||
place,
|
||||
placeTo,
|
||||
):
|
||||
self.id = id
|
||||
self.finalist = finalist
|
||||
self.cancelled = cancelled
|
||||
self.group = group
|
||||
self.class_ = class_
|
||||
self.dance = dance
|
||||
self.place = place
|
||||
self.placeTo = placeTo
|
45
src/solo_turnier/types/singleParticipantResult.py
Normal file
45
src/solo_turnier/types/singleParticipantResult.py
Normal file
@ -0,0 +1,45 @@
|
||||
import solo_turnier
|
||||
|
||||
|
||||
class SingleParticipantResult:
|
||||
def __init__(
|
||||
self,
|
||||
competitionClass: solo_turnier.competition_class.Class_t,
|
||||
nativeClass: solo_turnier.competition_class.CompetitionClass,
|
||||
dance: str,
|
||||
finalist: bool,
|
||||
place: int,
|
||||
placeTo: int | None,
|
||||
):
|
||||
self.competitionClass = competitionClass
|
||||
self.nativeClass = nativeClass
|
||||
self.dance = dance
|
||||
self.finalist = finalist
|
||||
self.place = place
|
||||
self.placeTo = placeTo
|
||||
|
||||
if placeTo == place:
|
||||
self.placeTo = None
|
||||
|
||||
self.placeNative = None
|
||||
self.placeNativeTo = None
|
||||
|
||||
def __repr__(self):
|
||||
asFinalist = " as finalist" if self.finalist else ""
|
||||
|
||||
if self.placeTo is None:
|
||||
return f"SR[{self.place} in {self.dance} {self.competitionClass} ({self.placeNative}-{self.placeNativeTo}, {self.nativeClass}){asFinalist}]"
|
||||
|
||||
return f"SR[{self.place}-{self.placeTo} in {self.dance} {self.competitionClass} ({self.placeNative}-{self.placeNativeTo}, {self.nativeClass}){asFinalist}]"
|
||||
|
||||
def getPlace(self):
|
||||
if self.placeTo is None:
|
||||
return f"{self.place}."
|
||||
else:
|
||||
return f"{self.place}.-{self.placeTo}."
|
||||
|
||||
def getNativePlace(self):
|
||||
if self.placeNativeTo is None:
|
||||
return f"{self.placeNative}."
|
||||
else:
|
||||
return f"{self.placeNative}.-{self.placeNativeTo}."
|
34
src/solo_turnier/types/stages.py
Normal file
34
src/solo_turnier/types/stages.py
Normal file
@ -0,0 +1,34 @@
|
||||
import solo_turnier
|
||||
|
||||
from .totalGroupResult import TotalGroupResult
|
||||
from .htmlCompetitionTotalResults import HtmlCompetitionTotalResults
|
||||
from .participant import Participant
|
||||
from .participantResult import ParticipantResult
|
||||
from .outputTable import OutputTable
|
||||
|
||||
|
||||
class State4:
|
||||
def __init__(
|
||||
self, resultPerGroup: dict[solo_turnier.group.Group, TotalGroupResult]
|
||||
):
|
||||
parser = group.GroupParser()
|
||||
self.groups = parser.getGroupsAsSortedList(resultPerGroup.keys())
|
||||
self.results = resultPerGroup
|
||||
|
||||
|
||||
class State3:
|
||||
def __init__(self, htmlResults: HtmlCompetitionTotalResults):
|
||||
self.htmlResults = htmlResults
|
||||
|
||||
|
||||
class Stage2:
|
||||
def __init__(self, results: dict[Participant, list[ParticipantResult]]):
|
||||
self.results = results
|
||||
|
||||
|
||||
class Stage1:
|
||||
def __init__(
|
||||
self,
|
||||
tables: dict[solo_turnier.group.Group, OutputTable],
|
||||
):
|
||||
self.tables = tables
|
44
src/solo_turnier/types/tableCompetitionEntry.py
Normal file
44
src/solo_turnier/types/tableCompetitionEntry.py
Normal file
@ -0,0 +1,44 @@
|
||||
import solo_turnier
|
||||
|
||||
|
||||
class TableCompetitionEntry:
|
||||
def __init__(
|
||||
self,
|
||||
cancelled: bool,
|
||||
finalist: bool,
|
||||
class_: solo_turnier.competition_class.Class_t,
|
||||
place: int = -1,
|
||||
placeTo: int = -1,
|
||||
group: solo_turnier.group.Group_t = None,
|
||||
id: int = None,
|
||||
):
|
||||
self.finalist = finalist
|
||||
self.cancelled = cancelled
|
||||
self.group = group
|
||||
self.class_ = class_
|
||||
self.place = place
|
||||
self.placeTo = placeTo
|
||||
|
||||
def __repr__(self):
|
||||
def paramMerging(l):
|
||||
return ", ".join(filter(lambda x: x is not None, l))
|
||||
|
||||
if self.cancelled:
|
||||
params = paramMerging([self.group, self.class_, self.id])
|
||||
if len(params) > 0:
|
||||
return f"- ({params})"
|
||||
else:
|
||||
return "-"
|
||||
elif not self.finalist:
|
||||
params = paramMerging([self.group, self.class_, self.id])
|
||||
if len(params) > 0:
|
||||
return f"x ({params})"
|
||||
else:
|
||||
return "x"
|
||||
else:
|
||||
if self.place == self.placeTo:
|
||||
place = f"{self.place}."
|
||||
else:
|
||||
place = f"{self.place}.-{self.placeTo}."
|
||||
params = paramMerging([self.group, self.class_, self.id])
|
||||
return f"{place} ({params})"
|
9
src/solo_turnier/types/tableEntry.py
Normal file
9
src/solo_turnier/types/tableEntry.py
Normal file
@ -0,0 +1,9 @@
|
||||
from .tableCompetitionEntry import TableCompetitionEntry
|
||||
|
||||
|
||||
class TableEntry:
|
||||
def __init__(self, competitions: list[TableCompetitionEntry]):
|
||||
self.competitions = competitions
|
||||
|
||||
def __repr__(self):
|
||||
return ", ".join(self.competitions)
|
16
src/solo_turnier/types/tableRow.py
Normal file
16
src/solo_turnier/types/tableRow.py
Normal file
@ -0,0 +1,16 @@
|
||||
from .participant import Participant
|
||||
from .tableEntry import TableEntry
|
||||
|
||||
|
||||
class TableRow:
|
||||
def __init__(self, participant: Participant, id: int, entries: list[TableEntry]):
|
||||
self.participant = participant
|
||||
self.id = id
|
||||
self.entries = entries
|
||||
|
||||
def getRowList(self):
|
||||
if self.id is not None:
|
||||
first = f"{self.id}. {self.participant.firstName} {self.participant.lastName} ({self.participant.club})"
|
||||
else:
|
||||
first = f"{self.participant.firstName} {self.participant.lastName} ({self.participant.club})"
|
||||
return [first] + map(str, self.entries)
|
15
src/solo_turnier/types/totalGroupResult.py
Normal file
15
src/solo_turnier/types/totalGroupResult.py
Normal file
@ -0,0 +1,15 @@
|
||||
from .htmlPreviewParticipant import HtmlPreviewParticipant
|
||||
from .singleParticipantResult import SingleParticipantResult
|
||||
|
||||
|
||||
class TotalGroupResult:
|
||||
def __init__(
|
||||
self,
|
||||
dances: list[str],
|
||||
results: dict[HtmlPreviewParticipant, list[SingleParticipantResult]],
|
||||
):
|
||||
self.dances = dances
|
||||
self.results = results
|
||||
|
||||
def __repr__(self):
|
||||
return f"TotalGroupResult({self.dances}, {self.results})"
|
Loading…
Reference in New Issue
Block a user