-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_html_page.py
34 lines (27 loc) · 967 Bytes
/
generate_html_page.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
#%%
from pathlib import Path
def find_repo(path):
"Find repository root from the path's parents"
for path in Path(path).parents:
# Check whether "path/.git" exists and is a directory
git_dir = path / ".git"
if git_dir.is_dir():
return path
# To create html table from data and write to filename
def write_to_html2(target_folder, filename, sorted_list):
table = "<table>\n"
# Create the table's column headers
header = ['Title', 'Score', 'Author', 'Views', 'Likes']
table += " <tr>\n"
for column in header:
table += " <th>{0}</th>\n".format(column.strip())
table += " </tr>\n"
# Create the table's row data
for row in sorted_list:
table += " <tr>\n"
for column in row:
table += " <td>{0}</td>\n".format(column)
table += " </tr>\n"
table += "</table>"
with open(target_folder+filename, "w") as f:
f.writelines(table)