refactor code and add stats for ewiges Frühstück
This commit is contained in:
parent
1b39c3085e
commit
379b90ea3d
2 changed files with 21 additions and 11 deletions
0
main.py
Normal file → Executable file
0
main.py
Normal file → Executable file
32
parse.py
32
parse.py
|
@ -3,6 +3,16 @@ from pathlib import Path
|
|||
from typing import Dict, Tuple, Union # I have just python3.8 here :(
|
||||
|
||||
|
||||
# ids of the questions which represent a size of a merch product
|
||||
SIZE_IDS = (312, 313, 314, 316, 319, 320, 321, 322, 323)
|
||||
# ID of wishlist for ewiges Frühstück
|
||||
BREAKFASTWISHES_ID = 309
|
||||
# Wie heißt die Athenanas?
|
||||
ATHENE_ID = 305 # ID of the question of how the logo image is to be named
|
||||
HUMAN_ID = 147 # ticket for a human
|
||||
MASCOT_ID = 148 # ticket for a mascot
|
||||
|
||||
|
||||
def parse(filename: Union[str, Path]) -> Tuple[
|
||||
Dict[int, str],
|
||||
Dict[int, int],
|
||||
|
@ -54,29 +64,29 @@ def wiki_stats(items: Dict[int, str], count_items: Dict[int, int], questions: Di
|
|||
'|-\n')
|
||||
for item_id, item_name in items.items():
|
||||
ret += f"|| {item_name} || {count_items.get(item_id)}\n|-\n"
|
||||
ret += "|}\n"
|
||||
ret += "|}\n\n"
|
||||
|
||||
# ids of the questions which represent a size of a merch product
|
||||
size_ids = (312, 313, 314, 316, 319, 320, 321, 322, 323)
|
||||
ret += ('== Merch-Größenverteilung ==\n'
|
||||
'{|class="wikitable sortable"\n'
|
||||
'! Größe/Eigenschaft !! Wert !! Anzahl\n'
|
||||
'|-\n')
|
||||
for size_id in size_ids:
|
||||
for size_id in SIZE_IDS:
|
||||
for size, count in quest_answers[size_id].items():
|
||||
ret += f"|| {questions[size_id]}: || {size[1]} || {count}\n|-\n"
|
||||
ret += "|}\n"
|
||||
|
||||
athene_id = 305 # ID of the question how the logo image is to be named
|
||||
human_id = 147 # ticket for a human
|
||||
mascot_id = 148 # ticket for a mascot
|
||||
ret += "|}\n\n"
|
||||
|
||||
ret += '== Wünsche an das ewige Frühstück ==\n'
|
||||
for wish in quest_answers[BREAKFASTWISHES_ID]:
|
||||
ret += f"* <pre>{wish[1]}</pre>\n"
|
||||
ret += "\n"
|
||||
|
||||
def prefix(id_):
|
||||
return "Mensch sagt:" if id_ == human_id else "Maskottchen sagt:" if id_ == mascot_id else ""
|
||||
return "Mensch sagt:" if id_ == HUMAN_ID else "Maskottchen sagt:" if id_ == MASCOT_ID else ""
|
||||
ret += ('== Wie heißt das Ding? ==\n'
|
||||
'{|class="wikitable sortable"\n'
|
||||
'! Variante !! Stimmen\n'
|
||||
'|-\n')
|
||||
for variant, count in quest_answers[athene_id].items():
|
||||
for variant, count in quest_answers[ATHENE_ID].items():
|
||||
ret += f"|| {prefix(variant[0])} {variant[1]} || {count}\n|-\n"
|
||||
ret += "|}\n"
|
||||
|
||||
|
|
Loading…
Reference in a new issue