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_t = CompetitionClass | CombinedCompetitionClass
|
||||||
|
|
||||||
|
|
||||||
class CompetitionClassParser:
|
class NoEClassException(Exception):
|
||||||
NEWC = CompetitionClass("Newc.")
|
def __init__(self, *args):
|
||||||
BEG = CompetitionClass("Beg.")
|
super(NoEClassException, self).__init__(*args)
|
||||||
ADV = CompetitionClass("Adv.")
|
|
||||||
|
|
||||||
PREVIEW = CompetitionClass("Sichtung")
|
|
||||||
|
class CompetitionClassParser:
|
||||||
|
E = CompetitionClass('E')
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.mapNames = {
|
self.mapNames = {
|
||||||
"Newc": self.NEWC,
|
"E": self.E,
|
||||||
"Newc.": self.NEWC,
|
|
||||||
"Newcomer": self.NEWC,
|
|
||||||
"Beg": self.BEG,
|
|
||||||
"Beg.": self.BEG,
|
|
||||||
"Beginner": self.BEG,
|
|
||||||
"Adv": self.ADV,
|
|
||||||
"Adv.": self.ADV,
|
|
||||||
"Advanced": self.ADV,
|
|
||||||
}
|
}
|
||||||
self.namesPreview = ["Sichtung"]
|
self.namesPreview = ["Sichtung"]
|
||||||
self.mapShortNames = {
|
self.mapShortNames = self.mapNames
|
||||||
"N": self.NEWC,
|
|
||||||
"B": self.BEG,
|
|
||||||
"A": self.ADV,
|
|
||||||
}
|
|
||||||
|
|
||||||
def parseClass(self, cls: str, allowPreview: bool = False) -> Class_t:
|
def parseClass(self, cls: str, allowPreview: bool = False) -> Class_t:
|
||||||
if allowPreview and cls in self.namesPreview:
|
# match = re.compile("^(\\w+\\.?)/(\\w+\\.?)$").match(cls)
|
||||||
return self.PREVIEW
|
# 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 cls in self.mapNames:
|
||||||
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]
|
return self.mapNames[cls]
|
||||||
|
else:
|
||||||
|
raise NoEClassException(f'The class "{cls}" is not parsable.')
|
||||||
|
|
||||||
def parseAbbreviatedClass(self, cls: str) -> Class_t:
|
def parseAbbreviatedClass(self, cls: str) -> Class_t:
|
||||||
return self.mapShortNames[cls]
|
return self.mapShortNames[cls]
|
||||||
|
@ -31,8 +31,11 @@ class ResultExtractor:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
data = parser.guessDataFromHtmlTitle()
|
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:
|
except:
|
||||||
self.l.error(
|
self.l.warning(
|
||||||
"Cannot parse HTML file %s to check if it is a valid result. Check manually.",
|
"Cannot parse HTML file %s to check if it is a valid result. Check manually.",
|
||||||
filePair[0],
|
filePair[0],
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user