-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_archive.py
More file actions
50 lines (42 loc) · 1.88 KB
/
make_archive.py
File metadata and controls
50 lines (42 loc) · 1.88 KB
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
def make_archive(years):
res = '<ul class="list-group">'
files = [f for f in os.listdir('./app/static/archive/' + years) if (f.endswith("pdf"))]
getTex = lambda x: x[:-3] + 'tex'
for f in files:
res += '<li class="list-group-item list-group-item-primary">'
res += '<a href="/archive/' + years + '/' + f + '">'
res += f[3:-4] + '</a>' +'(<a href="/archive/' + years + '/' + getTex(f) + '">' + 'tex'+ '</a>)' + '</li>\n'
res += '</ul>'
with open('./app/templates/archive' + years+ ".html", 'w', encoding="utf-8") as f:
f.write(res)
def make_archive2(years):
res = '<table class="table">\n <tbody>'
files = [f for f in os.listdir('./app/static/archive/' + years) if (f.endswith("pdf"))]
countRows = int((len(files) + 2) / 3)
getTex = lambda x: x[:-3] + 'tex'
for row in range(countRows):
res += "\n<tr>"
for i in range(3):
if row + i * countRows >= len(files):
res += "\n<td>\n"
res += "\n</td>\n"
continue
f = files[row + i * countRows]
res += "\n<td>\n"
res += '<a href="/archive/' + years + '/' + f + '">'
res += f[:-4] + '</a>' + '(<a href="/archive/' + years + '/' + getTex(
f) + '">' + 'tex' + '</a>)' + '\n'
res+= "\n</td>\n"
res += "\n</tr>"
#
# for count, f in enumerate(files):
# res += '<li class="list-group-item list-group-item-primary">'
# res += '<a href="/archive/' + years + '/' + f + '">'
# res += f[3:-4] + '</a>' +'(<a href="/archive/' + years + '/' + getTex(f) + '">' + 'tex'+ '</a>)' + '</li>\n'
res += ' </tbody>\n</table>'
with open('./app/templates/archive' + years+ ".html", 'w', encoding="utf-8") as f:
f.write(res)
make_archive2("2018-2019")