def run(self): """For each file in noseOfYeti/specs, output nodes to represent each spec file""" tokens = [] section = nodes.section() section['ids'].append("available-tasks") title = nodes.title() title += nodes.Text("Default tasks") section += title task_finder = TaskFinder(Collector()) for name, task in sorted(task_finder.default_tasks().items(), key=lambda x: len(x[0])): lines = [name] + [" {0}".format(line.strip()) for line in task.description.split('\n')] viewlist = ViewList() for line in lines: viewlist.append(line, name) self.state.nested_parse(viewlist, self.content_offset, section) return [section]
def extra_prepare_after_activation(self, configuration, args_dict): """Called after the configuration.converters are activated""" def task_maker(name, description=None, action=None, label="Project", **options): if not action: action = name self.task_overrides[name] = Task(action=action, description=description, options=options, label=label) return self.task_overrides[name] # Post register our addons extra_args = {"harpoon.crosshairs": {"task_maker": task_maker}} self.register.post_register(extra_args) # Make the task finder task_finder = TaskFinder(self) self.configuration["task_runner"] = task_finder.task_runner task_finder.find_tasks(getattr(self, "task_overrides", {}))
def extra_prepare_after_activation(self, configuration, args_dict): """ Called after the configuration.converters are activated Here we create our ``task_maker`` helper that we pass into ``post_register`` for our ``option_merge_addon_hook`` functions. We also create a ``task_finder`` for doing task finding related duties. """ def task_maker(name, description=None, action=None, label="Project", **options): if not action: action = name self.task_overrides[name] = Task(action=action, description=description, options=options, label=label) return self.task_overrides[name] # Post register our addons extra_args = {"harpoon.crosshairs": {"task_maker": task_maker}} self.register.post_register(extra_args) # Make the task finder task_finder = TaskFinder(self) configuration["task_runner"] = task_finder.task_runner task_finder.find_tasks(self.task_overrides)
from harpoon.task_finder import TaskFinder from harpoon.collector import Collector from harpoon.errors import BadTask from tests.helpers import HarpoonCase import mock import json describe HarpoonCase, "TaskFinder": it "takes in a collector": collector = mock.Mock(name="collector") configuration = mock.Mock(name="configuration") collector.configuration = configuration task_finder = TaskFinder(collector) self.assertEqual(task_finder.tasks, {}) self.assertIs(task_finder.collector, collector) describe "image_finder": it "defaults to the chosen_image": chosen_image = mock.Mock(name="chosen_image") configuration = {"harpoon": type("Harpoon", (object, ), {"chosen_image": chosen_image})()} collector = mock.Mock(name="collector", configuration=configuration) task_finder = TaskFinder(collector) task_finder.tasks["blah"] = type("Task", (object, ), {})() self.assertIs(task_finder.image_finder("blah"), chosen_image) it "chooses the image on the task": chosen_image = mock.Mock(name="chosen_image")
def extra_prepare_after_activation(self, configuration, cli_args): """Called after the configuration.converters are activated""" task_finder = TaskFinder(self) self.configuration["task_runner"] = task_finder.task_runner task_finder.find_tasks({})