-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreduce_severity_height.py
More file actions
61 lines (44 loc) · 1.52 KB
/
reduce_severity_height.py
File metadata and controls
61 lines (44 loc) · 1.52 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
#!/usr/bin/env python3
"""
Script to reduce the height of severity charts.
"""
import re
from pathlib import Path
def reduce_chart_height(file_path, new_height=350):
"""Reduce the chart height in a severity chart file and change background to white."""
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
# Replace the height in .chart-container
# Looking for: height: 500px;
content = re.sub(
r'(\.chart-container\s*\{[^}]*height:\s*)\d+px;',
rf'\g<1>{new_height}px;',
content
)
# Change body background from grey to white
# Looking for: background: #f5f5f5;
content = re.sub(
r'(body\s*\{[^}]*background:\s*)#f5f5f5;',
r'\g<1>white;',
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"Reducing height to 350px and changing background to white...\n")
for chart_file in all_charts:
reduce_chart_height(chart_file)
print(f"\nCompleted! Updated {len(all_charts)} files.")
if __name__ == '__main__':
main()