-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathupdate_css.py
More file actions
47 lines (37 loc) · 1.15 KB
/
Copy pathupdate_css.py
File metadata and controls
47 lines (37 loc) · 1.15 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
import sys
import os
css_to_add = """
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.animate-spin {
animation: spin 1s linear infinite;
}
"""
files = sys.argv[1:]
for file_path in files:
if "WritingGuide.vue" in file_path:
continue
try:
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
if "@keyframes spin" in content:
print(f"Skipping {file_path}: already has animation")
continue
if "</style>" in content:
# Check if we should insert before the last </style>
# Use rsplit to replace only the last occurrence
parts = content.rsplit("</style>", 1)
new_content = parts[0] + css_to_add + "</style>" + parts[1]
with open(file_path, 'w', encoding='utf-8') as f:
f.write(new_content)
print(f"Updated {file_path}")
else:
print(f"Skipping {file_path}: no </style> tag found")
except Exception as e:
print(f"Error processing {file_path}: {e}")