From fc1860c09c814f04a7d1f1c6535edc82a55d9c1f Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Sat, 21 Nov 2015 04:43:54 -0800 Subject: [PATCH] invoke utility functions in imalison.py --- dotfiles/lib/python/imalison.py | 14 +++++++++++++- dotfiles/lib/python/merge_zsh_history.py | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/dotfiles/lib/python/imalison.py b/dotfiles/lib/python/imalison.py index 515ea09b..d6a0c579 100644 --- a/dotfiles/lib/python/imalison.py +++ b/dotfiles/lib/python/imalison.py @@ -1,6 +1,6 @@ import os import errno -from invoke import run +from invoke import run, Collection, ctask def link_filenames(ctx, link_pairs, force=False): @@ -26,3 +26,15 @@ def ensure_path_exists(path): def command_exists(command, run=run): 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) diff --git a/dotfiles/lib/python/merge_zsh_history.py b/dotfiles/lib/python/merge_zsh_history.py index e92f57aa..b70e3267 100644 --- a/dotfiles/lib/python/merge_zsh_history.py +++ b/dotfiles/lib/python/merge_zsh_history.py @@ -1,5 +1,6 @@ import re + history_entry_re = re.compile(": ([0-9]*):[0-9]*;.*")