Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6f11554c18 | |||
| 03fed1e1e4 | |||
| be5ac238bc | |||
| 5015a4e4e1 | |||
| 90f82e677e | |||
| fac3fe1b34 | |||
| 25135cc7d9 | |||
| 77c156b7db |
@@ -1,6 +1,6 @@
|
||||
[Application]
|
||||
name=Solo Auswertung
|
||||
version=0.9.1
|
||||
version=0.9.5
|
||||
# How to launch the app - this calls the 'main' function from the 'myapp' package:
|
||||
entry_point=main:main
|
||||
# icon=myapp.ico
|
||||
|
||||
@@ -26,7 +26,9 @@ def main():
|
||||
port=cli.getPort()
|
||||
)
|
||||
else:
|
||||
combinedData = batchWorker.run()
|
||||
combinedData = batchWorker.run(
|
||||
removeFilteredParicipants=not cli.showAllParticipants()
|
||||
)
|
||||
|
||||
consoleOutputtter = solo_turnier.output.ConsoleOutputter()
|
||||
consoleOutputtter.output(combinedData)
|
||||
|
||||
@@ -29,7 +29,6 @@ class BatchWorker:
|
||||
importedData = worker.collectAllData(htmlCandidatesPreview, htmlResultFiles)
|
||||
combinedData = worker.combineData(importedData)
|
||||
|
||||
if not self.config.showAllParticipants():
|
||||
worker.filterOutFinalists(combinedData, removeFilteredParicipants)
|
||||
worker.filterOutFinalists(combinedData, removeFilteredParicipants)
|
||||
|
||||
return combinedData
|
||||
|
||||
@@ -8,7 +8,7 @@ class Cli:
|
||||
parser = argparse.ArgumentParser()
|
||||
# parser.add_argument('--gui', help='Show the GUI', action='store_true')
|
||||
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')
|
||||
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=1, default=['.'])
|
||||
parser.add_argument('-o', '--output', help='Set the output path of the script', nargs=1, default=[None])
|
||||
|
||||
@@ -4,7 +4,8 @@ import solo_turnier
|
||||
def startFlask(
|
||||
batchWorker: solo_turnier.batch.BatchWorker,
|
||||
debug: bool = False,
|
||||
port: int = 8082
|
||||
port: int = 8082,
|
||||
showOnlyFinalists: bool = True
|
||||
):
|
||||
app = flask.Flask(__name__)
|
||||
|
||||
@@ -14,4 +15,12 @@ def startFlask(
|
||||
|
||||
return flask.render_template('index.html', data=combinedData)
|
||||
|
||||
@app.get('/custom.css')
|
||||
def css():
|
||||
ret = flask.render_template(
|
||||
'custom.css',
|
||||
onlyFinalists=showOnlyFinalists
|
||||
)
|
||||
return flask.Response(ret, mimetype='text/css')
|
||||
|
||||
app.run(host='0.0.0.0', port=port, debug=debug)
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
5
src/solo_turnier/templates/custom.css
Normal file
5
src/solo_turnier/templates/custom.css
Normal file
@@ -0,0 +1,5 @@
|
||||
{% if onlyFinalists %}
|
||||
.no-finalist {
|
||||
display: none;
|
||||
}
|
||||
{% endif %}
|
||||
@@ -6,6 +6,7 @@
|
||||
{# <meta name="description" content="Webpage for xxxx"> #}
|
||||
<!-- http://meyerweb.com/eric/tools/css/reset/ -->
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||
<link rel="stylesheet" href="/custom.css">
|
||||
</head>
|
||||
<body>
|
||||
{# <h1>Finalauswertung Solo-Turniere</h1> #}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user