Subversion Repositories Kolibri OS

Rev

Rev 9367 | Rev 9374 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9367 Rev 9370
Line 1... Line 1...
1
#!/bin/python3
1
#!/usr/bin/python3
2
# Copyright Magomed Kostoev
2
# Copyright Magomed Kostoev
3
# Published under MIT license
3
# Published under MIT license
Line 4... Line 4...
4
 
4
 
Line 5... Line 5...
5
import os
5
import os
6
 
6
 
Line 7... Line 7...
7
def log(s, end = "\n"):
7
def log(s, end = "\n"):
8
    print(s, end = end, flush = True)
8
    print(s, end = end, flush = True)
Line 9... Line 9...
9
 
9
 
10
def install_python_script(src, dst, tools_lib):
10
def install_python_script(src, dst, tools):
11
    log(f"Copying {src}... ", end = "")
11
    log(f"Copying {src}... ", end = "")
12
 
12
 
13
    with open(src) as src_file:
13
    with open(src) as src_file:
14
        script = src_file.read()
14
        script = src_file.read()
15
    tools_lib_escaped = tools_lib.replace("\\", "\\\\")
15
    tools = tools.replace("\\", "\\\\")
16
    repl_from = "path_to_lib = '../lib'"
16
    repl_from = "path_to_tools = '..'"
Line 17... Line 17...
17
    repl_to = f"path_to_lib ='{tools_lib_escaped}'"
17
    repl_to = f"path_to_tools ='{tools}'"
Line 18... Line 18...
18
    script = script.replace(repl_from, repl_to, 1)
18
    script = script.replace(repl_from, repl_to, 1)
19
    with open(dst, "w") as dst_file:
19
    with open(dst, "w") as dst_file:
20
        dst_file.write(script)
20
        dst_file.write(script)
21
 
-
 
22
    log(f"Done")
21
 
23
 
22
    log(f"Done")
24
if __name__ == "__main__":
23
 
25
    tools_get_started_py = os.path.abspath(__file__)
24
if __name__ == "__main__":
26
    tools = os.sep.join(tools_get_started_py.split(os.sep)[:-1])
25
    tools_get_started_py = os.path.abspath(__file__)
27
    tools_lib = os.sep.join([tools, "lib"])
26
    tools = os.sep.join(tools_get_started_py.split(os.sep)[:-1])
28
    tools_workspace = os.sep.join([tools, "workspace"])
27
    tools_workspace = os.sep.join([tools, "workspace"])