-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.py
65 lines (55 loc) · 2.14 KB
/
script.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
55
56
57
58
59
60
61
62
63
64
import json
from jinja2 import Template
def main():
with open("resume.json", 'r') as resume:
data = json.load(resume)
basics_raw = data["basics"]
work_raw = data["work"]
volunteer_raw = data["volunteer"]
education_raw = data["education"]
awards_raw = data["awards"]
skills_raw = data["skills"]
basics_arr = basics_raw
work_arr = generate_items(work_raw)
volunteer_arr = generate_items(volunteer_raw)
education_arr = education_raw
awards_arr = awards_raw
skills_arr = skills_raw
github = next(item["username"] for item in basics_arr["profiles"] if item["network"].lower() == "github")
template_string = open("src/template.html", 'r').read()
template = Template(template_string)
render = template.render(basics_arr=basics_arr,
work_arr=work_arr,
volun_arr=volunteer_arr,
edu_arr=education_arr,
award_arr=awards_arr,
skill_arr=skills_arr,
github=github)
with open("index.html", 'w') as out:
out.write(render)
def generate_items(raw):
"""
generates a dict of items to give the template from a raw JSON Resume work/volunteer item
"""
section_list = list()
for raw_item in raw:
tmp_list_item = dict()
try:
tmp_list_item["company"] = raw_item["company"]
except KeyError:
tmp_list_item["company"] = raw_item["organization"]
tmp_list_item["startDate"] = raw_item["startDate"]
try:
tmp_list_item["endDate"] = raw_item["endDate"]
except KeyError:
tmp_list_item["endDate"] = "present"
tmp_list_item["position"] = raw_item["position"]
tmp_list_item["website"] = raw_item["website"]
tmp_list_item["details"] = list()
tmp_list_item["details"].append(raw_item["summary"])
for highlight in raw_item["highlights"]:
tmp_list_item["details"].append(highlight)
section_list.append(tmp_list_item)
return section_list
if __name__ == "__main__":
main()