diff --git a/README.md b/README.md index e32051b..f8becf2 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ In essence this repo will mimic the layout of my homedir with a bunch of dotfile The setup_dotfiles.py script takes the contents of this path and creates symlinks in my actual homedir, matching the directory structure. ## Requirements -* Python 3.4 +* Python 3.9 * A home directory ## Setup diff --git a/setup_dotfiles.py b/setup_dotfiles.py index 468bfd2..d9f9c31 100755 --- a/setup_dotfiles.py +++ b/setup_dotfiles.py @@ -8,6 +8,7 @@ removing old symlinks as necessary as well as optionally files. import inspect import os # Needed for os.walk til Py3.12 +import sys from pathlib import Path FORCE = False @@ -31,6 +32,7 @@ def check_and_remove(source: Path, destination: Path, *, force: bool = False) -> # Destination exists as a symlink if Path(destination).is_symlink(): # Symlink is correct, return + # This is the only function that bumps our requirement to py3.9, lol if Path(destination).readlink() == source: return False # Symlink is incorrect, remove it @@ -40,10 +42,10 @@ def check_and_remove(source: Path, destination: Path, *, force: bool = False) -> # Force mode enabled, remove it (Data loss risk!!) if force: Path(destination).unlink() - # Force mode disabled, error out + # Force mode disabled, skip this file else: - msg = f"{destination!s} exists as a file and --force not provided" - raise OSError(msg) + print(f"{destination!s} exists as a file and --force not provided") + return False # File doesn't exist or undefined "thing" happened, return True to try to # write, and if something goes wrong, we'll see the OSError @@ -81,4 +83,9 @@ def install_dotfiles(source_dir: Path, dest_dir: Path, exclusions: list, *, forc if __name__ == "__main__": - install_dotfiles(SOURCEDIR, HOMEDIR, EXCLUSIONS, force=False) + force = "--force" in sys.argv + + if force: + print("--force enabled, will remove files to create symlinks") + + install_dotfiles(SOURCEDIR, HOMEDIR, EXCLUSIONS, force=force)