From aaa311ee03f139d3eaa20e100857e2e3c9c75441 Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Wed, 8 Nov 2023 20:00:01 +0100 Subject: [PATCH 1/5] Avoid issue with rounds that contain all previous participants --- src/solo_turnier/html_parser.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/solo_turnier/html_parser.py b/src/solo_turnier/html_parser.py index 7117e4b..db97cac 100644 --- a/src/solo_turnier/html_parser.py +++ b/src/solo_turnier/html_parser.py @@ -57,6 +57,9 @@ class HtmlParser: if len(tds) != 2: return + if tds[1].contents[0].startswith('Alle Starter weiter genommen.'): + self.l.info('No excluded starters found.') + return regex = re.compile('(.*) \\(([0-9]+)\\)') place = tds[0].contents[0] From 36fa6a6dca6081085a3ecd696a76f541ba08c58f Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Wed, 8 Nov 2023 20:42:11 +0100 Subject: [PATCH 2/5] Augment the logging for debugging --- src/solo_turnier/worker.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/solo_turnier/worker.py b/src/solo_turnier/worker.py index 9968e61..e4e1192 100644 --- a/src/solo_turnier/worker.py +++ b/src/solo_turnier/worker.py @@ -467,11 +467,11 @@ class Worker: self.l.log(5, 'Obtained result %s', resultsOfParticipant) results[participant] = resultsOfParticipant - self.l.log(5, 'Result before native fixing: %s', (results)) + self.l.log(5, 'Result before native fixing: %s', pformat(results)) # self._fixNativePlaces(dances, results) - self._fixNativePlacesFromTable(dances, results, importedData.htmlResults) - # self.l.log(5, 'Result after native fixing: %s', pformat(results)) - self.l.log(5,'Data %s', results) + self._fixNativeDataFromTable(dances, results, importedData.htmlResults) + self.l.log(5, 'Result after native fixing: %s', pformat(results)) + # self.l.log(5,'Fixed data %s', results) totalResult[group] = types.TotalGroupResult(dances, results) From bb10d5fa0640cda8e6c3518d1f5f1eb4018498b6 Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Wed, 8 Nov 2023 20:45:19 +0100 Subject: [PATCH 3/5] Ignore failed preview round scans --- src/solo_turnier/worker.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/solo_turnier/worker.py b/src/solo_turnier/worker.py index e4e1192..6d2be77 100644 --- a/src/solo_turnier/worker.py +++ b/src/solo_turnier/worker.py @@ -159,7 +159,10 @@ class PreviewWorker: for file in parsers: parser = parsers[file] - self.__extractPersonsFromSinglePreview(parser) + try: + self.__extractPersonsFromSinglePreview(parser) + except: + self.l.error('Failed to parse preview round in file %s. Skipping this file\'s content.', parser.fileName) return types.HtmlPreviewImport(self.participants, self.previewResults) From ee63871e1c33d7b0fec968c0065aba3958df93f8 Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Wed, 8 Nov 2023 20:45:44 +0100 Subject: [PATCH 4/5] Augment logging a bit --- src/solo_turnier/html_parser.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/solo_turnier/html_parser.py b/src/solo_turnier/html_parser.py index db97cac..45b3f32 100644 --- a/src/solo_turnier/html_parser.py +++ b/src/solo_turnier/html_parser.py @@ -60,12 +60,14 @@ class HtmlParser: if tds[1].contents[0].startswith('Alle Starter weiter genommen.'): self.l.info('No excluded starters found.') return + regex = re.compile('(.*) \\(([0-9]+)\\)') place = tds[0].contents[0] match = regex.fullmatch(tds[1].contents[0]) if match is None: + self.l.error('Could not match %s to regex search pattern', str(tds)) raise Exception(f'Could not match {tds} to regex search pattern') name = match.group(1) number = match.group(2) From c7212316eea91b163cd8a698e6b21fdd905b6241 Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Wed, 8 Nov 2023 20:46:05 +0100 Subject: [PATCH 5/5] Fix native class from final result table --- src/solo_turnier/competition_class.py | 8 ++++++++ src/solo_turnier/worker.py | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/solo_turnier/competition_class.py b/src/solo_turnier/competition_class.py index 9fe88c8..20e1107 100644 --- a/src/solo_turnier/competition_class.py +++ b/src/solo_turnier/competition_class.py @@ -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) diff --git a/src/solo_turnier/worker.py b/src/solo_turnier/worker.py index 6d2be77..b5aa7ba 100644 --- a/src/solo_turnier/worker.py +++ b/src/solo_turnier/worker.py @@ -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(