Moved types into package

This commit is contained in:
Christian Wolf 2023-11-20 12:35:19 +01:00
parent 82d7717fde
commit b78b964a55
4 changed files with 50 additions and 41 deletions

View File

@ -1,37 +1,10 @@
from . import group from .place import Place
from . import competition_class
from .. import group
from .. import competition_class
class CSVResultRow: from .csvResultRow import 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}"
class HtmlPreviewParticipant: class HtmlPreviewParticipant:
@ -92,12 +65,6 @@ class HtmlParticipant:
return self.id >= other.id return self.id >= other.id
# class PreviewParticipationData:
# def __init__(self, dance: str, class_: competition_class.CompetitionClass):
# self.class_ = class_
# self.dance = dance
class HtmlPreviewImport: class HtmlPreviewImport:
def __init__( def __init__(
self, self,

View 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}"

View 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}"

View File

@ -53,16 +53,18 @@ class ResultExtractor:
return ret return ret
def _extractPlace(self, placeStr: str): def _extractPlace(self, placeStr: str) -> types.Place:
s = placeStr.replace(".", "") s = placeStr.replace(".", "")
matches = self.rePlaceSingle.fullmatch(s) matches = self.rePlaceSingle.fullmatch(s)
if matches is not None: 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) matches = self.rePlaceDouble.fullmatch(s)
if matches is not None: 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) self.l.error('Could not parse place string "%s"', placeStr)
raise Exception("Place cannot be parsed") raise Exception("Place cannot be parsed")