solo-auswertung/src/solo_turnier/worker.py

48 lines
1.2 KiB
Python
Raw Normal View History

2022-11-27 08:10:17 +00:00
class HtmlPerson:
def __init__(self, name, id, group):
self.name = name
self.id = id
self.group = group
2023-11-19 16:07:20 +00:00
2022-11-27 08:10:17 +00:00
def __repr__(self):
2023-11-19 16:07:20 +00:00
return f"{self.name} ({self.id}, {self.group})"
2022-12-03 13:29:35 +00:00
def __eq__(self, o):
if not isinstance(o, HtmlPerson):
return False
return str(self) == str(o)
def __hash__(self):
return str(self).__hash__()
2022-11-27 08:10:17 +00:00
2023-11-19 16:07:20 +00:00
2022-11-14 19:01:32 +00:00
class ResultPerson:
2023-11-19 16:07:20 +00:00
def __init__(self, firstName, lastName, club, id=None, group=None):
2022-11-14 19:01:32 +00:00
self.firstName = firstName
self.lastName = lastName
2023-11-19 16:07:20 +00:00
self.name = f"{firstName} {lastName}"
2022-11-14 19:01:32 +00:00
self.club = club
self.id = id
2022-11-15 09:48:50 +00:00
self.group = group
2023-11-19 16:07:20 +00:00
2022-11-15 09:48:50 +00:00
def __eq__(self, o):
if not isinstance(o, ResultPerson):
return False
2023-11-19 16:07:20 +00:00
2022-11-15 09:48:50 +00:00
return (
2023-11-19 16:07:20 +00:00
self.firstName == o.firstName
and self.lastName == o.lastName
and self.club == o.club
and self.id == o.id
2022-11-15 09:48:50 +00:00
)
2023-11-19 16:07:20 +00:00
2022-11-15 09:48:50 +00:00
def __repr__(self):
if self.id is None:
2023-11-19 16:07:20 +00:00
return f"{self.name} ({self.club})"
2022-11-15 09:48:50 +00:00
else:
2023-11-19 16:07:20 +00:00
return f"{self.name} ({self.club}) [{self.id}]"
2022-11-15 09:48:50 +00:00
def __hash__(self):
text = str(self)
return text.__hash__()