5 Commits

Author SHA1 Message Date
66d687d9f0 Update to new version 2023-10-06 18:18:50 +02:00
1d69d9fe8a Fix filtering w.r.t finalists in web styling
Mutiple rows were colored similarly of some are hidden
2023-10-06 18:17:37 +02:00
6f11554c18 Prepare next version 2023-10-06 17:53:15 +02:00
03fed1e1e4 Handle incomplete competitions as well 2023-10-06 17:52:52 +02:00
be5ac238bc Revert "Add UI dialog for unknown path"
This reverts commit 90f82e677e.
2023-10-06 16:20:39 +02:00
8 changed files with 40 additions and 37 deletions

View File

@@ -1,6 +1,6 @@
[Application]
name=Solo Auswertung
version=0.9.4
version=0.9.6
# How to launch the app - this calls the 'main' function from the 'myapp' package:
entry_point=main:main
# icon=myapp.ico

View File

@@ -16,7 +16,6 @@ def main():
cli = solo_turnier.cli.Cli(l)
batchWorker = solo_turnier.batch.BatchWorker(cli)
batchWorker.prepare()
if cli.showGUI():
raise Exception('Not yet implemented')
@@ -24,7 +23,8 @@ def main():
solo_turnier.flask.startFlask(
batchWorker,
debug=cli.getLogLevel() > 0,
port=cli.getPort()
port=cli.getPort(),
showOnlyFinalists=not cli.showAllParticipants()
)
else:
combinedData = batchWorker.run(

View File

@@ -5,8 +5,6 @@ import os
import pprint
import tabulate
import tkinter.filedialog
import tkinter.simpledialog
class BatchWorker:
def __init__(
@@ -15,33 +13,16 @@ class BatchWorker:
):
self.l = logging.getLogger('solo_turnier.batch')
self.config = config
self.importPath = None
def prepare(self):
self.importPath = self.config.importHtmlPath()
if self.importPath is None:
self.l.debug('No HTML import path was provided.')
self.importPath = tkinter.filedialog.askdirectory(mustexist=True, title='HMTL Export auswählen')
if self.importPath is None or len(self.importPath) == 0:
self.l.critical('Import path was not selected. Aborting.')
tkinter.simpledialog.messagebox.showerror(
title='Invalid HTML path selected',
message='You did not select an appropriate folder. Aborting now.'
)
exit(1)
self.l.debug('Using import path %s', self.importPath)
def run(self, removeFilteredParicipants=True):
self.l.debug(self.config.__dict__)
locator = solo_turnier.html_locator.HtmlLocator()
self.l.info('Checking for feasible preview HTML export files in "%s"', self.importPath)
htmlCandidatesPreview = locator.findPreviewRoundCandidates(self.importPath)
self.l.info('Checking for feasible preview HTML export files in "%s"', self.config.importHtmlPath())
htmlCandidatesPreview = locator.findPreviewRoundCandidates(self.config.importHtmlPath())
self.l.debug('Found HTML file candidates for preview rounds: %s', htmlCandidatesPreview)
htmlResultFiles = locator.findCandidates(self.importPath)
htmlResultFiles = locator.findCandidates(self.config.importHtmlPath())
self.l.debug('Using HTML result files for result extraction: %s', htmlResultFiles)
worker = solo_turnier.worker.Worker()

View File

@@ -10,7 +10,7 @@ class Cli:
parser.add_argument('--no-flask', action='store_false', dest='flask', help='Disable the internal flask web server')
parser.add_argument('--port', help='The port to listen for incoming requests', default='8082')
parser.add_argument('html', help='The path from where to look for HTML export files', nargs='?', default=None)
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('--all-participants', '-a', action='store_true', help='Show all participants not only finalists')
@@ -40,7 +40,7 @@ class Cli:
return self.__args.flask
def importHtmlPath(self):
return self.__args.html
return self.__args.html[0]
def importCSVPath(self):
return self.__args.import_from[0]

View File

@@ -1,5 +1,8 @@
import flask
import solo_turnier
import logging
_l = logging.getLogger(__name__)
def startFlask(
batchWorker: solo_turnier.batch.BatchWorker,
@@ -12,8 +15,9 @@ def startFlask(
@app.route('/')
def index():
combinedData = batchWorker.run(False)
_l.debug('Show only finalists %s', showOnlyFinalists)
return flask.render_template('index.html', data=combinedData)
return flask.render_template('index.html', data=combinedData, onlyFinalists=showOnlyFinalists)
@app.get('/custom.css')
def css():

View File

@@ -8,6 +8,10 @@ from .types import HtmlPreviewImport as HtmlImport, HtmlResultImport
from .group import GroupParser
from .competition_class import CompetitionClassParser
class IncompleteRoundException(Exception):
def __init__(self, *args):
super(IncompleteRoundException, self).__init__(*args)
class HtmlParser:
def __init__(self, text: str, fileName: str = None):
@@ -73,7 +77,8 @@ class HtmlParser:
def __parseFirstTable(table):
roundName = table.tr.td.contents[0]
if roundName != 'Endrunde':
raise Exception('Could not parse HTML file')
self.l.warning('Found table with round name %s.', roundName)
raise IncompleteRoundException('Could not parse HTML file')
__parseRows(table.find_all('tr')[2:], True)
@@ -82,10 +87,14 @@ class HtmlParser:
__parseRows(table.find_all('tr'), False)
tables = self.soup.find('div', class_='extract').find_all('table')
if len(tables) > 0:
__parseFirstTable(tables[0])
try:
if len(tables) > 0:
__parseFirstTable(tables[0])
__parseRemainingTables(tables[1:])
__parseRemainingTables(tables[1:])
except IncompleteRoundException:
pass
# title = self.soup.find('div', class_='eventhead').table.tr.td.contents[0]

View File

@@ -28,6 +28,7 @@
{% if not participant.finalist %}
{% set rowCls = "no-finalist" %}
{% endif %}
{% if participant.finalist or not onlyFinalists %}
<tr class="{{ rowCls }}">
<td>{{ participant.name }} ({{ participant.id }})</td>
{% for dance in data.results[group].dances %}
@@ -47,6 +48,7 @@
{% endblock %}
{% endfor %}
</tr>
{% endif %}
{% endblock %}
{% endfor %}
</table>

View File

@@ -177,10 +177,14 @@ class ResultExtractor:
for filePair in files:
with open(filePair[0], 'r') as fp:
text = fp.read()
with open(filePair[1], 'r') as fp:
textTab = fp.read()
parser = html_parser.HtmlParser(text, filePair[0])
parserTab = html_parser.HtmlParser(textTab, filePair[1])
if filePair[1] is None:
parserTab = None
else:
with open(filePair[1], 'r') as fp:
textTab = fp.read()
parserTab = html_parser.HtmlParser(textTab, filePair[1])
try:
data = parser.guessDataFromHtmlTitle()
@@ -247,8 +251,11 @@ class ResultExtractor:
self.l.debug('Extracting data from file %s', fileName)
self._analyzeSingleParser(parsers[fileNameTuple][0], ret)
self.l.debug('Fetching individual result of combined competitions in %s', fileName)
self._analyzeIndividualResults(parsers[fileNameTuple][1], ret)
if parsers[fileNameTuple][1] is None:
self.l.info('Skipping extraction of individual result as class is not yet finished.')
else:
self.l.debug('Fetching individual result of combined competitions in %s', fileName)
self._analyzeIndividualResults(parsers[fileNameTuple][1], ret)
return ret