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}' class GroupParser: def __init__(self): self.KIN = Group('Kin.') self.JUN = Group('Jun.') self.JUG = Group('Jug.') 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, } def parseClass(self, cls: str) -> Group|CombinedGroup: 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)