1
0
Fork 0
mirror of synced 2024-06-27 19:21:10 -04:00
dotbot/bin/dotbot_from_python_manually.py
m-richards 47f3e07b2d
Cleanup link logic, with a fix for windows links with \\?\ in them.
* reduce ci matrix

* python runscript without bash

(cherry picked from commit 9b148a6679722db5eb7ffabd3a27a8579f296319)

* change link dest function to handle '\?\' links

* add path normalization for windows support

* Revert "add path normalization for windows support"

This reverts commit 2ab0fc1b3c.

* link variable extraction without normpath

* type annotation

* blacken

* missing black files

* variable renames from '2775765a' outside link function

* from '2775765a' use method for default flags

* fix defaults from method

* variable renames from '2775765a' in link function and method renames

* refactor if clauses into blocks

* maybe fix if refactor

* remove unreachable code

* remove silly disambiguation semantics

* remove silly disambiguation semantics 2

* incremental else swap

* bring source existence check to front

* bring source existence check to front and remove old back check

* refactor almost final case

* check symlink broken cases up front

* add return missing

* flip block order to make things easier to understand
2021-02-16 19:32:13 +10:00

50 lines
1.2 KiB
Python

ARGS_TO_SCRIPT = (
"python >/dev/null /c/Users/Matt/dotfiles/dotbot/bin/dotbot -d /c/Users/Matt/dotfiles -c install.conf.yaml"
)
# These arguments are only linux/ bash safe
"""Script port from /c/Users/Matt/dotfiles/dotbot/bin/dotbot"""
import sys, os
DOTFILE_DIR = os.path.normpath(os.path.expandvars("%USERPROFILE%/dotfiles/"))
DIRECTORY_ARG = os.path.normpath(DOTFILE_DIR)
CONFIG_FILE_ARG = "install.conf.yaml"
sys.path.append(DOTFILE_DIR)
print(DOTFILE_DIR)
os.chdir(DOTFILE_DIR)
# PROJECT_ROOT_DIRECTORY = os.path.dirname(
# os.path.dirname(os.path.realpath(__file__)))
# print(PROJECT_ROOT_DIRECTORY)
PROJECT_ROOT_DIRECTORY = DOTFILE_DIR
def inject(lib_path):
path = os.path.join(PROJECT_ROOT_DIRECTORY, "lib", lib_path)
sys.path.insert(0, path)
# version dependent libraries
if sys.version_info[0] >= 3:
inject("pyyaml/lib3")
else:
inject("pyyaml/lib")
if os.path.exists(os.path.join(PROJECT_ROOT_DIRECTORY, "dotbot")):
if PROJECT_ROOT_DIRECTORY not in sys.path:
sys.path.insert(0, PROJECT_ROOT_DIRECTORY)
os.putenv("PYTHONPATH", PROJECT_ROOT_DIRECTORY)
import dotbot
def main():
dotbot.cli.main(additional_args=["-d", DIRECTORY_ARG, "-c", CONFIG_FILE_ARG])
if __name__ == "__main__":
main()