Blacken deploy.py
This commit is contained in:
28
deploy.py
28
deploy.py
@@ -8,34 +8,36 @@ dotdir = Path(__file__).parent.resolve().absolute()
|
||||
|
||||
simple = [
|
||||
# 'gemrc',
|
||||
'gitconfig',
|
||||
'ideavimrc',
|
||||
'lein',
|
||||
"gitconfig",
|
||||
"ideavimrc",
|
||||
"lein",
|
||||
# 'irbrc',
|
||||
# 'nethackrc',
|
||||
# 'spacemacs',
|
||||
'tmux.conf',
|
||||
'vimrc'
|
||||
"tmux.conf",
|
||||
"vimrc",
|
||||
]
|
||||
|
||||
targeted = {
|
||||
'doom': '.doom.d',
|
||||
'fish': '.config/fish',
|
||||
"doom": ".doom.d",
|
||||
"fish": ".config/fish",
|
||||
}
|
||||
|
||||
|
||||
def deploy(source_name, target_name, dry_run=False):
|
||||
source = dotdir.joinpath(source_name)
|
||||
target = home.joinpath(target_name)
|
||||
|
||||
|
||||
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.samefile(source):
|
||||
print(f"{target}->{source} already linked.")
|
||||
return
|
||||
|
||||
|
||||
backup_path = target.parent.joinpath(f"{target.name}.bak")
|
||||
|
||||
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):
|
||||
for source in simple:
|
||||
target = f".{source}"
|
||||
target = f".{source}"
|
||||
deploy(source, target, dry_run=dry_run)
|
||||
|
||||
|
||||
for source, target in targeted.items():
|
||||
deploy(source, target, dry_run=dry_run)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
main(False)
|
||||
except FileNotFoundError as e:
|
||||
|
||||
Reference in New Issue
Block a user