Extension to new class and group restrictions
This commit is contained in:
parent
561dab897b
commit
d39a8d590e
@ -8,12 +8,16 @@ class CompetitionClass:
|
|||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
class CombinedCompetitionClass:
|
class CombinedCompetitionClass:
|
||||||
def __init__(self, clsA: CompetitionClass, clsB: CompetitionClass):
|
def __init__(self, clsA: CompetitionClass, clsB: CompetitionClass, clsC: CompetitionClass = None):
|
||||||
self.clsA = clsA
|
self.clsA = clsA
|
||||||
self.clsB = clsB
|
self.clsB = clsB
|
||||||
|
self.clsC = clsC
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
if self.clsC is None:
|
||||||
return f'{self.clsA}/{self.clsB}'
|
return f'{self.clsA}/{self.clsB}'
|
||||||
|
else:
|
||||||
|
return f'{self.clsA}/{self.clsB}/{self.clsC}'
|
||||||
|
|
||||||
Class_t = CompetitionClass | CombinedCompetitionClass
|
Class_t = CompetitionClass | CombinedCompetitionClass
|
||||||
|
|
||||||
@ -22,6 +26,8 @@ class CompetitionClassParser:
|
|||||||
BEG = CompetitionClass('Beg.')
|
BEG = CompetitionClass('Beg.')
|
||||||
ADV = CompetitionClass('Adv.')
|
ADV = CompetitionClass('Adv.')
|
||||||
|
|
||||||
|
PREVIEW = CompetitionClass('Sichtung')
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.mapNames = {
|
self.mapNames = {
|
||||||
@ -35,8 +41,14 @@ class CompetitionClassParser:
|
|||||||
'Adv.': self.ADV,
|
'Adv.': self.ADV,
|
||||||
'Advanced': self.ADV,
|
'Advanced': self.ADV,
|
||||||
}
|
}
|
||||||
|
self.namesPreview = [
|
||||||
|
'Sichtung'
|
||||||
|
]
|
||||||
|
|
||||||
|
def parseClass(self, cls: str, allowPreview: bool = False) -> Class_t:
|
||||||
|
if allowPreview and cls in self.namesPreview:
|
||||||
|
return self.PREVIEW
|
||||||
|
|
||||||
def parseClass(self, cls: str) -> Class_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:
|
||||||
clsA = self.mapNames[match.group(1)]
|
clsA = self.mapNames[match.group(1)]
|
||||||
@ -45,6 +57,6 @@ class CompetitionClassParser:
|
|||||||
else:
|
else:
|
||||||
return self.mapNames[cls]
|
return self.mapNames[cls]
|
||||||
|
|
||||||
def isPureClass(self, cls: str) -> bool:
|
def isPureClass(self, cls: str, allowPreview: bool = False) -> bool:
|
||||||
parsedClass = self.parseClass(cls)
|
parsedClass = self.parseClass(cls, allowPreview)
|
||||||
return isinstance(parsedClass, CompetitionClass)
|
return isinstance(parsedClass, CompetitionClass)
|
||||||
|
@ -21,6 +21,12 @@ class GroupParser:
|
|||||||
KIN = Group('Kin.')
|
KIN = Group('Kin.')
|
||||||
JUN = Group('Jun.')
|
JUN = Group('Jun.')
|
||||||
JUG = Group('Jug.')
|
JUG = Group('Jug.')
|
||||||
|
HGR = Group('Hgr.')
|
||||||
|
MAS1 = Group('Mas. I')
|
||||||
|
MAS2 = Group('Mas. II')
|
||||||
|
MAS3 = Group('Mas. III')
|
||||||
|
MAS4 = Group('Mas. IV')
|
||||||
|
MAS5 = Group('Mas. V')
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
@ -28,12 +34,36 @@ class GroupParser:
|
|||||||
'Kin': self.KIN,
|
'Kin': self.KIN,
|
||||||
'Kin.': self.KIN,
|
'Kin.': self.KIN,
|
||||||
'Kinder': self.KIN,
|
'Kinder': self.KIN,
|
||||||
|
|
||||||
'Jun': self.JUN,
|
'Jun': self.JUN,
|
||||||
'Jun.': self.JUN,
|
'Jun.': self.JUN,
|
||||||
'Junioren': self.JUN,
|
'Junioren': self.JUN,
|
||||||
|
|
||||||
'Jug': self.JUG,
|
'Jug': self.JUG,
|
||||||
'Jug.': self.JUG,
|
'Jug.': self.JUG,
|
||||||
'Jugend': self.JUG,
|
'Jugend': self.JUG,
|
||||||
|
|
||||||
|
'Hgr': self.HGR,
|
||||||
|
'HGr': self.HGR,
|
||||||
|
'Hgr.': self.HGR,
|
||||||
|
'HGr.': self.HGR,
|
||||||
|
'Hauptgruppe': self.HGR,
|
||||||
|
|
||||||
|
'Mas. I': self.MAS1,
|
||||||
|
'Mas. II': self.MAS2,
|
||||||
|
'Mas. III': self.MAS3,
|
||||||
|
'Mas. IV': self.MAS4,
|
||||||
|
'Mas. V': self.MAS5,
|
||||||
|
'Mas I': self.MAS1,
|
||||||
|
'Mas II': self.MAS2,
|
||||||
|
'Mas III': self.MAS3,
|
||||||
|
'Mas IV': self.MAS4,
|
||||||
|
'Mas V': self.MAS5,
|
||||||
|
'Masters I': self.MAS1,
|
||||||
|
'Masters II': self.MAS2,
|
||||||
|
'Masters III': self.MAS3,
|
||||||
|
'Masters IV': self.MAS4,
|
||||||
|
'Masters V': self.MAS5,
|
||||||
}
|
}
|
||||||
|
|
||||||
def parseClass(self, cls: str) -> Group_t:
|
def parseClass(self, cls: str) -> Group_t:
|
||||||
|
Loading…
Reference in New Issue
Block a user