-
Notifications
You must be signed in to change notification settings - Fork 0
/
generator.py
45 lines (35 loc) · 1.03 KB
/
generator.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
import json
from taxes import EnergySource, calculate_tax
YEARS = range(2015, 2025)
FUEL_TYPE = EnergySource.BENZINE
CAR_WEIGHTS = range(500, 3300, 100)
PROVINCES = [
"drenthe",
# "flevoland",
# "friesland",
# "gelderland",
# "groningen",
# "limburg",
# "noord-brabant",
# "noord-holland",
# "overijssel",
# "utrecht",
# "zeeland",
# "zuid-holland"
]
class AutoVivification(dict):
"""Implementation of perl's autovivification feature."""
def __getitem__(self, item):
try:
return dict.__getitem__(self, item)
except KeyError:
value = self[item] = type(self)()
return value
results = AutoVivification()
for province in PROVINCES:
for weight_class in CAR_WEIGHTS:
for year in YEARS:
tax = calculate_tax(FUEL_TYPE, weight_class, province, year)
results[province][str(weight_class)][str(year)] = tax
with open("output/drenthe_benzine.json", "w") as convert_file:
convert_file.write(json.dumps(results))