-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswitch-to-dev.py
More file actions
executable file
·78 lines (66 loc) · 3.27 KB
/
switch-to-dev.py
File metadata and controls
executable file
·78 lines (66 loc) · 3.27 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
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python3
"""Switch to development mode by enabling dev scripts and disabling production scripts."""
import re
def switch_to_dev():
with open('index.html', 'r') as f:
content = f.read()
# Switch color-modes script
# Comment out production color-modes if it's active
content = re.sub(
r'^\s*<script src="/mesa-explorer/js/color-modes\.js"></script>',
r'\t<!-- <script src="/mesa-explorer/js/color-modes.js"></script> -->',
content,
flags=re.MULTILINE
)
# Uncomment development color-modes if it's commented
content = re.sub(
r'^\s*<!-- <script src="/js/color-modes\.js"></script> -->',
r'\t<script src="/js/color-modes.js"></script>',
content,
flags=re.MULTILINE
)
# Handle production scripts - comment them out if they're active
production_scripts = [
'file-manager.js', 'ui-utils.js', 'style-manager.js', 'metadata-manager.js',
'text-markup.js', 'data-utils.js', 'series-manager.js', 'interaction-manager.js',
'download-manager.js', 'controls-manager.js', 'mesa-explorer.js'
]
for script in production_scripts:
content = re.sub(
rf'^\s*<script src="/mesa-explorer/js/{script}"></script>',
rf'\t\t<!-- <script src="/mesa-explorer/js/{script}"></script> -->',
content,
flags=re.MULTILINE
)
# Uncomment development scripts that are currently commented
# Handle the multi-line comment block for core utilities
content = re.sub(
r'<!-- <script src="/js/file-manager\.js"></script>\s*\n\s*<script src="/js/ui-utils\.js"></script>\s*\n\s*<script src="/js/style-manager\.js"></script>\s*\n\s*<script src="/js/metadata-manager\.js"></script>\s*\n\s*<script src="/js/text-markup\.js"></script> -->',
r'<script src="/js/file-manager.js"></script>\n\t\t<script src="/js/ui-utils.js"></script>\n\t\t<script src="/js/style-manager.js"></script>\n\t\t<script src="/js/metadata-manager.js"></script>\n\t\t<script src="/js/text-markup.js"></script>',
content
)
# Handle data-utils
content = re.sub(
r'^\s*<!-- <script src="/js/data-utils\.js"></script> -->',
r'\t\t<script src="/js/data-utils.js"></script>',
content,
flags=re.MULTILINE
)
# Handle the UI management multi-line comment
content = re.sub(
r'<!-- <script src="/js/series-manager\.js"></script>\s*\n\s*<script src="/js/interaction-manager\.js"></script>\s*\n\s*<script src="/js/download-manager\.js"></script>\s*\n\s*<script src="/js/controls-manager\.js"></script> -->',
r'<script src="/js/series-manager.js"></script>\n\t\t<script src="/js/interaction-manager.js"></script>\n\t\t<script src="/js/download-manager.js"></script>\n\t\t<script src="/js/controls-manager.js"></script>',
content
)
# Handle mesa-explorer
content = re.sub(
r'^\s*<!-- <script src="/js/mesa-explorer\.js"></script> -->',
r'\t\t<script src="/js/mesa-explorer.js"></script>',
content,
flags=re.MULTILINE
)
with open('index.html', 'w') as f:
f.write(content)
print("Switched to development mode. Development scripts are now active.")
if __name__ == "__main__":
switch_to_dev()