-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_quizzes.py
More file actions
59 lines (49 loc) · 1.83 KB
/
update_quizzes.py
File metadata and controls
59 lines (49 loc) · 1.83 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
import os
import re
files_to_update = [
"encryption-pqc.html",
"active-directory-pentest.html",
"crest-crt.html",
"git-security.html",
"mitre-attack.html",
"networking.html",
"owasp-agentic.html",
"owasp-mas.html",
"owasp-top10-2021.html",
"owasp-top10-2025.html",
"owasp-wstg.html",
"portswigger-2025.html"
]
base_dirs = [
"/home/r/Documents/cybersecurity-revision-quizzes/",
"/home/r/Documents/cybersecurity-revision-quizzes/AndroidApp/app/src/main/assets/"
]
def update_file(file_path):
with open(file_path, 'r') as f:
content = f.read()
# Look for the start-box div
# We want to find the <p> ... </p> and then the button
pattern = re.compile(r'(<div class="start-box">.*?<p>.*?</p>)\s*(<button[^>]*id="start-btn"[^>]*>.*?</button>)', re.DOTALL)
def replacement(match):
p_part = match.group(1)
button_part = match.group(2)
new_content = p_part + '\n <div id="high-score" class="high-score-box">Best Score: --</div>\n'
new_content += ' <div class="start-actions">\n'
new_content += ' ' + button_part + '\n'
new_content += ' <button class="btn btn-s" id="back-btn">Back to Menu</button>\n'
new_content += ' </div>'
return new_content
new_content, count = pattern.subn(replacement, content)
if count > 0:
with open(file_path, 'w') as f:
f.write(new_content)
print(f"Updated {file_path}")
else:
print(f"No match found in {file_path}")
for base_dir in base_dirs:
for filename in files_to_update:
full_path = os.path.join(base_dir, filename)
if os.path.exists(full_path):
update_file(full_path)
else:
print(f"File not found: {full_path}")