-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexportJsonMetadata.py
46 lines (29 loc) · 1.15 KB
/
exportJsonMetadata.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
"""This script creates a JSON release of the AFP's metadata"""
import os
import json
from typing import Set
from writeFile import writeFile
def exportJsonMetadata():
"""Iterates over each entry and builds the output list"""
inputDir = "hugo/content/entries/"
outputFile = "hugo/static/release/metadata.json"
data = []
for entry in os.listdir(inputDir):
entryPath = os.path.join(inputDir, entry)
if entry != "Example-Submission.md":
data.append(processEntry(entryPath, entry))
writeFile(outputFile, data, overwrite=True)
def processEntry(entryPath, entry):
"""Removes the emails and related entries and returns the dictionary"""
fileExists = os.path.isfile(entryPath)
entryData = {"session": entry[:-3]}
if fileExists:
with open(entryPath) as r:
entryData = {**entryData, **json.load(r)}
# remove notify emails
entryData.pop("notify", None)
# remove related entries as they are not from the original data
entryData.pop("relatedEntries", None)
return entryData
if __name__ == "__main__":
exportJsonMetadata()