-
Notifications
You must be signed in to change notification settings - Fork 1
/
lpa_html_builder.py
81 lines (72 loc) · 1.88 KB
/
lpa_html_builder.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
from datetime import datetime
from string import Template
import pandas as pd
def read_template(file: str) -> Template:
with open(file, "r") as f:
content = f.read()
return Template(content)
df = pd.read_csv("export.csv")
df = df.astype(
{
"repository_stars_count": "Int64",
}
)
df = df.fillna(
{
"repository_domain": "",
"description": "",
"repository_last_update": "",
"distribution": "",
}
)
header = (
"<thead>\n"
"<tr>\n"
"<th>Name</th>\n"
"<th>Repository</th>\n"
"<th>Repository Stars Count</th>\n"
"<th>Repository Last Update</th>\n"
"<th>Repository Domain</th>\n"
"<th>Categories</th>\n"
"<th>Compatibility</th>\n"
"<th>Frameworks</th>\n"
"<th>Distribution</th>\n"
"<th>Description</th>\n"
"</tr>\n"
"</thead>\n"
)
table_data = "<tbody>\n"
for index, row in df.iterrows():
name = f"<a href='{row['url']}'>{row['name']}</a></td>"
table_data += (
"<tr>\n"
"<td>"
f"{name}"
"\n"
f"<td><a href='{row['repository']}'>{row['repository']}</a></td>"
"\n"
f"<td>{row['repository_stars_count']}</td>"
"\n"
f"<td>{row['repository_last_update']}</td>"
"\n"
f"<td>{row['repository_domain']}</td>"
"\n"
f"<td>{row['categories']}</td>"
"\n"
f"<td>{row['compatibility']}</td>"
"\n"
f"<td>{row['frameworks']}</td>"
"\n"
f"<td>{row['distribution']}</td>"
"\n"
f"<td>{row['description']}</td>"
"\n"
"</tr>\n"
)
table_data += "</tbody>\n"
date_update = datetime.today().strftime("%Y-%m-%d")
formatted_message = read_template("template.html").safe_substitute(
{"date_update": date_update, "header": header, "table_data": table_data}
)
with open("docs/index.html", "w") as f:
f.write(formatted_message)