Enhance data structure to reuse common class objects
This commit is contained in:
parent
16d78e18f3
commit
69e20dd4c8
@ -16,7 +16,7 @@ sectionMap = {
|
|||||||
|
|
||||||
class AbstractOutputter:
|
class AbstractOutputter:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.worker = solo_turnier.worker.DataWorker()
|
self.worker = solo_turnier.workers.DataWorker.DataWorker()
|
||||||
self.groups = []
|
self.groups = []
|
||||||
self.dances = []
|
self.dances = []
|
||||||
self.showIds = False
|
self.showIds = False
|
||||||
|
@ -1,6 +1,15 @@
|
|||||||
from .reader import ResultRow
|
from .reader import ResultRow
|
||||||
|
|
||||||
|
# import logging
|
||||||
|
# from pprint import pformat
|
||||||
|
|
||||||
|
# import re
|
||||||
|
|
||||||
|
# import solo_turnier
|
||||||
|
|
||||||
|
# from .types import HtmlCompetitionResultRow as CompetitionResult
|
||||||
|
# from . import types
|
||||||
|
# from . import competition_class
|
||||||
|
|
||||||
|
|
||||||
class HtmlPerson:
|
class HtmlPerson:
|
||||||
|
@ -2,6 +2,7 @@ from ..reader import ResultRow
|
|||||||
from ..worker import ResultPerson
|
from ..worker import ResultPerson
|
||||||
from ..types import HtmlCompetitionResultRow as CompetitionResult
|
from ..types import HtmlCompetitionResultRow as CompetitionResult
|
||||||
from solo_turnier import html_parser
|
from solo_turnier import html_parser
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
class DataWorker:
|
class DataWorker:
|
||||||
|
@ -42,6 +42,7 @@ class Worker:
|
|||||||
self.l.log(5, "Inverted group maping: %s", invertedGroupMapping)
|
self.l.log(5, "Inverted group maping: %s", invertedGroupMapping)
|
||||||
|
|
||||||
totalResult = {}
|
totalResult = {}
|
||||||
|
ret = types.State4(totalResult)
|
||||||
|
|
||||||
for group in groups:
|
for group in groups:
|
||||||
self.l.debug("Collecting data for total result of group %s", group)
|
self.l.debug("Collecting data for total result of group %s", group)
|
||||||
@ -75,32 +76,27 @@ class Worker:
|
|||||||
|
|
||||||
self.l.log(5, "Total result of all groups: %s", pformat(totalResult))
|
self.l.log(5, "Total result of all groups: %s", pformat(totalResult))
|
||||||
|
|
||||||
ret = types.State4(totalResult)
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def _extractGroups(self, data: types.State3):
|
def _extractGroups(self, data: types.State3):
|
||||||
groupParser = solo_turnier.group.GroupParser()
|
|
||||||
|
|
||||||
groupSet = set([])
|
groupSet = set([])
|
||||||
# for id in data.previewImport.participants:
|
# for id in data.previewImport.participants:
|
||||||
# participants = data.previewImport.participants[id]
|
# participants = data.previewImport.participants[id]
|
||||||
# for participant in participants:
|
# for participant in participants:
|
||||||
# groupSet.add(participant.group)
|
# groupSet.add(participant.group)
|
||||||
for tup in data.htmlResults.results.keys():
|
for tup in data.htmlResults.results.keys():
|
||||||
gr = groupParser.parseClass(tup[0])
|
gr = self._groupParser.parseClass(tup[0])
|
||||||
# groupSet.add(gr)
|
# groupSet.add(gr)
|
||||||
groupSet.update(gr.getContainedGroups())
|
groupSet.update(gr.getContainedGroups())
|
||||||
# self.l.log(5, 'Group type %s', type(gr))
|
# self.l.log(5, 'Group type %s', type(gr))
|
||||||
|
|
||||||
self.l.log(5, "Set of active groups: %s", groupSet)
|
self.l.log(5, "Set of active groups: %s", groupSet)
|
||||||
groups = groupParser.getGroupsAsSortedList(groupSet)
|
groups = self._groupParser.getGroupsAsSortedList(groupSet)
|
||||||
return groups
|
return groups
|
||||||
|
|
||||||
def _getGroupMapping(
|
def _getGroupMapping(
|
||||||
self, importedData: types.State3
|
self, importedData: types.State3
|
||||||
) -> dict[int, solo_turnier.group.Group | None]:
|
) -> dict[int, solo_turnier.group.Group | None]:
|
||||||
groupParser = solo_turnier.group.GroupParser()
|
|
||||||
|
|
||||||
def _getBestGroupGuess(groups, id):
|
def _getBestGroupGuess(groups, id):
|
||||||
counts = {}
|
counts = {}
|
||||||
grNones = 0
|
grNones = 0
|
||||||
@ -141,11 +137,11 @@ class Worker:
|
|||||||
|
|
||||||
groupsPerId = {}
|
groupsPerId = {}
|
||||||
for tup in importedData.htmlResults.results:
|
for tup in importedData.htmlResults.results:
|
||||||
competitionGroup = groupParser.parseClass(tup[0])
|
competitionGroup = self._groupParser.parseClass(tup[0])
|
||||||
fixture = importedData.htmlResults.tabges.get(tup, (None, None, None))
|
fixture = importedData.htmlResults.tabges.get(tup, (None, None, None))
|
||||||
id = int(tup[3])
|
id = int(tup[3])
|
||||||
if fixture[2] is not None:
|
if fixture[2] is not None:
|
||||||
group = groupParser.parseClass(fixture[2])
|
group = self._groupParser.parseClass(fixture[2])
|
||||||
else:
|
else:
|
||||||
containedGroups = competitionGroup.getContainedGroups()
|
containedGroups = competitionGroup.getContainedGroups()
|
||||||
if len(containedGroups) > 1:
|
if len(containedGroups) > 1:
|
||||||
@ -202,13 +198,11 @@ class Worker:
|
|||||||
def _extractDancesPerGroup(
|
def _extractDancesPerGroup(
|
||||||
self, data: types.State3, group: solo_turnier.group.Group
|
self, data: types.State3, group: solo_turnier.group.Group
|
||||||
):
|
):
|
||||||
groupParser = solo_turnier.group.GroupParser()
|
|
||||||
|
|
||||||
dances = set()
|
dances = set()
|
||||||
additionalDances = set()
|
additionalDances = set()
|
||||||
foundDances = set()
|
foundDances = set()
|
||||||
for tup in data.htmlResults.results.keys():
|
for tup in data.htmlResults.results.keys():
|
||||||
currentGroup = groupParser.parseClass(tup[0])
|
currentGroup = self._groupParser.parseClass(tup[0])
|
||||||
if group not in currentGroup.getContainedGroups():
|
if group not in currentGroup.getContainedGroups():
|
||||||
continue
|
continue
|
||||||
foundDances.add(tup[2])
|
foundDances.add(tup[2])
|
||||||
@ -233,15 +227,13 @@ class Worker:
|
|||||||
# previewData: types.HtmlPreviewImport,
|
# previewData: types.HtmlPreviewImport,
|
||||||
group: solo_turnier.group.Group,
|
group: solo_turnier.group.Group,
|
||||||
) -> list[types.HtmlPreviewParticipant]:
|
) -> list[types.HtmlPreviewParticipant]:
|
||||||
groupParser = types.group.GroupParser()
|
|
||||||
|
|
||||||
ret = []
|
ret = []
|
||||||
|
|
||||||
# self.l.log(5, 'Table %s', pformat(importedData.htmlResults.tabges))
|
# self.l.log(5, 'Table %s', pformat(importedData.htmlResults.tabges))
|
||||||
# self.l.log(5, 'Results %s', pformat(importedData.htmlResults.results))
|
# self.l.log(5, 'Results %s', pformat(importedData.htmlResults.results))
|
||||||
|
|
||||||
for tup in importedData.htmlResults.results.keys():
|
for tup in importedData.htmlResults.results.keys():
|
||||||
currentGroup = groupParser.parseClass(tup[0])
|
currentGroup = self._groupParser.parseClass(tup[0])
|
||||||
activeGroups = currentGroup.getContainedGroups()
|
activeGroups = currentGroup.getContainedGroups()
|
||||||
if group not in activeGroups:
|
if group not in activeGroups:
|
||||||
continue
|
continue
|
||||||
@ -252,7 +244,7 @@ class Worker:
|
|||||||
else:
|
else:
|
||||||
if (
|
if (
|
||||||
fixture[2] is not None
|
fixture[2] is not None
|
||||||
and groupParser.parseClass(fixture[2]) != group
|
and self._groupParser.parseClass(fixture[2]) != group
|
||||||
):
|
):
|
||||||
self.l.log(
|
self.l.log(
|
||||||
5,
|
5,
|
||||||
|
Loading…
Reference in New Issue
Block a user