From c1f0fb5af6b1af6e74ed15c86632e4bc37f2a869 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 15 Jun 2015 04:57:01 -0700 Subject: [PATCH] move link_filenames to util. --- tasks/__init__.py | 15 +-------------- tasks/util.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tasks/__init__.py b/tasks/__init__.py index e7a86acd..0f865e3c 100644 --- a/tasks/__init__.py +++ b/tasks/__init__.py @@ -5,7 +5,7 @@ from invoke import Collection, ctask from . import osx from . import linux -from .util import DOTFILES_DIRECTORY, RESOURCES_DIRECTORY +from .util import DOTFILES_DIRECTORY, RESOURCES_DIRECTORY, link_filenames ns = Collection() @@ -97,19 +97,6 @@ def link_dropbox_other(ctx, force=False): 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: - print("Linking {0} to {1}".format(destination, source)) - ctx.run('ln -s {0} {1}'.format(source, destination)) - - @ctask def customize_user_settings(ctx): input_function = input if sys.version_info.major == 3 else raw_input diff --git a/tasks/util.py b/tasks/util.py index 723fca6e..e76a6afa 100644 --- a/tasks/util.py +++ b/tasks/util.py @@ -13,6 +13,19 @@ def command_exists(command, run=run): return run("hash {0}".format(command), warn=True, hide=True).exited == 0 +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: + print("Linking {0} to {1}".format(destination, source)) + ctx.run('ln -s {0} {1}'.format(source, destination)) + + def ensure_path_exists(path): try: os.makedirs(path)