This repository has been archived by the owner on Sep 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exporter.py
132 lines (120 loc) · 3.93 KB
/
exporter.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
def html_wrapper(content):
css = """#wrapper {
padding:0px;
width:900px;
max-width: 100%;
margin: 0 auto;
border:1px solid #000000;
-moz-border-radius-bottomleft:0px;
-webkit-border-bottom-left-radius:0px;
border-bottom-left-radius:0px;
-moz-border-radius-bottomright:0px;
-webkit-border-bottom-right-radius:0px;
border-bottom-right-radius:0px;
-moz-border-radius-topright:0px;
-webkit-border-top-right-radius:0px;
border-top-right-radius:0px;
-moz-border-radius-topleft:0px;
-webkit-border-top-left-radius:0px;
border-top-left-radius:0px;
}
#wrapper table{
border-collapse: collapse;
border-spacing: 0;
width:100%;
margin:0px;padding:0px;
}
#wrapper tr:last-child td:last-child {
-moz-border-radius-bottomright:0px;
-webkit-border-bottom-right-radius:0px;
border-bottom-right-radius:0px;
}
#wrapper table tr th {
-moz-border-radius-topleft:0px;
-webkit-border-top-left-radius:0px;
border-top-left-radius:0px;
}
#wrapper table tr:first-child td:last-child {
-moz-border-radius-topright:0px;
-webkit-border-top-right-radius:0px;
border-top-right-radius:0px;
}
#wrapper tr th {
-moz-border-radius-bottomleft:0px;
-webkit-border-bottom-left-radius:0px;
border-bottom-left-radius:0px;
}
#wrapper tr:hover td{
}
#wrapper tr:nth-child(even){ background-color:#e5e5e5; }
#wrapper tr:nth-child(odd){ background-color:#b2b2b2; }
#wrapper td{
vertical-align:middle;
border:1px solid #000000;
border-width:0px 1px 1px 0px;
text-align:left;
padding:7px;
font-size:14px;
font-family:Arial;
font-weight:normal;
color:#000000;
}
#wrapper tr:last-child td{
border-width:0px 1px 1px 0px;
}
#wrapper tr td:last-child{
border-width:0px 0px 1px 0px;
}
#wrapper tr:last-child td:last-child{
border-width:0px 0px 1px 0px;
}
#wrapper tr th{
background:-o-linear-gradient(bottom, #7f7f7f 5%, #cccccc 100%); background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #7f7f7f), color-stop(1, #cccccc) );
background:-moz-linear-gradient( center top, #7f7f7f 5%, #cccccc 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#7f7f7f", endColorstr="#cccccc"); background: -o-linear-gradient(top,#7f7f7f,cccccc);
padding: 4px 0px;
background-color:#7f7f7f;
border:0px solid #000000;
text-align:center;
border-width:1px 1px 1px 1px;
font-size:18px;
font-family:Arial;
font-weight:bold;
color:#000000;
}
#wrapper tr:hover th {
background:-o-linear-gradient(bottom, #7f7f7f 5%, #cccccc 100%); background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #7f7f7f), color-stop(1, #cccccc) );
background:-moz-linear-gradient( center top, #7f7f7f 5%, #cccccc 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#7f7f7f", endColorstr="#cccccc"); background: -o-linear-gradient(top,#7f7f7f,cccccc);
background-color:#7f7f7f;
}
#wrapper tr th:first-child{
border-width:1px 0px 1px 0px;
}
#wrapper tr th:last-child{
border-width:1px 0px 1px 1px;
}
#caption {
padding: 10px 5px;
}
.clear {
clear: both;
}
"""
return '<html><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><style>'+ css +'</style></head><body><div id="wrapper">'+content+'</div></body></html'
def html_table(headers = [], rows = [], caption = ''):
return '<table>'+html_header(headers)+html_body(rows)+'</table>'+html_caption(caption)
def html_header(headers):
return '<thead><tr>'+''.join(map(lambda h: '<th>'+h+'</th>',headers))+'</tr></thead>'
def html_body(rows):
html = '<tbody>'
for values in rows:
html += '<tr>'+''.join(map(lambda td: "<td>" + td + "</td>", values))+'</tr>'
return html+'</tbody>'
def html_caption(caption):
if caption:
return '<div id="caption">'+caption+'</div>'
else:
return ''
def string_to_csv_filename(s):
return s.lower().replace('"','').replace(" ",'_')