From a9ab9ff75a8159a5476f51886a638169cdc4f5f5 Mon Sep 17 00:00:00 2001 From: Paillat-dev Date: Tue, 10 Jun 2025 21:45:48 +0200 Subject: [PATCH] Still broken --- j.txt | 846 ++++++++++++++++++++++++++++++++++++++++- pyproject.toml | 1 + src/__main__.py | 76 ++-- tests/test_esc_2025.py | 85 +++++ uv.lock | 45 +++ 5 files changed, 1017 insertions(+), 36 deletions(-) create mode 100644 tests/test_esc_2025.py diff --git a/j.txt b/j.txt index 26f6e93..d2a960e 100644 --- a/j.txt +++ b/j.txt @@ -1,2 +1,844 @@ -Austria 258 -Switzerland 214 +Parsing jury file: /tmp/tmpuiemxcw7 + Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 0 │ +│ Armenia │ 42 │ 0 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 0 │ +│ Estonia │ 98 │ 0 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 0 │ +│ Greece │ 105 │ 0 │ +│ Iceland │ 0 │ 0 │ +│ Israel │ 60 │ 0 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 0 │ +│ Lithuania │ 34 │ 0 │ +│ Luxembourg │ 23 │ 0 │ +│ Malta │ 83 │ 0 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 0 │ +│ Poland │ 17 │ 0 │ +│ Portugal │ 37 │ 0 │ +│ San Marino │ 9 │ 0 │ +│ Spain │ 27 │ 0 │ +│ Sweden │ 126 │ 0 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 0 │ +│ United Kingdom │ 88 │ 0 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Iceland (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 0 │ +│ Armenia │ 42 │ 0 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 0 │ +│ Estonia │ 98 │ 0 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 0 │ +│ Greece │ 105 │ 0 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 0 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 0 │ +│ Lithuania │ 34 │ 0 │ +│ Luxembourg │ 23 │ 0 │ +│ Malta │ 83 │ 0 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 0 │ +│ Poland │ 17 │ 0 │ +│ Portugal │ 37 │ 0 │ +│ San Marino │ 9 │ 0 │ +│ Spain │ 27 │ 0 │ +│ Sweden │ 126 │ 0 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 0 │ +│ United Kingdom │ 88 │ 0 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for San Marino (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 0 │ +│ Armenia │ 42 │ 0 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 0 │ +│ Estonia │ 98 │ 0 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 0 │ +│ Greece │ 105 │ 0 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 0 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 0 │ +│ Lithuania │ 34 │ 0 │ +│ Luxembourg │ 23 │ 0 │ +│ Malta │ 83 │ 0 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 0 │ +│ Poland │ 17 │ 0 │ +│ Portugal │ 37 │ 0 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 0 │ +│ Sweden │ 126 │ 0 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 0 │ +│ United Kingdom │ 88 │ 0 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Poland (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 0 │ +│ Armenia │ 42 │ 0 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 0 │ +│ Estonia │ 98 │ 0 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 0 │ +│ Greece │ 105 │ 0 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 0 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 0 │ +│ Lithuania │ 34 │ 0 │ +│ Luxembourg │ 23 │ 0 │ +│ Malta │ 83 │ 0 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 0 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 0 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 0 │ +│ Sweden │ 126 │ 0 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 0 │ +│ United Kingdom │ 88 │ 0 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Norway (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 0 │ +│ Armenia │ 42 │ 0 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 0 │ +│ Estonia │ 98 │ 0 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 0 │ +│ Greece │ 105 │ 0 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 0 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 0 │ +│ Lithuania │ 34 │ 0 │ +│ Luxembourg │ 23 │ 0 │ +│ Malta │ 83 │ 0 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 0 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 0 │ +│ Sweden │ 126 │ 0 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 0 │ +│ United Kingdom │ 88 │ 0 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Luxembourg (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 0 │ +│ Armenia │ 42 │ 0 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 0 │ +│ Estonia │ 98 │ 0 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 0 │ +│ Greece │ 105 │ 0 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 0 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 0 │ +│ Lithuania │ 34 │ 0 │ +│ Luxembourg │ 23 │ 24 │ +│ Malta │ 83 │ 0 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 0 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 0 │ +│ Sweden │ 126 │ 0 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 0 │ +│ United Kingdom │ 88 │ 0 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Spain (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 0 │ +│ Armenia │ 42 │ 0 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 0 │ +│ Estonia │ 98 │ 0 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 0 │ +│ Greece │ 105 │ 0 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 0 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 0 │ +│ Lithuania │ 34 │ 0 │ +│ Luxembourg │ 23 │ 24 │ +│ Malta │ 83 │ 0 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 0 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 10 │ +│ Sweden │ 126 │ 0 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 0 │ +│ United Kingdom │ 88 │ 0 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Lithuania (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 0 │ +│ Armenia │ 42 │ 0 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 0 │ +│ Estonia │ 98 │ 0 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 0 │ +│ Greece │ 105 │ 0 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 0 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 0 │ +│ Lithuania │ 34 │ 62 │ +│ Luxembourg │ 23 │ 24 │ +│ Malta │ 83 │ 0 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 0 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 10 │ +│ Sweden │ 126 │ 0 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 0 │ +│ United Kingdom │ 88 │ 0 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Portugal (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 0 │ +│ Armenia │ 42 │ 0 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 0 │ +│ Estonia │ 98 │ 0 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 0 │ +│ Greece │ 105 │ 0 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 0 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 0 │ +│ Lithuania │ 34 │ 62 │ +│ Luxembourg │ 23 │ 24 │ +│ Malta │ 83 │ 0 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 13 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 10 │ +│ Sweden │ 126 │ 0 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 0 │ +│ United Kingdom │ 88 │ 0 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Armenia (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 0 │ +│ Armenia │ 42 │ 30 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 0 │ +│ Estonia │ 98 │ 0 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 0 │ +│ Greece │ 105 │ 0 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 0 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 0 │ +│ Lithuania │ 34 │ 62 │ +│ Luxembourg │ 23 │ 24 │ +│ Malta │ 83 │ 0 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 13 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 10 │ +│ Sweden │ 126 │ 0 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 0 │ +│ United Kingdom │ 88 │ 0 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Albania (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 2 │ +│ Armenia │ 42 │ 30 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 0 │ +│ Estonia │ 98 │ 0 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 0 │ +│ Greece │ 105 │ 0 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 0 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 0 │ +│ Lithuania │ 34 │ 62 │ +│ Luxembourg │ 23 │ 24 │ +│ Malta │ 83 │ 0 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 13 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 10 │ +│ Sweden │ 126 │ 0 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 0 │ +│ United Kingdom │ 88 │ 0 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Denmark (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 2 │ +│ Armenia │ 42 │ 30 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 173 │ +│ Estonia │ 98 │ 0 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 0 │ +│ Greece │ 105 │ 0 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 0 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 0 │ +│ Lithuania │ 34 │ 62 │ +│ Luxembourg │ 23 │ 24 │ +│ Malta │ 83 │ 0 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 13 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 10 │ +│ Sweden │ 126 │ 0 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 0 │ +│ United Kingdom │ 88 │ 0 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Ukraine (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 2 │ +│ Armenia │ 42 │ 30 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 173 │ +│ Estonia │ 98 │ 0 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 0 │ +│ Greece │ 105 │ 0 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 0 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 0 │ +│ Lithuania │ 34 │ 62 │ +│ Luxembourg │ 23 │ 24 │ +│ Malta │ 83 │ 0 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 13 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 10 │ +│ Sweden │ 126 │ 0 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 297 │ +│ United Kingdom │ 88 │ 0 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Israel (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 2 │ +│ Armenia │ 42 │ 30 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 173 │ +│ Estonia │ 98 │ 0 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 0 │ +│ Greece │ 105 │ 0 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 158 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 0 │ +│ Lithuania │ 34 │ 62 │ +│ Luxembourg │ 23 │ 24 │ +│ Malta │ 83 │ 0 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 13 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 10 │ +│ Sweden │ 126 │ 0 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 297 │ +│ United Kingdom │ 88 │ 0 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Germany (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 2 │ +│ Armenia │ 42 │ 30 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 173 │ +│ Estonia │ 98 │ 0 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 74 │ +│ Greece │ 105 │ 0 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 158 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 0 │ +│ Lithuania │ 34 │ 62 │ +│ Luxembourg │ 23 │ 24 │ +│ Malta │ 83 │ 0 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 13 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 10 │ +│ Sweden │ 126 │ 0 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 297 │ +│ United Kingdom │ 88 │ 0 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Malta (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 2 │ +│ Armenia │ 42 │ 30 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 173 │ +│ Estonia │ 98 │ 0 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 74 │ +│ Greece │ 105 │ 0 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 158 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 0 │ +│ Lithuania │ 34 │ 62 │ +│ Luxembourg │ 23 │ 24 │ +│ Malta │ 83 │ 8 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 13 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 10 │ +│ Sweden │ 126 │ 0 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 297 │ +│ United Kingdom │ 88 │ 0 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for United Kingdom (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 2 │ +│ Armenia │ 42 │ 30 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 173 │ +│ Estonia │ 98 │ 0 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 74 │ +│ Greece │ 105 │ 0 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 158 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 0 │ +│ Lithuania │ 34 │ 62 │ +│ Luxembourg │ 23 │ 24 │ +│ Malta │ 83 │ 8 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 13 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 10 │ +│ Sweden │ 126 │ 0 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 297 │ +│ United Kingdom │ 88 │ 108 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Finland (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 2 │ +│ Armenia │ 42 │ 30 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 173 │ +│ Estonia │ 98 │ 0 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 74 │ +│ Greece │ 105 │ 0 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 158 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 0 │ +│ Lithuania │ 34 │ 62 │ +│ Luxembourg │ 23 │ 24 │ +│ Malta │ 83 │ 8 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 13 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 10 │ +│ Sweden │ 126 │ 0 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 297 │ +│ United Kingdom │ 88 │ 108 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Estonia (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 2 │ +│ Armenia │ 42 │ 30 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 173 │ +│ Estonia │ 98 │ 258 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 74 │ +│ Greece │ 105 │ 0 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 158 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 0 │ +│ Lithuania │ 34 │ 62 │ +│ Luxembourg │ 23 │ 24 │ +│ Malta │ 83 │ 8 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 13 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 10 │ +│ Sweden │ 126 │ 0 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 297 │ +│ United Kingdom │ 88 │ 108 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Greece (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 2 │ +│ Armenia │ 42 │ 30 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 173 │ +│ Estonia │ 98 │ 258 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 74 │ +│ Greece │ 105 │ 126 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 158 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 0 │ +│ Lithuania │ 34 │ 62 │ +│ Luxembourg │ 23 │ 24 │ +│ Malta │ 83 │ 8 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 13 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 10 │ +│ Sweden │ 126 │ 0 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 297 │ +│ United Kingdom │ 88 │ 108 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Latvia (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 2 │ +│ Armenia │ 42 │ 30 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 173 │ +│ Estonia │ 98 │ 258 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 74 │ +│ Greece │ 105 │ 126 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 158 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 42 │ +│ Lithuania │ 34 │ 62 │ +│ Luxembourg │ 23 │ 24 │ +│ Malta │ 83 │ 8 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 13 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 10 │ +│ Sweden │ 126 │ 0 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 297 │ +│ United Kingdom │ 88 │ 108 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Sweden (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 2 │ +│ Armenia │ 42 │ 30 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 173 │ +│ Estonia │ 98 │ 258 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 74 │ +│ Greece │ 105 │ 126 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 158 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 42 │ +│ Lithuania │ 34 │ 62 │ +│ Luxembourg │ 23 │ 24 │ +│ Malta │ 83 │ 8 │ +│ Netherlands │ 133 │ 0 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 13 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 10 │ +│ Sweden │ 126 │ 195 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 297 │ +│ United Kingdom │ 88 │ 108 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Netherlands (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 2 │ +│ Armenia │ 42 │ 30 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 173 │ +│ Estonia │ 98 │ 258 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 74 │ +│ Greece │ 105 │ 126 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 158 │ +│ Italy │ 159 │ 0 │ +│ Latvia │ 116 │ 42 │ +│ Lithuania │ 34 │ 62 │ +│ Luxembourg │ 23 │ 24 │ +│ Malta │ 83 │ 8 │ +│ Netherlands │ 133 │ 42 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 13 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 10 │ +│ Sweden │ 126 │ 195 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 297 │ +│ United Kingdom │ 88 │ 108 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Italy (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 2 │ +│ Armenia │ 42 │ 30 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 173 │ +│ Estonia │ 98 │ 258 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 0 │ +│ Germany │ 77 │ 74 │ +│ Greece │ 105 │ 126 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 158 │ +│ Italy │ 159 │ 97 │ +│ Latvia │ 116 │ 42 │ +│ Lithuania │ 34 │ 62 │ +│ Luxembourg │ 23 │ 24 │ +│ Malta │ 83 │ 8 │ +│ Netherlands │ 133 │ 42 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 13 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 10 │ +│ Sweden │ 126 │ 195 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 297 │ +│ United Kingdom │ 88 │ 108 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for France (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 2 │ +│ Armenia │ 42 │ 30 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 173 │ +│ Estonia │ 98 │ 258 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 50 │ +│ Germany │ 77 │ 74 │ +│ Greece │ 105 │ 126 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 158 │ +│ Italy │ 159 │ 97 │ +│ Latvia │ 116 │ 42 │ +│ Lithuania │ 34 │ 62 │ +│ Luxembourg │ 23 │ 24 │ +│ Malta │ 83 │ 8 │ +│ Netherlands │ 133 │ 42 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 13 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 10 │ +│ Sweden │ 126 │ 195 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 297 │ +│ United Kingdom │ 88 │ 108 │ +└────────────────┴────────────┴──────────────────┘ +Enter televoting score for Switzerland (go back with b): (0): Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ +│ Albania │ 45 │ 2 │ +│ Armenia │ 42 │ 30 │ +│ Austria │ 258 │ 0 │ +│ Denmark │ 45 │ 173 │ +│ Estonia │ 98 │ 258 │ +│ Finland │ 88 │ 0 │ +│ France │ 180 │ 50 │ +│ Germany │ 77 │ 74 │ +│ Greece │ 105 │ 126 │ +│ Iceland │ 0 │ 33 │ +│ Israel │ 60 │ 158 │ +│ Italy │ 159 │ 97 │ +│ Latvia │ 116 │ 42 │ +│ Lithuania │ 34 │ 62 │ +│ Luxembourg │ 23 │ 24 │ +│ Malta │ 83 │ 8 │ +│ Netherlands │ 133 │ 42 │ +│ Norway │ 22 │ 67 │ +│ Poland │ 17 │ 139 │ +│ Portugal │ 37 │ 13 │ +│ San Marino │ 9 │ 18 │ +│ Spain │ 27 │ 10 │ +│ Sweden │ 126 │ 195 │ +│ Switzerland │ 214 │ 0 │ +│ Ukraine │ 60 │ 297 │ +│ United Kingdom │ 88 │ 108 │ +└────────────────┴────────────┴──────────────────┘ +Final score entered! Review and continue? [y/n] (y): Please enter Y or N +Final score entered! Review and continue? [y/n] (y): Televoting scores have been successfully entered! +█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ Calculating final scores... Final Scores +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┓ +┃ Name ┃ Jury Score ┃ Televoting Score ┃ Final Score ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━┩ +│ Ukraine │ 60 │ 297 │ 357 │ +│ Estonia │ 98 │ 258 │ 356 │ +│ Sweden │ 126 │ 195 │ 321 │ +│ Italy │ 159 │ 97 │ 256 │ +│ Greece │ 105 │ 126 │ 231 │ +│ France │ 180 │ 50 │ 230 │ +│ Israel │ 60 │ 158 │ 218 │ +│ Denmark │ 45 │ 173 │ 218 │ +│ Switzerland │ 214 │ 0 │ 214 │ +│ United Kingdom │ 88 │ 108 │ 196 │ +│ Netherlands │ 133 │ 42 │ 175 │ +│ Latvia │ 116 │ 42 │ 158 │ +│ Poland │ 17 │ 139 │ 156 │ +│ Germany │ 77 │ 74 │ 151 │ +│ Lithuania │ 34 │ 62 │ 96 │ +│ Malta │ 83 │ 8 │ 91 │ +│ Norway │ 22 │ 67 │ 89 │ +│ Finland │ 88 │ 0 │ 88 │ +│ Armenia │ 42 │ 30 │ 72 │ +│ Portugal │ 37 │ 13 │ 50 │ +│ Albania │ 45 │ 2 │ 47 │ +│ Luxembourg │ 23 │ 24 │ 47 │ +│ Spain │ 27 │ 10 │ 37 │ +│ Iceland │ 0 │ 33 │ 33 │ +│ San Marino │ 9 │ 18 │ 27 │ +│ Austria │ 258 │ -460 │ -202 │ +└────────────────┴────────────┴──────────────────┴─────────────┘ +Final scores have been calculated! +╭──────────────────────────── Winner Announcement ─────────────────────────────╮ +│ This year's winner is: 🎉 Ukraine 🎉 │ +╰────────────────────────────── Congratulations! ──────────────────────────────╯ diff --git a/pyproject.toml b/pyproject.toml index 9ab38d4..d0b3cf0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,6 +5,7 @@ description = "Add your description here" readme = "README.md" requires-python = ">=3.12" dependencies = [ + "pytest>=8.4.0", "rich>=14.0.0", "typer>=0.16.0", ] diff --git a/src/__main__.py b/src/__main__.py index 3daf827..5a31928 100644 --- a/src/__main__.py +++ b/src/__main__.py @@ -43,7 +43,7 @@ def render_table_final(final_scores: dict[str, int], jury_data: dict[str, int], def sort_dict[A, B](d: dict[A, B], reverse: bool = True) -> dict[A, B]: """Sorts a dictionary by its values in descending order.""" - return dict(sorted(d.items(), key=lambda item: item[1], reverse=reverse)) # pyright: ignore [reportCallIssue, reportUnknownArgumentType, reportArgumentType] + return dict(sorted(d.items(), key=lambda item: item[1], reverse=reverse)) @app.command() def run(jury_path: Path = "jury.txt"): # pyright: ignore [reportArgumentType] @@ -51,6 +51,7 @@ def run(jury_path: Path = "jury.txt"): # pyright: ignore [reportArgumentType] if not jury_file.exists(): print(f"[red]File [bold]{jury_path}[bold/] does not exist.[/red]") raise typer.Exit(code=1) + print(f"Parsing jury file: [bold]{jury_file}[/bold]") console = Console() jury_scores = parse_jury_file(jury_file) @@ -59,13 +60,18 @@ def run(jury_path: Path = "jury.txt"): # pyright: ignore [reportArgumentType] televoting_data: dict[str, int] = {} table = render_table(jury_scores, televoting_data) console.print(table) - i = 0 - while i < (len(jury_scores) - 1): - name = list(jury_scores.keys())[i] + + # Collect N–1 televote scores + while len(televoting_data) < len(jury_scores) - 1: + name = list(jury_scores.keys())[len(televoting_data)] r: str = Prompt.ask(f"Enter televoting score for [bold]{name}[/bold] (go back with b):", default="0") if r.lower() == "b": - if i > 0: - i -= 1 + # back up one entry + if televoting_data: + last = list(televoting_data.keys())[-1] + del televoting_data[last] + console.clear() + console.print(render_table(jury_scores, televoting_data)) continue try: score: int = int(r) @@ -76,54 +82,56 @@ def run(jury_path: Path = "jury.txt"): # pyright: ignore [reportArgumentType] print(f"[red]Score for [bold]{name}[/bold] cannot be negative.[/red]") continue televoting_data[name] = score - i += 1 - table = render_table(jury_scores, televoting_data) console.clear() - console.print(table) - if i == (len(jury_scores) - 1): - c = Confirm.ask("Final score entered! Please review the scores. Do you want to continue?", default=True) - if not c: - i -= 1 - del televoting_data[name] - console.clear() - table = render_table(jury_scores, televoting_data) - console.print(table) - continue - console.clear() + console.print(render_table(jury_scores, televoting_data)) + # After N-1 entries, confirm before computing last + if len(televoting_data) == len(jury_scores) - 1: + if not Confirm.ask("Final score entered! Review and continue?", default=True): + # remove last entry if they want to re-enter + last = list(televoting_data.keys())[-1] + del televoting_data[last] + console.clear() + console.print(render_table(jury_scores, televoting_data)) + + console.clear() print("[green]Televoting scores have been successfully entered![/green]") + + # Dramatic pause spinner spinner = Spinner("material", text="Calculating final scores...") with Live(spinner, console=console, refresh_per_second=10): for _ in range(20): - time.sleep(0.1) # Our own dramatic pause :) + time.sleep(0.1) - televoting_scores_sum: int = sum(televoting_data.values()) - # We should be doing -1 below but it's being compensated by the "rest of the world" score - televoting_scores_total: int = sum((12, 10, 8, 7, 6, 5, 4, 3, 2, 1)) * len(jury_scores) + # Compute the 38×58 total and subtract the N-1 sum + total_available = sum((12, 10, 8, 7, 6, 5, 4, 3, 2, 1)) * (len(jury_scores) + 1) # N-1 televoting + 1 rest of the world + sum_entered = sum(televoting_data.values()) + missing = set(jury_scores) - set(televoting_data) + country_to_predict = missing.pop() + televoting_data[country_to_predict] = total_available - sum_entered - predicted_score = televoting_scores_total - televoting_scores_sum - country_to_predict = list(jury_scores.keys())[i] - - televoting_data[country_to_predict] = predicted_score + # Sort and compute finals televoting_data = sort_dict(televoting_data) jury_scores = sort_dict(jury_scores) - - final_scores: dict[str, int] = {} - - for name in jury_scores.keys(): - final_scores[name] = jury_scores[name] + televoting_data.get(name, 0) + final_scores: dict[str, int] = { + name: jury_scores[name] + televoting_data.get(name, 0) + for name in jury_scores + } final_scores = dict(sorted(final_scores.items(), key=lambda item: item[1], reverse=True)) + + # Render and announce final_table = render_table_final(final_scores, jury_scores, televoting_data) console.print(final_table) print("[green]Final scores have been calculated![/green]") panel = Panel( - f"[bold]This year's winner is: :tada: [red]{list(final_scores.keys())[0]} :tada:[/red][/bold]", + f"[bold]This year's winner is: :tada: [red]{next(iter(final_scores))} :tada:[/red][/bold]", title="Winner Announcement", subtitle="Congratulations!", style="green", ) console.print(panel) + if __name__ == "__main__": - app() \ No newline at end of file + app() diff --git a/tests/test_esc_2025.py b/tests/test_esc_2025.py new file mode 100644 index 0000000..f1fa13f --- /dev/null +++ b/tests/test_esc_2025.py @@ -0,0 +1,85 @@ +import os +import sys +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) + +import tempfile +from typer.testing import CliRunner +from src.__main__ import app + +# 2025 Eurovision Grand Final jury scores +JURY_SCORES = { + "Austria": 258, + "Switzerland": 214, + "France": 180, + "Italy": 159, + "Netherlands": 133, + "Sweden": 126, + "Latvia": 116, + "Greece": 105, + "Estonia": 98, + "United Kingdom": 88, + "Finland": 88, + "Malta": 83, + "Germany": 77, + "Ukraine": 60, + "Israel": 60, + "Albania": 45, + "Denmark": 45, + "Armenia": 42, + "Portugal": 37, + "Lithuania": 34, + "Spain": 27, + "Luxembourg": 23, + "Norway": 22, + "Poland": 17, + "San Marino": 9, + "Iceland": 0, +} + + +# 2025 Eurovision Grand Final televoting scores +TELEVOTE_SCORES = { + "Israel": 297, + "Estonia": 258, + "Sweden": 195, + "Austria": 178, + "Albania": 173, + "Ukraine": 158, + "Poland": 139, + "Greece": 126, + "Finland": 108, + "Italy": 97, + "Germany": 74, + "Norway": 67, + "Lithuania": 62, + "France": 50, + "Latvia": 42, + "Netherlands": 42, + "Iceland": 33, + "Armenia": 30, + "Luxembourg": 24, + "San Marino": 18, + "Portugal": 13, + "Spain": 10, + "Malta": 8, + "Denmark": 2, + "United Kingdom": 0, + "Switzerland": 0, +} + +RETURN = """ +╭──────────────────────────── Winner Announcement ─────────────────────────────╮ +│ This year's winner is: 🎉 Austria 🎉 │ +╰────────────────────────────── Congratulations! ──────────────────────────────╯ +""" + +def test_esc_2025(): + with tempfile.NamedTemporaryFile(delete=False, mode='w', encoding='utf-8') as jury_file: + jury_file.write("\n".join(f"{country} {score}" for country, score in JURY_SCORES.items())) + runner = CliRunner() + i: str = "" + for country in reversed(list(JURY_SCORES.keys())): + i += f"{TELEVOTE_SCORES[country]}\n" + i += "y\n" + result = runner.invoke(app, ["--jury-path", jury_file.name], input=i) + assert result.stdout.strip().endswith(RETURN), f"Expected output to end with {RETURN.strip()}, got {result.output.strip()}" diff --git a/uv.lock b/uv.lock index 7d62c8e..b490fea 100644 --- a/uv.lock +++ b/uv.lock @@ -40,6 +40,7 @@ name = "esc-drammatic-pause" version = "0.1.0" source = { virtual = "." } dependencies = [ + { name = "pytest" }, { name = "rich" }, { name = "typer" }, ] @@ -52,6 +53,7 @@ dev = [ [package.metadata] requires-dist = [ + { name = "pytest", specifier = ">=8.4.0" }, { name = "rich", specifier = ">=14.0.0" }, { name = "typer", specifier = ">=0.16.0" }, ] @@ -62,6 +64,15 @@ dev = [ { name = "ruff", specifier = ">=0.11.13" }, ] +[[package]] +name = "iniconfig" +version = "2.1.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f2/97/ebf4da567aa6827c909642694d71c9fcf53e5b504f2d96afea02718862f3/iniconfig-2.1.0.tar.gz", hash = "sha256:3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7", size = 4793 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2c/e1/e6716421ea10d38022b952c159d5161ca1193197fb744506875fbb87ea7b/iniconfig-2.1.0-py3-none-any.whl", hash = "sha256:9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760", size = 6050 }, +] + [[package]] name = "markdown-it-py" version = "3.0.0" @@ -99,6 +110,24 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/91/03/a852711aec73dfb965844592dfe226024c0da28e37d1ee54083342e38f57/nodejs_wheel_binaries-22.16.0-py2.py3-none-win_arm64.whl", hash = "sha256:2728972d336d436d39ee45988978d8b5d963509e06f063e80fe41b203ee80b28", size = 38828154 }, ] +[[package]] +name = "packaging" +version = "25.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a1/d4/1fc4078c65507b51b96ca8f8c3ba19e6a61c8253c72794544580a7b6c24d/packaging-25.0.tar.gz", hash = "sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f", size = 165727 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/20/12/38679034af332785aac8774540895e234f4d07f7545804097de4b666afd8/packaging-25.0-py3-none-any.whl", hash = "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484", size = 66469 }, +] + +[[package]] +name = "pluggy" +version = "1.6.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f9/e2/3e91f31a7d2b083fe6ef3fa267035b518369d9511ffab804f839851d2779/pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3", size = 69412 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", size = 20538 }, +] + [[package]] name = "pygments" version = "2.19.1" @@ -108,6 +137,22 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/8a/0b/9fcc47d19c48b59121088dd6da2488a49d5f72dacf8262e2790a1d2c7d15/pygments-2.19.1-py3-none-any.whl", hash = "sha256:9ea1544ad55cecf4b8242fab6dd35a93bbce657034b0611ee383099054ab6d8c", size = 1225293 }, ] +[[package]] +name = "pytest" +version = "8.4.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "iniconfig" }, + { name = "packaging" }, + { name = "pluggy" }, + { name = "pygments" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/fb/aa/405082ce2749be5398045152251ac69c0f3578c7077efc53431303af97ce/pytest-8.4.0.tar.gz", hash = "sha256:14d920b48472ea0dbf68e45b96cd1ffda4705f33307dcc86c676c1b5104838a6", size = 1515232 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2f/de/afa024cbe022b1b318a3d224125aa24939e99b4ff6f22e0ba639a2eaee47/pytest-8.4.0-py3-none-any.whl", hash = "sha256:f40f825768ad76c0977cbacdf1fd37c6f7a468e460ea6a0636078f8972d4517e", size = 363797 }, +] + [[package]] name = "rich" version = "14.0.0"