Enable looking for other HTML files than erg.htm

This commit is contained in:
Christian Wolf 2022-11-26 08:39:35 +01:00
parent 80fdfdc786
commit 724ac95886

View File

@ -4,21 +4,24 @@ import logging
class HtmlLocator: class HtmlLocator:
def __init__(self): def __init__(self):
self.l = logging.getLogger('solo_turnier.html_locator') self.l = logging.getLogger('solo_turnier.html_locator')
self.fileName = 'erg.htm'
def __findRecursivelyCandidates(self, path: str): def __findRecursivelyCandidates(self, path: str, fileName: str):
ret = [] ret = []
ls = os.listdir(path) ls = os.listdir(path)
if self.fileName in ls and os.path.isfile(os.path.join(path, self.fileName)): if fileName in ls and os.path.isfile(os.path.join(path, fileName)):
ret.append(os.path.join(path, self.fileName)) ret.append(os.path.join(path, fileName))
for p in ls: for p in ls:
subPath = os.path.join(path, p) subPath = os.path.join(path, p)
if os.path.isdir(subPath): if os.path.isdir(subPath):
ret = ret + self.__findRecursivelyCandidates(subPath) ret = ret + self.__findRecursivelyCandidates(subPath, fileName)
return ret return ret
def findCandidates(self, path: str): def findCandidates(self, path: str):
return self.__findRecursivelyCandidates(path) return self.__findRecursivelyCandidates(path, 'erg.htm')
def findPreviewRoundCandidates(self, path: str):
candidates = self.__findRecursivelyCandidates(path, 'tabges.htm')
return candidates