-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchid_replace.py
More file actions
executable file
·38 lines (26 loc) · 828 Bytes
/
chid_replace.py
File metadata and controls
executable file
·38 lines (26 loc) · 828 Bytes
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
from __future__ import annotations
import sys
from chid_utils import get_root_path
def main() -> str:
alias = sys.argv[3]
if len(sys.argv) <= 2 or not (sys.argv[2].startswith("chid ") or sys.argv[2].startswith(f"{alias} ")):
return ""
value = sys.argv[2].split(" ")[1]
if not value.isnumeric():
return ""
value = int(value)
if value == 0:
return ""
# dir = sys.argv[1]
root_path = get_root_path()
destination_file = root_path / "last_output"
if not destination_file.exists():
return ""
with open(destination_file, "r") as file:
splited = file.readlines()
if len(splited) < value:
return ""
return splited[value - 1].split(";")[-1]
if __name__ == "__main__":
result = main()
print(result, end="")