Fix native class from final result table

This commit is contained in:
Christian Wolf 2023-11-08 20:46:05 +01:00
parent ee63871e1c
commit c7212316ee
2 changed files with 17 additions and 2 deletions

View File

@ -44,6 +44,11 @@ class CompetitionClassParser:
self.namesPreview = [
'Sichtung'
]
self.mapShortNames = {
'N': self.NEWC,
'B': self.BEG,
'A': self.ADV,
}
def parseClass(self, cls: str, allowPreview: bool = False) -> Class_t:
if allowPreview and cls in self.namesPreview:
@ -57,6 +62,9 @@ class CompetitionClassParser:
else:
return self.mapNames[cls]
def parseAbbreviatedClass(self, cls: str) -> Class_t:
return self.mapShortNames[cls]
def isPureClass(self, cls: str, allowPreview: bool = False) -> bool:
parsedClass = self.parseClass(cls, allowPreview)
return isinstance(parsedClass, CompetitionClass)

View File

@ -550,7 +550,9 @@ class Worker:
raise Exception('Multiple results found with same key')
rawResult = rawResult[0]
nativeClass = previewResults.results[participant][dance]
nativeClass = key[2]
# nativeClass = previewResults.results[participant][dance]
# nativeClass = key[2]
# self.l.log(5, 'Result %s => %s', key, rawResult)
ret = types.SingleParticipantResult(
@ -565,13 +567,15 @@ class Worker:
return results
def _fixNativePlacesFromTable(
def _fixNativeDataFromTable(
self,
dances: list[str],
data: dict[types.HtmlPreviewParticipant, list[types.SingleParticipantResult]],
importedData: types.HtmlCompetitionTotalResults
):
rePlace = re.compile('([0-9]+)(?:-([0-9]+))?')
classParser = competition_class.CompetitionClassParser()
for participant in data.keys():
self.l.log(5, 'fixing participant %s', participant)
results = data[participant]
@ -598,6 +602,9 @@ class Worker:
result.placeNative = matcher.group(1)
result.placeNativeTo = matcher.group(2)
if raw[1] is not None:
result.nativeClass = classParser.parseAbbreviatedClass(raw[1])
pass
def _fixNativePlaces(