2022-11-28 18:01:13 +00:00
|
|
|
import re
|
|
|
|
|
|
|
|
class Group:
|
|
|
|
def __init__(self, text: str):
|
|
|
|
self.name = text
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
class CombinedGroup:
|
|
|
|
def __init__(self, grpA: Group, grpB: Group):
|
|
|
|
self.clsA = grpA
|
|
|
|
self.clsB = grpB
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return f'{self.clsA}/{self.clsB}'
|
|
|
|
|
2022-12-03 19:40:41 +00:00
|
|
|
Group_t = Group | CombinedGroup
|
|
|
|
|
2022-11-28 18:01:13 +00:00
|
|
|
class GroupParser:
|
2022-12-03 20:43:21 +00:00
|
|
|
KIN = Group('Kin.')
|
|
|
|
JUN = Group('Jun.')
|
|
|
|
JUG = Group('Jug.')
|
|
|
|
|
2022-11-28 18:01:13 +00:00
|
|
|
def __init__(self):
|
|
|
|
|
|
|
|
self.mapNames = {
|
|
|
|
'Kin': self.KIN,
|
|
|
|
'Kin.': self.KIN,
|
|
|
|
'Kinder': self.KIN,
|
|
|
|
'Jun': self.JUN,
|
|
|
|
'Jun.': self.JUN,
|
|
|
|
'Junioren': self.JUN,
|
|
|
|
'Jug': self.JUG,
|
|
|
|
'Jug.': self.JUG,
|
|
|
|
'Jugend': self.JUG,
|
|
|
|
}
|
|
|
|
|
2022-12-03 19:40:41 +00:00
|
|
|
def parseClass(self, cls: str) -> Group_t:
|
2022-11-28 18:01:13 +00:00
|
|
|
match = re.compile('^(\\w+\\.?)/(\\w+\\.?)$').match(cls)
|
|
|
|
if match is not None:
|
|
|
|
grpA = self.mapNames[match.group(1)]
|
|
|
|
grpB = self.mapNames[match.group(2)]
|
|
|
|
return CombinedGroup(grpA, grpB)
|
|
|
|
else:
|
|
|
|
return self.mapNames[cls]
|
|
|
|
|
|
|
|
def isPureClass(self, cls: str) -> bool:
|
|
|
|
parsedClass = self.parseClass(cls)
|
|
|
|
return isinstance(parsedClass, Group)
|