forked from conda/schemas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-index.py
102 lines (96 loc) · 2 KB
/
generate-index.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2020 Anaconda, Inc
import os
from os.path import dirname, join
import sys
from jinja2 import Template
_TEMPLATE = """\
<html>
<head>
<title>Conda Schemas</title>
<style type="text/css">
a, a:active {
text-decoration: none; color: blue;
}
a:visited {
color: #48468F;
}
a:hover, a:focus {
text-decoration: underline; color: red;
}
body {
background-color: #F5F5F5;
}
h2 {
margin-bottom: 12px;
}
th, td {
font: 100% monospace; text-align: left;
}
th {
font-weight: bold; padding-right: 14px; padding-bottom: 3px;
}
th.tight {
padding-right: 6px;
}
td {
padding-right: 14px;
}
td.tight {
padding-right: 8px;
}
td.s, th.s {
text-align: right;
}
td.summary {
white-space: nowrap;
overflow: hidden;
}
td.packagename {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
max-width: 180px;
padding-right: 8px;
}
td.version {
//white-space: nowrap;
overflow: hidden;
max-width: 90px;
padding-right: 8px;
}
table {
background-color: white;
border-top: 1px solid #646464;
border-bottom: 1px solid #646464;
padding-top: 10px;
padding-bottom: 14px;
}
address {
color: #787878;
padding-top: 10px;
}
</style>
</head>
<body>
<h2>Conda Schemas</h2>
{% for subdir in subdirs %}<a href="{{ subdir }}">{{ subdir }}</a> {% endfor %}
<table>
<tr>
<th>File</th>
</tr>
{% for fn in files %}
<tr>
<td><a href="{{ fn }}">{{ fn }}</a></td>
</tr>
{%- endfor %}
</table>
</body>
</html>
"""
files=sorted(p for p in os.listdir(".") if p.endswith(".schema.json"))
rendered = Template(_TEMPLATE).render(files=files)
print(rendered, file=sys.stderr)
with open(join(dirname(__file__), "index.html"), "w") as fh:
fh.write(rendered)