-
Notifications
You must be signed in to change notification settings - Fork 6
/
lotterycars.py
54 lines (47 loc) · 1.29 KB
/
lotterycars.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from db import *
html = ""
with open("lottery-cars.html", "r", encoding='utf-8') as f:
html = f.read()
lines = []
with open(f"_data/db/lotterycars.csv") as f:
lines = f.readlines()
lines = lines[1:] # remove headers
cars_s = []
cars_m = []
cars_l = []
cars_b = []
for lotterycar in lines:
lotterycarsplit = lotterycar.strip().split(",")
cars = []
match lotterycarsplit[0]:
case "L":
cars = cars_l
case "M":
cars = cars_m
case "S":
cars = cars_s
case "B":
cars = cars_b
cars.append(f"{cardb_id_to_makername(lotterycarsplit[1])} {cardb_id_to_name(lotterycarsplit[1])}")
cars_s = sorted(cars_s)
cars_m = sorted(cars_m)
cars_l = sorted(cars_l)
cars_b = sorted(cars_b)
section_s = ""
for car in cars_s:
section_s += f"<li>{car}</li>\n"
section_m = ""
for car in cars_m:
section_m += f"<li>{car}</li>\n"
section_l = ""
for car in cars_l:
section_l += f"<li>{car}</li>\n"
section_b = ""
for car in cars_b:
section_b += f"<li>{car}</li>\n"
html = html.replace("%LOTTERY_CAR_S", section_s)
html = html.replace("%LOTTERY_CAR_M", section_m)
html = html.replace("%LOTTERY_CAR_L", section_l)
html = html.replace("%LOTTERY_CAR_B", section_b)
with open("build/lottery-cars.html", "w") as f:
f.write(html)