-
Notifications
You must be signed in to change notification settings - Fork 1
/
fdroid_html_builder.py
81 lines (73 loc) · 1.94 KB
/
fdroid_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 string import Template
from datetime import datetime
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",
"repository_forks_count": "Int64",
}
)
df = df.fillna(
{
# "repository_forks_count": 0,
# "repository_stars_count": 0,
"repository": "",
"repository_domain": "",
"summary": "",
}
)
header = (
"<thead>\n"
"<tr>\n"
"<th>Name</th>\n"
"<th>Repository</th>\n"
"<th>Repository Stars Count</th>\n"
"<th>Repository Forks Count</th>\n"
"<th>Repository Domain</th>\n"
"<th>Summary</th>\n"
"<th>Categories</th>\n"
"<th>Added</th>\n"
"<th>Last Updated</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"<img loading='lazy' width='30' src='{row['icon']}' alt=''/>"
"\n"
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_forks_count']}</td>"
"\n"
f"<td>{row['repository_domain']}</td>"
"\n"
f"<td>{row['summary']}</td>"
"\n"
f"<td>{row['categories']}</td>"
"\n"
f"<td>{row['added']}</td>"
"\n"
f"<td>{row['last_updated']}</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)