Fixed bug with pure string group

This commit is contained in:
Christian Wolf 2023-11-22 16:33:02 +01:00
parent abf4974d40
commit c690ce755a
4 changed files with 40 additions and 6 deletions

View File

@ -114,6 +114,9 @@ class HtmlParser:
rePlaceParser = re.compile("([0-9]+)(?:-([0-9]+))?")
groupParser = solo_turnier.group.GroupParser()
classParser = solo_turnier.competition_class.CompetitionClassParser()
def __parseTable(table):
rows = table.find_all("tr")
@ -176,7 +179,12 @@ class HtmlParser:
classRow = findRowIndex("Startklasse")
if classRow is not None:
classTags = rows[classRow]("td")[1 : (numIds + 1)]
return list(map(lambda x: x.contents[0], classTags))
return list(
map(
lambda x: classParser.parseAbbreviatedClass(x.contents[0]),
classTags,
)
)
return None
classes = getClass()
@ -185,8 +193,10 @@ class HtmlParser:
def getGroups():
groupRow = findRowIndex("Startgruppe")
if groupRow is not None:
classTags = rows[groupRow]("td")[1 : (numIds + 1)]
return list(map(lambda x: x.contents[0], classTags))
groupTags = rows[groupRow]("td")[1 : (numIds + 1)]
return list(
map(lambda x: groupParser.parseGroup(x.contents[0]), groupTags)
)
return None
groups = getGroups()

View File

@ -65,6 +65,26 @@ class ConsoleOutputter(AbstractOutputter):
print(tabulate(tableData, headers="firstrow", tablefmt="fancy_grid"))
print()
def _reshapeRow(
self,
results: list[solo_turnier.types.SingleParticipantResult],
dances: list[str],
) -> list[solo_turnier.types.SingleParticipantResult]:
ret = [None for x in dances]
for result in results:
if result.dance not in dances:
self.l.error(
"Result in unknown dance found in table. This is a bug. (%s)",
result,
)
continue
idx = dances.index(result.dance)
ret[idx] = result
return ret
def _outputGroup(
self, group: solo_turnier.group.Group, groupResults: types.TotalGroupResult
):
@ -76,6 +96,9 @@ class ConsoleOutputter(AbstractOutputter):
for participant in participants:
results = groupResults.results[participant]
results = self._reshapeRow(results, groupResults.dances)
self.l.log(5, "Results of %s: %s", participant, results)
def mapResultColumn(result: types.SingleParticipantResult):
def getPlace(place, placeTo):

View File

@ -18,3 +18,6 @@ class Participant(Person):
if self.finalist == True:
return f"Part({self.id} {self.name},F)"
return f"Part({self.id} {self.name})"
def __ge__(self, other):
return self.id >= other.id

View File

@ -356,9 +356,7 @@ class Worker:
singleResult.nativePlace = fixture.place
if fixture.class_ is not None:
singleResult.nativeClass = self._classParser.parseAbbreviatedClass(
fixture.class_
)
singleResult.nativeClass = fixture.class_
def _extractDancesPerGroup(
self, data: types.State3, group: solo_turnier.group.Group