Allow to filter only for finalists in the output of the script
This commit is contained in:
parent
62035b01b4
commit
d7d72e83b5
@ -29,5 +29,8 @@ class BatchWorker:
|
|||||||
importedData = worker.collectAllData(htmlCandidatesPreview, htmlResultFiles)
|
importedData = worker.collectAllData(htmlCandidatesPreview, htmlResultFiles)
|
||||||
combinedData = worker.combineData(importedData)
|
combinedData = worker.combineData(importedData)
|
||||||
|
|
||||||
|
if not self.config.showAllParticipants():
|
||||||
|
worker.filterOutFinalists(combinedData)
|
||||||
|
|
||||||
consoleOutputtter = solo_turnier.output.ConsoleOutputter()
|
consoleOutputtter = solo_turnier.output.ConsoleOutputter()
|
||||||
consoleOutputtter.output(combinedData)
|
consoleOutputtter.output(combinedData)
|
||||||
|
@ -10,6 +10,7 @@ class Cli:
|
|||||||
|
|
||||||
parser.add_argument('html', help='The path from where to look for HTML export files', nargs=1, default=['.'])
|
parser.add_argument('html', help='The path from where to look for HTML export files', nargs=1, default=['.'])
|
||||||
parser.add_argument('-o', '--output', help='Set the output path of the script', nargs=1, default=[None])
|
parser.add_argument('-o', '--output', help='Set the output path of the script', nargs=1, default=[None])
|
||||||
|
parser.add_argument('--all-participants', '-a', action='store_true', help='Show all participants not only finalists')
|
||||||
|
|
||||||
parser.add_argument('-v', '--verbose', help='Increase verbosity', action='count', default=0)
|
parser.add_argument('-v', '--verbose', help='Increase verbosity', action='count', default=0)
|
||||||
parser.add_argument('-d', '--debug', action='store_true', help='Activate debugging during startup')
|
parser.add_argument('-d', '--debug', action='store_true', help='Activate debugging during startup')
|
||||||
@ -43,3 +44,6 @@ class Cli:
|
|||||||
|
|
||||||
def getLogLevel(self):
|
def getLogLevel(self):
|
||||||
return self.__args.verbose
|
return self.__args.verbose
|
||||||
|
|
||||||
|
def showAllParticipants(self):
|
||||||
|
return self.__args.all_participants
|
||||||
|
@ -651,4 +651,27 @@ class Worker:
|
|||||||
|
|
||||||
# self.l.log(5, '(Partially) fixed places: %s', (data))
|
# self.l.log(5, '(Partially) fixed places: %s', (data))
|
||||||
|
|
||||||
|
def filterOutFinalists(self, data: types.State4):
|
||||||
|
for group in data.results:
|
||||||
|
self.l.debug('Cleaning up group %s', group.name)
|
||||||
|
participants = data.results[group].results.keys()
|
||||||
|
droppedParticipants = []
|
||||||
|
|
||||||
|
for participant in participants:
|
||||||
|
self.l.debug('Checking %s', participant)
|
||||||
|
|
||||||
|
def isFinalistInDance(x: types.HtmlSingleCompetitionResult|None):
|
||||||
|
if x is None:
|
||||||
|
return False
|
||||||
|
return x.finalist
|
||||||
|
mapped = list(map(isFinalistInDance, data.results[group].results[participant]))
|
||||||
|
finalist = True in mapped
|
||||||
|
self.l.log(5,'Check for finalist (in dances %s): %s', mapped, finalist)
|
||||||
|
|
||||||
|
if not finalist:
|
||||||
|
self.l.warning('Dropping %s from the output as no finalist', participant)
|
||||||
|
droppedParticipants.append(participant)
|
||||||
|
|
||||||
|
for droppedParticipant in droppedParticipants:
|
||||||
|
data.results[group].results.pop(droppedParticipant)
|
||||||
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user