forked from Ikalus1988/MisakaNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean_empty_verification.py
More file actions
76 lines (61 loc) 路 1.75 KB
/
Copy pathclean_empty_verification.py
File metadata and controls
76 lines (61 loc) 路 1.75 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
#!/usr/bin/env python3
"""Clean empty verification templates and irrelevant commands."""
import re
from pathlib import Path
REPO = Path(__file__).resolve().parent.parent
CONTRIB = REPO / "lessons" / "contrib"
def clean_verification(filepath: Path) -> bool:
"""Remove empty verification templates and irrelevant commands."""
content = filepath.read_text(encoding='utf-8')
original = content
# Remove echo verification commands
content = re.sub(
r'```bash\n\s*echo\s+.*?Verification\s+commands\s+for:.*?\n```',
'',
content,
flags=re.DOTALL
)
# Remove irrelevant curl commands
content = re.sub(
r'```bash\n\s*curl\s+.*?localhost:8080/health.*?\n```',
'',
content,
flags=re.DOTALL
)
# Remove irrelevant python commands
content = re.sub(
r'```bash\n\s*python3\s+.*?Python\s+check\s+passed.*?\n```',
'',
content,
flags=re.DOTALL
)
# Remove git status commands
content = re.sub(
r'```bash\n\s*git\s+status\s*\n```',
'',
content,
flags=re.DOTALL
)
# Remove docker ps commands
content = re.sub(
r'```bash\n\s*docker\s+ps\s*\n```',
'',
content,
flags=re.DOTALL
)
if content != original:
filepath.write_text(content, encoding='utf-8')
return True
return False
def main():
count = 0
for filepath in sorted(CONTRIB.glob("*.md")):
if clean_verification(filepath):
try:
print(f"Cleaned: {filepath.name}")
except UnicodeEncodeError:
print(f"Cleaned: {filepath.stem}")
count += 1
print(f"\nTotal cleaned: {count}")
if __name__ == "__main__":
main()