summaryrefslogtreecommitdiff
path: root/compile.py
diff options
context:
space:
mode:
Diffstat (limited to 'compile.py')
-rw-r--r--compile.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/compile.py b/compile.py
index cb421b5..01efeba 100644
--- a/compile.py
+++ b/compile.py
@@ -1,4 +1,5 @@
import json
+import os
import sys
compiled = []
@@ -7,23 +8,25 @@ for json_file in sys.argv[1:]:
jfile = json.load(open(json_file))
for beer in jfile:
year = 2000 + beer['added'][2]
- month = beer['added'][0]
- brewery = json_file.split('.')[0]
- name = beer['name']
- style = beer['style']
abv = beer['abv']
ratings = beer['ratings']
av_rating = beer['rating']
- if (ratings >= 15) and (av_rating is not None) and (abv is not None):
+ if (ratings >= 15) and (av_rating is not None) and (abv is not None) and (year < 2021):
compiled.append({
- 'year': year,
- 'month': month,
- 'brewery': brewery,
- 'name': name,
- 'style': style,
+ 'added': {
+ 'year': year,
+ 'month': beer['added'][0],
+ 'day': beer['added'][1],
+ },
+ 'brewery': os.path.basename(json_file).split('.')[0],
+ 'name': beer['name'],
+ 'style': beer['style'],
'abv': abv,
- 'ratings': ratings,
- 'average': av_rating
+ 'ratings': {
+ 'count': ratings,
+ 'average': av_rating
+ },
+ 'in_production': beer['in_production']
})
print(json.dumps(compiled))