-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.py
39 lines (27 loc) · 989 Bytes
/
utils.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
def join_with_br(l):
return "<br>".join(l)
def _get_table_row_bgcolor(ct):
if ct % 2 == 0:
return "#FFFFFF"
else:
return "#FFF8DC"
def get_html_table(list_of_columnes):
col_width = 100 // len(list_of_columnes)
rows = [f'</td> <td width="{col_width}%">'.join(x) for x in zip(*list_of_columnes)]
rows = [f'<td width="{col_width}%"> {r} </td>' for r in rows]
columns = [
f'<tr bgcolor="{_get_table_row_bgcolor(ct)}">{row}</tr>'
for ct, row in enumerate(rows)
]
columns = " ".join(columns)
return f"<table>{columns}</table>"
def pad_list(input_list, target_length):
input_length = len(input_list)
assert target_length >= input_length, "target length should be longer than input"
if input_length == target_length:
return input_list
return input_list + [""] * (target_length - input_length)
class NoExplanationException(Exception):
pass
class NoExampleException(Exception):
pass