Subversion Repositories Kolibri OS

Rev

Rev 9367 | Rev 9375 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #!/usr/bin/python3
  2. # Copyright Magomed Kostoev
  3. # Published under MIT license
  4.  
  5. import os
  6.  
  7. def log(s, end = "\n"):
  8.     print(s, end = end, flush = True)
  9.  
  10. def install_python_script(src, dst, tools):
  11.     log(f"Copying {src}... ", end = "")
  12.  
  13.     with open(src) as src_file:
  14.         script = src_file.read()
  15.     tools = tools.replace("\\", "\\\\")
  16.     repl_from = "path_to_tools = '..'"
  17.     repl_to = f"path_to_tools ='{tools}'"
  18.     script = script.replace(repl_from, repl_to, 1)
  19.     with open(dst, "w") as dst_file:
  20.         dst_file.write(script)
  21.  
  22.     log(f"Done")
  23.  
  24. if __name__ == "__main__":
  25.     tools_get_started_py = os.path.abspath(__file__)
  26.     tools = os.sep.join(tools_get_started_py.split(os.sep)[:-1])
  27.     tools_workspace = os.sep.join([tools, "workspace"])
  28.     # Copy scripts from _tools/workspace to current folder, but let them know
  29.     # where the _tools/lib is (change their value of tools variable)
  30.     tools_workspace_run_py = os.sep.join([tools_workspace, "run.py"])
  31.     tools_workspace_build_py = os.sep.join([tools_workspace, "build.py"])
  32.     install_python_script(tools_workspace_run_py, "run.py", tools)
  33.     install_python_script(tools_workspace_build_py, "build.py", tools)
  34.