-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_severity_controls.py
More file actions
93 lines (71 loc) · 2.43 KB
/
fix_severity_controls.py
File metadata and controls
93 lines (71 loc) · 2.43 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python3
"""
Script to fix the wrapping issue in severity chart controls.
"""
import re
from pathlib import Path
def fix_controls(file_path):
"""Fix the controls layout to prevent wrapping."""
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
# Find and replace the .controls CSS
controls_pattern = r'(\.controls\s*\{[^}]*\})'
new_controls_css = """.controls {
margin-bottom: 10px;
padding: 8px 10px;
background: #f9f9f9;
border-radius: 4px;
display: flex;
align-items: center;
gap: 10px;
flex-wrap: nowrap;
justify-content: space-between;
}"""
content = re.sub(controls_pattern, new_controls_css, content, flags=re.DOTALL)
# Make the mode buttons more compact
mode_button_pattern = r'(\.mode-button\s*\{[^}]*padding:[^;]*;)'
content = re.sub(
mode_button_pattern,
r'.mode-button {\n background: white;\n color: #a32035;\n border: none;\n padding: 8px 12px;',
content,
flags=re.DOTALL
)
# Reduce font size for better fit
mode_button_font_pattern = r'(\.mode-button\s*\{[^}]*font-size:[^;]*;)'
content = re.sub(
r'(\.mode-button[^}]*font-size:\s*)\d+px;',
r'\g<1>13px;',
content
)
# Make toggle button text smaller
content = re.sub(
r'(\.toggle-button[^}]*font-size:\s*)\d+px;',
r'\g<1>13px;',
content
)
# Reduce toggle button padding
content = re.sub(
r'(\.toggle-button[^}]*padding:\s*)10px 0px;',
r'\g<1>8px 0px;',
content
)
# Write back
with open(file_path, 'w', encoding='utf-8') as f:
f.write(content)
print(f"Updated: {file_path.name}")
def main():
"""Process all severity chart files."""
# Find all BAU and PM severity charts
bau_charts = sorted(Path('.').glob('risk*_bau_chart.html'))
pm_charts = sorted(Path('.').glob('risk*_pm_chart.html'))
all_charts = bau_charts + pm_charts
if not all_charts:
print("No severity charts found!")
return
print(f"Found {len(all_charts)} severity charts")
print(f"Fixing control wrapping issues...\n")
for chart_file in all_charts:
fix_controls(chart_file)
print(f"\nCompleted! Updated {len(all_charts)} files.")
if __name__ == '__main__':
main()