-
Notifications
You must be signed in to change notification settings - Fork 3
/
utils.py
54 lines (36 loc) · 1.2 KB
/
utils.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
import os
import json
from datetime import datetime
def read_json_file(path):
with open(path) as json_file:
data = json.load(json_file)
return data
def get_news(lang='sk', items=None):
news = []
counter = 0
for item in read_json_file(os.path.join('data', 'news.json')):
counter += 1
data = {
"date": datetime.strptime(item['date'], '%Y-%m-%d').date(),
"categories": item['categories']
}
if lang == "sk":
data["title"] = item['title_sk']
data["meta"] = item['meta_sk']
if lang == "en":
data["title"] = item['title_en']
data["meta"] = item['meta_en']
if 'url' in item.keys():
data['url'] = item['url']
news.append(data)
if items and counter >= items:
break
return news
def get_speakers():
return read_json_file(os.path.join('data', 'speakers.json'))
def get_talks():
return read_json_file(os.path.join('data', 'talks.json'))
def get_edu_speakers():
return read_json_file(os.path.join('data', 'edusummit_speakers.json'))
def get_edu_talks():
return read_json_file(os.path.join('data', 'edusummit_talks.json'))