-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.py
executable file
·117 lines (103 loc) · 4.22 KB
/
generate.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env python
from __future__ import print_function
import csv
temp = open("template.html").read()
temp_people = open("people.html").read()
temp_alumni = open("alumni.html").read()
temp_papers = open("papers.html").read()
temp_jobs = open("jobs.html").read()
temp_tools = open("tools.html").read()
temp_news = open("news.html").read()
temp_research = open("research.html").read()
authors = {}
people = ""
lalumni = "<ul>"
ix = 0;
for i in csv.reader(open("people.csv"), delimiter=";"):
authors[i[6]] = i
if i[1] != "Alumni":
nln=""
nn=i[7].strip()
if nn!="" and nn!="\n":
nln="("+i[7]+")<br>"
else:
nln="<br>"
people += temp_people.format(name=i[0], title=i[1], description=i[2], imgsrc="imgs/" + i[3], imgalt=i[4],
email=i[5], native_language_name=nln)
ix += 1
else:
lalumni += "<li>" + i[0]
people += temp_alumni.format(alumni=lalumni + "</ul>")
def makeup_author(s):
sp = s.split(", ")
nl = []
for i in sp:
if i in authors:
nl.append("<span class='author' onmouseover='author_image=\"imgs/" + authors[i][
3] + "\";'><b><u>" + i + "</u></b></span>")
else:
nl.append(i)
return ", ".join(nl)
paper_free_links_title = {}
paper_free_links_id = {}
for i in csv.reader(open("paper_free_links.csv"), delimiter="|"):
if len(i)>2:
if i[0]!="":
paper_free_links_title[i[0]]=i[2]
if i[1]!="":
paper_free_links_id[i[1]]=i[2]
papers = "";
pix = 0;
py = ""
papercount = 0
for i in csv.reader(open("papers.csv"), delimiter="|"):
papercount += 1
for i in csv.reader(open("papers.csv"), delimiter="|"):
if py != i[3]:
if py != "":
papers += " </table><br>"
papers += " <b>" + i[3] + "</b><br>\n <table class='papertable'>\n"
img1, img2, img3 = "", "", ""
if i[5] != "":
img1 = "<a href='" + i[5] + "'><img class='paperimg' src='" + i[6] + "'/></a>"
if i[7] != "":
img2 = "<a href='" + i[7] + "'><img class='paperimg' src='" + i[8] + "'/></a>"
if i[0] in paper_free_links_title:
img3 = "<a href='" + paper_free_links_title[i[0]] + "'><img class='paperimg' src='imgs/link.png'/></a>"
papers += temp_papers.format(title=i[0], authors=makeup_author(i[1]), journal=i[2], year=i[3], ref=i[4], img1=img1,
img2=img2, img3=img3, index=str(papercount))
papercount -= 1
pix += 1
py = i[3]
papers += " </table>"
research = " <div class='research-div'>\n";
for i in csv.reader(open("research.csv"), delimiter=";"):
research += temp_research.format(title=i[0], description=i[1], img="imgs/" + i[2])
research += " </div>"
tools = " <div class='w3-row'>";
for i in csv.reader(open("tools.csv"), delimiter=";"):
tools += temp_tools.format(card='<div class="github-card" data-github="' + i[
1] + '" data-width="100%" data-height="200" data-theme="default"></div>')
tools += "</div>"
tools += '<script src="//cdn.jsdelivr.net/github-cards/latest/widget.js"></script>\n'
news_archive="<ul>"
news = " <div class='w3-row'>";
pix = 0
for i in csv.reader(open("news.csv"), delimiter=";"):
link, img = "", ""
if (i[1] != ""):
link = "<b>More: </b><a href='" + i[1] + "'>" + i[1] + "</a>"
if (i[2] != ""):
img = "<img src='" + i[2] + "' class='w3-center' style='width:90%;'>"
if pix < 4:
news += temp_news.format(title=i[0], link=link, img=img, subtitle=i[3], footer=i[4], description=i[5])
news_archive += "<li><b>{title}</b><br><i>{subtitle}</i><br> {description}<br>{img} {link}<br> {footer} <br><br>".format(
title=i[0], link=link, img=img, subtitle=i[3], footer=i[4], description=i[5])
pix += 1
news += "</div>"
import functools
gp = next(csv.reader(open("group_photos.csv"), delimiter="|"))
gpa = "["+functools.reduce(str.__add__,map(lambda s:"'"+s+"', ",gp),"")[:-2]+"]"
print(temp.replace("{{people}}", people).replace("{{papers}}", papers).replace("{{positions}}", temp_jobs).replace(
"{{research}}", research).replace("{{news}}", news).replace("{{tools}}", tools).replace("{{news_archive}}",news_archive)
.replace("{{group_photos_array}}",gpa))