invoke utility functions in imalison.py

This commit is contained in:
Ivan Malison 2015-11-21 04:43:54 -08:00
parent 199e9cc1f8
commit fc1860c09c
2 changed files with 14 additions and 1 deletions

View File

@ -1,6 +1,6 @@
import os import os
import errno import errno
from invoke import run from invoke import run, Collection, ctask
def link_filenames(ctx, link_pairs, force=False): def link_filenames(ctx, link_pairs, force=False):
@ -26,3 +26,15 @@ def ensure_path_exists(path):
def command_exists(command, run=run): 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 build_task_factory(ns):
def task(function):
ns.add_task(ctask(function))
return function
return task
def namespace_and_factory():
ns = Collection()
return ns, build_task_factory(ns)

View File

@ -1,5 +1,6 @@
import re import re
history_entry_re = re.compile(": ([0-9]*):[0-9]*;.*") history_entry_re = re.compile(": ([0-9]*):[0-9]*;.*")