Refactor name of group parser method
This commit is contained in:
parent
7382df03a8
commit
b4ec4f896c
@ -71,7 +71,7 @@ class GroupParser:
|
|||||||
"Masters V": self.MAS5,
|
"Masters V": self.MAS5,
|
||||||
}
|
}
|
||||||
|
|
||||||
def parseClass(self, cls: str) -> Group_t:
|
def parseGroup(self, cls: str) -> Group_t:
|
||||||
match = re.compile("^(\\w+\\.?)/(\\w+\\.?)$").match(cls)
|
match = re.compile("^(\\w+\\.?)/(\\w+\\.?)$").match(cls)
|
||||||
if match is not None:
|
if match is not None:
|
||||||
grpA = self.mapNames[match.group(1)]
|
grpA = self.mapNames[match.group(1)]
|
||||||
@ -80,9 +80,9 @@ class GroupParser:
|
|||||||
else:
|
else:
|
||||||
return self.mapNames[cls]
|
return self.mapNames[cls]
|
||||||
|
|
||||||
def isPureClass(self, cls: str) -> bool:
|
def isPureGroup(self, cls: str) -> bool:
|
||||||
parsedClass = self.parseClass(cls)
|
parsedGroup = self.parseGroup(cls)
|
||||||
return isinstance(parsedClass, Group)
|
return isinstance(parsedGroup, Group)
|
||||||
|
|
||||||
def getGroups(self) -> list[Group]:
|
def getGroups(self) -> list[Group]:
|
||||||
return [
|
return [
|
||||||
|
@ -46,7 +46,7 @@ class HtmlParser:
|
|||||||
return {
|
return {
|
||||||
"dance": dance.strip(),
|
"dance": dance.strip(),
|
||||||
"class_": str(self.classParser.parseClass(rawClass, True)),
|
"class_": str(self.classParser.parseClass(rawClass, True)),
|
||||||
"group": str(self.groupParser.parseClass(rawGroup)),
|
"group": str(self.groupParser.parseGroup(rawGroup)),
|
||||||
}
|
}
|
||||||
|
|
||||||
def parseResult(self):
|
def parseResult(self):
|
||||||
|
@ -37,7 +37,7 @@ class CSVResultReader:
|
|||||||
|
|
||||||
def __processRow(row):
|
def __processRow(row):
|
||||||
result = ResultRow(
|
result = ResultRow(
|
||||||
competitionGroup=groupParser.parseClass(row[2]),
|
competitionGroup=groupParser.parseGroup(row[2]),
|
||||||
competitionClass=classParser.parseClass(row[3]),
|
competitionClass=classParser.parseClass(row[3]),
|
||||||
dance=row[4],
|
dance=row[4],
|
||||||
id=row[5],
|
id=row[5],
|
||||||
@ -46,7 +46,7 @@ class CSVResultReader:
|
|||||||
club=row[10],
|
club=row[10],
|
||||||
place=row[12],
|
place=row[12],
|
||||||
placeTo=row[13],
|
placeTo=row[13],
|
||||||
group=groupParser.parseClass(row[15]),
|
group=groupParser.parseGroup(row[15]),
|
||||||
class_=classParser.parseClass(row[16]),
|
class_=classParser.parseClass(row[16]),
|
||||||
)
|
)
|
||||||
self.l.log(5, "Found row in CSV: %s", result)
|
self.l.log(5, "Found row in CSV: %s", result)
|
||||||
|
@ -39,7 +39,7 @@ class HtmlPreviewParticipant:
|
|||||||
self.name = name
|
self.name = name
|
||||||
self.id = id
|
self.id = id
|
||||||
groupParser = group.GroupParser()
|
groupParser = group.GroupParser()
|
||||||
self.group = groupParser.parseClass(group_)
|
self.group = groupParser.parseGroup(group_)
|
||||||
self.finalist = None
|
self.finalist = None
|
||||||
|
|
||||||
def __eq__(self, o):
|
def __eq__(self, o):
|
||||||
|
@ -85,7 +85,7 @@ class Worker:
|
|||||||
# 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 = self._groupParser.parseClass(tup[0])
|
gr = self._groupParser.parseGroup(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))
|
||||||
@ -137,11 +137,11 @@ class Worker:
|
|||||||
|
|
||||||
groupsPerId = {}
|
groupsPerId = {}
|
||||||
for tup in importedData.htmlResults.results:
|
for tup in importedData.htmlResults.results:
|
||||||
competitionGroup = self._groupParser.parseClass(tup[0])
|
competitionGroup = self._groupParser.parseGroup(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 = self._groupParser.parseClass(fixture[2])
|
group = self._groupParser.parseGroup(fixture[2])
|
||||||
else:
|
else:
|
||||||
containedGroups = competitionGroup.getContainedGroups()
|
containedGroups = competitionGroup.getContainedGroups()
|
||||||
if len(containedGroups) > 1:
|
if len(containedGroups) > 1:
|
||||||
@ -202,7 +202,7 @@ class Worker:
|
|||||||
additionalDances = set()
|
additionalDances = set()
|
||||||
foundDances = set()
|
foundDances = set()
|
||||||
for tup in data.htmlResults.results.keys():
|
for tup in data.htmlResults.results.keys():
|
||||||
currentGroup = self._groupParser.parseClass(tup[0])
|
currentGroup = self._groupParser.parseGroup(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,7 +233,7 @@ class Worker:
|
|||||||
# 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 = self._groupParser.parseClass(tup[0])
|
currentGroup = self._groupParser.parseGroup(tup[0])
|
||||||
activeGroups = currentGroup.getContainedGroups()
|
activeGroups = currentGroup.getContainedGroups()
|
||||||
if group not in activeGroups:
|
if group not in activeGroups:
|
||||||
continue
|
continue
|
||||||
@ -244,7 +244,7 @@ class Worker:
|
|||||||
else:
|
else:
|
||||||
if (
|
if (
|
||||||
fixture[2] is not None
|
fixture[2] is not None
|
||||||
and self._groupParser.parseClass(fixture[2]) != group
|
and self._groupParser.parseGroup(fixture[2]) != group
|
||||||
):
|
):
|
||||||
self.l.log(
|
self.l.log(
|
||||||
5,
|
5,
|
||||||
|
Loading…
Reference in New Issue
Block a user