forked from OpenMDAO/OpenMDAO-Framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkdlversionindex.py
68 lines (59 loc) · 2.1 KB
/
mkdlversionindex.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
"""
This creates an index.html file for a version downloads dir on
the openmdao.org site.
"""
import sys
import os.path
import hashlib
def file_md5(fpath):
"""Return the MD5 digest for the given file"""
with open(fpath,'rb') as f:
m = hashlib.md5()
while True:
s = f.read(4096)
if not s:
break
m.update(s)
return m.hexdigest()
def make_index():
startdir = os.path.abspath(os.path.dirname(__file__))
out = open('index.html', 'w')
version = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
out.write('<html>\n\n')
out.write('<head>\n')
out.write(' <title>OpenMDAO Version %s Downloads</title>\n' % version)
out.write(' <link rel="stylesheet" href="/chrome/common/css/trac.css" type="text/css" />\n')
out.write(' <div id="header">\n')
out.write(' <a id="logo" href="http://openmdao.org/">\n')
out.write(' <img src="/chrome/site/Feb2010_OpenMDAOLogo.png" alt="OpenMDAO Logo" height="93" width="334" />\n')
out.write(' </a>\n')
out.write(' </div>\n')
out.write('</head>\n\n')
out.write('<body>\n')
out.write(' <br><br><br>\n')
out.write(' <h1 class="blog-title" id="openmdao">\n')
out.write(' OpenMDAO Version %s Downloads\n' % version)
out.write(' </h1>\n')
out.write(' <ul>\n')
out.write(' <li><a href="..">..</a>\n')
files = []
dirs = []
for f in os.listdir(startdir):
if f in ['index.html', 'mkdlversionindex.py'] or f.startswith('openmdao_src'):
continue
if os.path.isfile(f):
files.append(f)
else:
dirs.append(f)
for d in dirs:
#lpath = os.path.join(url, 'downloads', version, d)
out.write(' <li><a href="%s">%s</a>\n' % (d, d))
for f in files:
#lpath = os.path.join(url, 'downloads', version, f)
checksum = file_md5(f)
out.write(' <li><a href="%s#md5=%s">%s</a>\n'%(f, checksum, f))
out.write(' </ul>\n')
out.write('</body>\n</html>')
out.close()
if __name__ == '__main__':
make_index()