Blacken deploy.py

This commit is contained in:
2021-05-17 11:45:08 -07:00
parent 3cb8ff8a33
commit 6530e35130

View File

@@ -8,34 +8,36 @@ dotdir = Path(__file__).parent.resolve().absolute()
simple = [ simple = [
# 'gemrc', # 'gemrc',
'gitconfig', "gitconfig",
'ideavimrc', "ideavimrc",
'lein', "lein",
# 'irbrc', # 'irbrc',
# 'nethackrc', # 'nethackrc',
# 'spacemacs', # 'spacemacs',
'tmux.conf', "tmux.conf",
'vimrc' "vimrc",
] ]
targeted = { targeted = {
'doom': '.doom.d', "doom": ".doom.d",
'fish': '.config/fish', "fish": ".config/fish",
} }
def deploy(source_name, target_name, dry_run=False): def deploy(source_name, target_name, dry_run=False):
source = dotdir.joinpath(source_name) source = dotdir.joinpath(source_name)
target = home.joinpath(target_name) target = home.joinpath(target_name)
if not source.exists(): if not source.exists():
raise FileNotFoundError(f"Asked to link {source_name}, which doesn't exist in {dotdir}.") raise FileNotFoundError(
f"Asked to link {source_name}, which doesn't exist in {dotdir}."
)
if target.exists(): if target.exists():
if target.samefile(source): if target.samefile(source):
print(f"{target}->{source} already linked.") print(f"{target}->{source} already linked.")
return return
backup_path = target.parent.joinpath(f"{target.name}.bak") backup_path = target.parent.joinpath(f"{target.name}.bak")
print(f"{target} moves to {backup_path}") print(f"{target} moves to {backup_path}")
@@ -54,14 +56,14 @@ def deploy(source_name, target_name, dry_run=False):
def main(dry_run=True): def main(dry_run=True):
for source in simple: for source in simple:
target = f".{source}" target = f".{source}"
deploy(source, target, dry_run=dry_run) deploy(source, target, dry_run=dry_run)
for source, target in targeted.items(): for source, target in targeted.items():
deploy(source, target, dry_run=dry_run) deploy(source, target, dry_run=dry_run)
if __name__ == '__main__': if __name__ == "__main__":
try: try:
main(False) main(False)
except FileNotFoundError as e: except FileNotFoundError as e: