From 7d30be57e26399a384d77b378e67d4d58b0fb30c Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 15 Dec 2014 16:50:58 -0800 Subject: [PATCH] Refactor dropbox linking. --- tasks/__init__.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tasks/__init__.py b/tasks/__init__.py index 21757db9..999110f1 100644 --- a/tasks/__init__.py +++ b/tasks/__init__.py @@ -43,7 +43,8 @@ def dropbox_dotfiles(ctx, flags='f'): ), flags )) - link_dropbox_other(ctx) + link_filenames(ctx, [('~/Dropbox/configs/custom.el', '~/.emacs.d/custom.el')], force=True) + @ctask def powerline(ctx): @@ -77,16 +78,22 @@ def change_shell(ctx): @ctask -def link_dropbox_other(ctx): +def link_dropbox_other(ctx, force=False): link_pairs = ( - ('~/Dropbox/configs/custom.el', '~/.emacs.d/custom.el'), ('~/Dropbox/Documents', '~/Documents'), ('~/Dropbox/Pictures', '~/Pictures'), ('~/Dropbox/org', '~/org') + ('~/Dropbox/Desktop', '~/Desktop') ) + link_filenames(ctx, link_pairs, force) + + +def link_filenames(ctx, link_pairs, force=False) for source, destination in link_pairs: destination = os.path.expanduser(destination) source = os.path.expanduser(source) + if force: + ctx.run("sudo rm -rf {0}".format(destination)) if os.path.exists(destination): print("Skipping {0} because path already exists".format(destination)) else: