move link_filenames to util.

This commit is contained in:
Ivan Malison 2015-06-15 04:57:01 -07:00
parent d056c25982
commit c1f0fb5af6
2 changed files with 14 additions and 14 deletions

View File

@ -5,7 +5,7 @@ from invoke import Collection, ctask
from . import osx from . import osx
from . import linux from . import linux
from .util import DOTFILES_DIRECTORY, RESOURCES_DIRECTORY from .util import DOTFILES_DIRECTORY, RESOURCES_DIRECTORY, link_filenames
ns = Collection() ns = Collection()
@ -97,19 +97,6 @@ def link_dropbox_other(ctx, force=False):
link_filenames(ctx, link_pairs, force) 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 @ctask
def customize_user_settings(ctx): def customize_user_settings(ctx):
input_function = input if sys.version_info.major == 3 else raw_input input_function = input if sys.version_info.major == 3 else raw_input

View File

@ -13,6 +13,19 @@ def command_exists(command, run=run):
return run("hash {0}".format(command), warn=True, hide=True).exited == 0 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): def ensure_path_exists(path):
try: try:
os.makedirs(path) os.makedirs(path)