Moved types into package
This commit is contained in:
parent
82d7717fde
commit
b78b964a55
@ -1,37 +1,10 @@
|
||||
from . import group
|
||||
from . import competition_class
|
||||
from .place import Place
|
||||
|
||||
from .. import group
|
||||
from .. import competition_class
|
||||
|
||||
|
||||
class CSVResultRow:
|
||||
def __init__(
|
||||
self,
|
||||
firstName,
|
||||
lastName,
|
||||
club,
|
||||
id,
|
||||
group,
|
||||
class_,
|
||||
dance,
|
||||
place,
|
||||
placeTo,
|
||||
competitionGroup,
|
||||
competitionClass,
|
||||
):
|
||||
self.firstName = firstName
|
||||
self.lastName = lastName
|
||||
self.name = f"{firstName} {lastName}"
|
||||
self.club = club
|
||||
self.id = id
|
||||
self.group = group
|
||||
self.class_ = class_
|
||||
self.dance = dance
|
||||
self.place = place
|
||||
self.placeTo = placeTo
|
||||
self.competitionGroup = competitionGroup
|
||||
self.competitionClass = competitionClass
|
||||
|
||||
def __repr__(self):
|
||||
return f"{self.name} ({self.id}, {self.club}) is in {self.group} {self.class_} and danced the {self.dance} in {self.competitionGroup} {self.competitionClass} getting place {self.place}-{self.placeTo}"
|
||||
from .csvResultRow import CSVResultRow
|
||||
|
||||
|
||||
class HtmlPreviewParticipant:
|
||||
@ -92,12 +65,6 @@ class HtmlParticipant:
|
||||
return self.id >= other.id
|
||||
|
||||
|
||||
# class PreviewParticipationData:
|
||||
# def __init__(self, dance: str, class_: competition_class.CompetitionClass):
|
||||
# self.class_ = class_
|
||||
# self.dance = dance
|
||||
|
||||
|
||||
class HtmlPreviewImport:
|
||||
def __init__(
|
||||
self,
|
30
src/solo_turnier/types/csvResultRow.py
Normal file
30
src/solo_turnier/types/csvResultRow.py
Normal file
@ -0,0 +1,30 @@
|
||||
class CSVResultRow:
|
||||
def __init__(
|
||||
self,
|
||||
firstName,
|
||||
lastName,
|
||||
club,
|
||||
id,
|
||||
group,
|
||||
class_,
|
||||
dance,
|
||||
place,
|
||||
placeTo,
|
||||
competitionGroup,
|
||||
competitionClass,
|
||||
):
|
||||
self.firstName = firstName
|
||||
self.lastName = lastName
|
||||
self.name = f"{firstName} {lastName}"
|
||||
self.club = club
|
||||
self.id = id
|
||||
self.group = group
|
||||
self.class_ = class_
|
||||
self.dance = dance
|
||||
self.place = place
|
||||
self.placeTo = placeTo
|
||||
self.competitionGroup = competitionGroup
|
||||
self.competitionClass = competitionClass
|
||||
|
||||
def __repr__(self):
|
||||
return f"{self.name} ({self.id}, {self.club}) is in {self.group} {self.class_} and danced the {self.dance} in {self.competitionGroup} {self.competitionClass} getting place {self.place}-{self.placeTo}"
|
10
src/solo_turnier/types/place.py
Normal file
10
src/solo_turnier/types/place.py
Normal file
@ -0,0 +1,10 @@
|
||||
class Place:
|
||||
def __init__(self, place: int, placeTo: int | None = None):
|
||||
self.place = place
|
||||
self.placeTo = placeTo
|
||||
|
||||
def __str__(self):
|
||||
if self.placeTo is None:
|
||||
return f"{self.place}."
|
||||
|
||||
return f"{self.place}.-{self.placeTo}"
|
@ -53,16 +53,18 @@ class ResultExtractor:
|
||||
|
||||
return ret
|
||||
|
||||
def _extractPlace(self, placeStr: str):
|
||||
def _extractPlace(self, placeStr: str) -> types.Place:
|
||||
s = placeStr.replace(".", "")
|
||||
|
||||
matches = self.rePlaceSingle.fullmatch(s)
|
||||
if matches is not None:
|
||||
return (int(matches.group(1)), None)
|
||||
return types.Place(int(matches.group(1)))
|
||||
# return (int(matches.group(1)), None)
|
||||
|
||||
matches = self.rePlaceDouble.fullmatch(s)
|
||||
if matches is not None:
|
||||
return (int(matches.group(1)), int(matches.group(2)))
|
||||
return types.Place(int(matches.group(1)), int(matches.group(2)))
|
||||
# return (int(matches.group(1)), int(matches.group(2)))
|
||||
|
||||
self.l.error('Could not parse place string "%s"', placeStr)
|
||||
raise Exception("Place cannot be parsed")
|
||||
|
Loading…
Reference in New Issue
Block a user