Fix tasks_from_directory

This commit is contained in:
Ivan Malison 2016-11-18 16:18:22 -06:00
parent 206fc8ffbf
commit b84ab65b93
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8
2 changed files with 13 additions and 12 deletions

View File

@ -29,14 +29,14 @@ def command_exists(command, run=run):
def build_task_factory(ns): def build_task_factory(ns):
def task(function): def task(function, *args, **kwargs):
ns.add_task(ctask(function)) ns.add_task(ctask(function, *args, **kwargs))
return function return function
return task return task
def namespace_and_factory(): def namespace_and_factory(*args, **kwargs):
ns = Collection() ns = Collection(*args, **kwargs)
return ns, build_task_factory(ns) return ns, build_task_factory(ns)
@ -48,17 +48,17 @@ def extension_checker(extension):
def tasks_from_directory(directory_path, file_predicate=extension_checker("sh")): def tasks_from_directory(directory_path, file_predicate=extension_checker("sh")):
ns, make_task = namespace_and_factory() ns, make_task = namespace_and_factory(os.path.basename(directory_path))
def task_from_file(filepath): def task_from_file(filepath):
@make_task()
def run_script(ctx): def run_script(ctx):
ctx.run(filepath) ctx.run(filepath)
return run_script return make_task(run_script, name=os.path.basename(filepath).split(os.path.extsep)[0])
filepaths = filter(os.path.isfile, filepaths = filter(
os.path.isfile,
[os.path.join(directory_path, filename) [os.path.join(directory_path, filename)
for filename in os.listdir(directory_path)]) for filename in os.listdir(directory_path)],
)
map(task_from_file, filepaths) list(map(task_from_file, filepaths))
return ns return ns

1
tasks/imalison.py Symbolic link
View File

@ -0,0 +1 @@
../dotfiles/lib/python/imalison.py