-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.py
More file actions
35 lines (24 loc) · 777 Bytes
/
util.py
File metadata and controls
35 lines (24 loc) · 777 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
from shutil import move
from os import remove
def stream_set_src(src: str, params: [str]) -> None:
src_temp = '/'.join(src.split('/')[:-1] + ["temp.dat"]) # creates a tmp file at the same location as src
f_src = open(src, 'w')
f_temp = open(src_temp, 'w+')
i = 0
for line in f_src.readlines():
if line.startswith("source:"):
f_temp.write("source: " + params[i])
i += 1
else:
f_temp.write(line)
f_temp.close()
f_src.close()
remove(src)
move(src_temp, src)
def stream_get_dest(src: str) -> str:
f_src = open(src, 'r')
dest = ""
for line in f_src.readlines():
if line.startswith("dest:"):
dest = line.split("dest:")[-1].strip()
return dest