forked from farion1231/cc-switch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_lib.py
More file actions
42 lines (38 loc) · 1.8 KB
/
Copy pathfix_lib.py
File metadata and controls
42 lines (38 loc) · 1.8 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
import pathlib
f = pathlib.Path(r"C:\GitHub\cc-switch\src-tauri\src\lib.rs")
content = f.read_text(encoding="utf-8")
old = """ commands::backends::list_backends,
commands::backends::get_backend,
commands::backends::create_backend,
commands::backends::update_backend,
commands::backends::delete_backend,
commands::backends::start_backend,
commands::backends::stop_backend,
commands::backends::get_backend_status,"""
new = """ commands::backends::list_backends,
commands::backends::get_backend,
commands::backends::create_backend,
commands::backends::update_backend,
commands::backends::delete_backend,
commands::backends::start_backend,
commands::backends::stop_backend,
commands::backends::restart_backend,
commands::backends::get_backend_logs,
commands::backends::send_backend_input,
commands::backends::check_backend_health,
commands::backends::list_backend_models,
commands::backends::read_backend_env_file,
commands::backends::write_backend_env_file,"""
count = content.count(old)
if count == 1:
content = content.replace(old, new)
f.write_text(content, encoding="utf-8")
pathlib.Path(r"C:\GitHub\cc-switch\lib_result.txt").write_text("OK: replaced", encoding="utf-8")
else:
# Try to find what's actually there
idx = content.find("commands::backends::")
if idx >= 0:
ctx = content[idx:idx+500]
pathlib.Path(r"C:\GitHub\cc-switch\lib_result.txt").write_text(f"Found {count} matches. Context:\n{ctx}", encoding="utf-8")
else:
pathlib.Path(r"C:\GitHub\cc-switch\lib_result.txt").write_text("NOT FOUND", encoding="utf-8")