-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_table.py
More file actions
66 lines (57 loc) · 1.94 KB
/
generate_table.py
File metadata and controls
66 lines (57 loc) · 1.94 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
import json
import os
# Load data
with open('mediatypes.json', 'r') as f:
data = json.load(f)
formats = data['formats']
# Generate HTML
html = f"""<!DOCTYPE html>
<html>
<head>
<title>Neuroimaging File Formats</title>
<style>
body {{ font-family: Arial, sans-serif; margin: 20px; }}
table {{ border-collapse: collapse; width: 100%; }}
th, td {{ border: 1px solid #ddd; padding: 8px; text-align: left; }}
th {{ background-color: #f2f2f2; }}
.ext {{ font-family: monospace; background: #f8f8f8; padding: 2px 4px; margin: 1px; display: inline-block; }}
.standard {{ color: green; font-weight: bold; }}
.proprietary {{ color: red; font-weight: bold; }}
</style>
</head>
<body>
<h1>Neuroimaging File Formats ({len(formats)} formats)</h1>
<table>
<tr>
<th>Format</th>
<th>Extensions</th>
<th>Type</th>
<th>Organization</th>
<th>Description</th>
<th>Docs</th>
</tr>
"""
for format_id, fmt in formats.items():
extensions = ' '.join(f'<span class="ext">{ext}</span>' for ext in fmt['file_extensions'] if ext)
if not extensions:
extensions = '<span class="ext">(none)</span>'
type_class = fmt['format_type']
docs = f'<a href="{fmt["documentation_url"]}" target="_blank">Link</a>' if fmt.get('documentation_url') else 'None'
html += f""" <tr>
<td><strong>{fmt['full_name']}</strong></td>
<td>{extensions}</td>
<td><span class="{type_class}">{fmt['format_type'].title()}</span></td>
<td>{fmt['organization']}</td>
<td>{fmt['description']}</td>
<td>{docs}</td>
</tr>
"""
html += """ </table>
</body>
</html>"""
# Write output
os.makedirs('docs', exist_ok=True)
with open('docs/index.html', 'w') as f:
f.write(html)
print(f"Generated table with {len(formats)} formats")