-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrename_places.py
More file actions
77 lines (65 loc) · 1.97 KB
/
Copy pathrename_places.py
File metadata and controls
77 lines (65 loc) · 1.97 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
"""
Script pour renommer a1-a6 en P1-P6 dans tout le projet
"""
import os
import re
# Mapping des remplacements
replacements = {
'"a1"': '"P1"',
'"a2"': '"P2"',
'"a3"': '"P3"',
'"a4"': '"P4"',
'"a5"': '"P5"',
'"a6"': '"P6"',
'/a1': '/P1',
'/a2': '/P2',
'/a3': '/P3',
'/a4': '/P4',
'/a5': '/P5',
'/a6': '/P6',
'place_id="a1"': 'place_id="P1"',
'place_id="a2"': 'place_id="P2"',
'place_id="a3"': 'place_id="P3"',
'place_id="a4"': 'place_id="P4"',
'place_id="a5"': 'place_id="P5"',
'place_id="a6"': 'place_id="P6"',
# Commentaires
'a1 -': 'P1 -',
"ex: a10": "ex: P10",
}
# Fichiers à modifier
files_to_process = [
'backend/tests/test_parking.py',
'backend/tests/test_sensor.py',
'backend/tests/test_admin.py',
'backend/tests/test_access.py',
'backend/services/websocket_service.py',
'frontend/admin/places.html',
]
base_dir = r'c:\Users\AJC\Desktop\aero-park-main (4) - Copie\aero-park-main'
def process_file(filepath):
"""Process a single file"""
full_path = os.path.join(base_dir, filepath)
if not os.path.exists(full_path):
print(f"❌ File not found: {filepath}")
return
try:
with open(full_path, 'r', encoding='utf-8') as f:
content = f.read()
original_content = content
# Apply replacements
for old, new in replacements.items():
content = content.replace(old, new)
if content != original_content:
with open(full_path, 'w', encoding='utf-8') as f:
f.write(content)
print(f"✅ Updated: {filepath}")
else:
print(f"⏭️ No changes: {filepath}")
except Exception as e:
print(f"❌ Error processing {filepath}: {e}")
# Process all files
print("🚀 Starting place ID rename: a1-a6 → P1-P6\n")
for filepath in files_to_process:
process_file(filepath)
print("\n✅ Rename complete!")