-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.py
More file actions
25 lines (19 loc) · 1019 Bytes
/
index.py
File metadata and controls
25 lines (19 loc) · 1019 Bytes
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
from os import listdir
from os.path import isfile, join, exists
import json
search_attributes = keys = ['id','GPCatalogPath','ShortTitle','CoverImage','PublicationStatus','ReleaseDate', 'LastUpdated', 'FirstPublicationDate', 'Title', 'Subtitle', 'SponsoredBy', 'Tags','Description','Standards','Section']
lessons = [f for f in listdir('./lessons') if not isfile(join('./lessons/', f)) and f[0] != "."]
index = []
assert len(lessons)!= 0, 'No lessons found...'
for lesson in lessons:
json_path = './lessons/' + lesson + '/LESSON.json'
if exists(json_path):
with open(json_path) as file:
lesson_json = json.load(file)
#filtered_attributes = [x for x in search_attributes if x in lesson_json.keys()]
#search_terms = {attribute: lesson_json[attribute] for attribute in filtered_attributes}
index += [lesson_json]
else:
print("No LESSON.json found...")
with open('index.json', 'w') as json_file:
json.dump(index, json_file, indent=2)