Fix names of classes and allow for combined competitions with other classes
This commit is contained in:
parent
8d227af0e4
commit
b36d5a81ce
@ -36,43 +36,34 @@ class CombinedCompetitionClass:
|
||||
Class_t = CompetitionClass | CombinedCompetitionClass
|
||||
|
||||
|
||||
class CompetitionClassParser:
|
||||
NEWC = CompetitionClass("Newc.")
|
||||
BEG = CompetitionClass("Beg.")
|
||||
ADV = CompetitionClass("Adv.")
|
||||
class NoEClassException(Exception):
|
||||
def __init__(self, *args):
|
||||
super(NoEClassException, self).__init__(*args)
|
||||
|
||||
PREVIEW = CompetitionClass("Sichtung")
|
||||
|
||||
class CompetitionClassParser:
|
||||
E = CompetitionClass('E')
|
||||
|
||||
def __init__(self):
|
||||
self.mapNames = {
|
||||
"Newc": self.NEWC,
|
||||
"Newc.": self.NEWC,
|
||||
"Newcomer": self.NEWC,
|
||||
"Beg": self.BEG,
|
||||
"Beg.": self.BEG,
|
||||
"Beginner": self.BEG,
|
||||
"Adv": self.ADV,
|
||||
"Adv.": self.ADV,
|
||||
"Advanced": self.ADV,
|
||||
"E": self.E,
|
||||
}
|
||||
self.namesPreview = ["Sichtung"]
|
||||
self.mapShortNames = {
|
||||
"N": self.NEWC,
|
||||
"B": self.BEG,
|
||||
"A": self.ADV,
|
||||
}
|
||||
self.mapShortNames = self.mapNames
|
||||
|
||||
def parseClass(self, cls: str, allowPreview: bool = False) -> Class_t:
|
||||
if allowPreview and cls in self.namesPreview:
|
||||
return self.PREVIEW
|
||||
# match = re.compile("^(\\w+\\.?)/(\\w+\\.?)$").match(cls)
|
||||
# if match is not None:
|
||||
# clsA = self.mapNames[match.group(1)]
|
||||
# clsB = self.mapNames[match.group(2)]
|
||||
# return CombinedCompetitionClass(clsA, clsB)
|
||||
# else:
|
||||
# return self.mapNames[cls]
|
||||
|
||||
match = re.compile("^(\\w+\\.?)/(\\w+\\.?)$").match(cls)
|
||||
if match is not None:
|
||||
clsA = self.mapNames[match.group(1)]
|
||||
clsB = self.mapNames[match.group(2)]
|
||||
return CombinedCompetitionClass(clsA, clsB)
|
||||
else:
|
||||
if cls in self.mapNames:
|
||||
return self.mapNames[cls]
|
||||
else:
|
||||
raise NoEClassException(f'The class "{cls}" is not parsable.')
|
||||
|
||||
def parseAbbreviatedClass(self, cls: str) -> Class_t:
|
||||
return self.mapShortNames[cls]
|
||||
|
@ -31,8 +31,11 @@ class ResultExtractor:
|
||||
|
||||
try:
|
||||
data = parser.guessDataFromHtmlTitle()
|
||||
except competition_class.NoEClassException as ex:
|
||||
self.l.info('The HTML file %s does not represent a solo E class. Skipping it. (%s)', filePair[0], ex)
|
||||
continue
|
||||
except:
|
||||
self.l.error(
|
||||
self.l.warning(
|
||||
"Cannot parse HTML file %s to check if it is a valid result. Check manually.",
|
||||
filePair[0],
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user