def load_tasks(self, cmd, opt_values, pos_args): """Load Nikola tasks.""" if self.quiet: DOIT_CONFIG = { 'verbosity': 0, 'reporter': 'zero', } else: DOIT_CONFIG = { 'reporter': ExecutedOnlyReporter, 'outfile': sys.stderr, } DOIT_CONFIG['default_tasks'] = ['render_site', 'post_render'] DOIT_CONFIG.update(self.nikola._doit_config) try: tasks = generate_tasks( 'render_site', self.nikola.gen_tasks('render_site', "Task", 'Group of tasks to render the site.')) latetasks = generate_tasks( 'post_render', self.nikola.gen_tasks('post_render', "LateTask", 'Group of tasks to be executed after site is rendered.')) signal('initialized').send(self.nikola) except Exception: LOGGER.error('Error loading tasks. An unhandled exception occurred.') if self.nikola.debug or self.nikola.show_tracebacks: raise _print_exception() sys.exit(3) return tasks + latetasks, DOIT_CONFIG
def load_tasks(self, cmd, opt_values, pos_args): DOIT_CONFIG = { 'reporter': ExecutedOnlyReporter, 'default_tasks': ['render_site', 'post_render'], } tasks = generate_tasks('render_site', self.nikola.gen_tasks('render_site', "Task")) latetasks = generate_tasks('post_render', self.nikola.gen_tasks('post_render', "LateTask")) return tasks + latetasks, DOIT_CONFIG
def _call_nikola_list(site): files = [] deps = defaultdict(list) for task in generate_tasks('render_site', site.gen_tasks('render_site', "Task", '')): files.extend(task.targets) for target in task.targets: deps[target].extend(task.file_dep) for task in generate_tasks('post_render', site.gen_tasks('render_site', "LateTask", '')): files.extend(task.targets) for target in task.targets: deps[target].extend(task.file_dep) return files, deps
def load_tasks(self, cmd, opt_values, pos_args): if self.quiet: DOIT_CONFIG = { 'verbosity': 0, 'reporter': 'zero', } else: DOIT_CONFIG = { 'reporter': ExecutedOnlyReporter, } DOIT_CONFIG['default_tasks'] = ['render_site', 'post_render'] tasks = generate_tasks('render_site', self.nikola.gen_tasks('render_site', "Task")) latetasks = generate_tasks('post_render', self.nikola.gen_tasks('post_render', "LateTask")) return tasks + latetasks, DOIT_CONFIG
def load_tasks(self, cmd, opt_values, pos_args): if self.quiet: DOIT_CONFIG = {"verbosity": 0, "reporter": "zero"} else: DOIT_CONFIG = {"reporter": ExecutedOnlyReporter, "outfile": sys.stderr} DOIT_CONFIG["default_tasks"] = ["render_site", "post_render"] tasks = generate_tasks( "render_site", self.nikola.gen_tasks("render_site", "Task", "Group of tasks to render the site.") ) latetasks = generate_tasks( "post_render", self.nikola.gen_tasks("post_render", "LateTask", "Group of tasks to be executed after site is rendered."), ) signal("initialized").send(self.nikola) return tasks + latetasks, DOIT_CONFIG
def testBaseName(self): tasks = generate_tasks("function_name", { 'basename': 'real_task_name', 'actions':['xpto 14'] }) assert isinstance(tasks[0], Task) assert "real_task_name" == tasks[0].name
def testGeneratorDocString(self): def f_xpto(): "the doc" for i in range(3): yield {'name':str(i), 'actions' :["xpto -%d"%i]} tasks = sorted(generate_tasks("xpto", f_xpto(), f_xpto.__doc__)) assert "the doc" == tasks[0].doc
def testGeneratorWithNoTasks(self): def f_xpto(): for x in []: yield x tasks = generate_tasks("xpto", f_xpto()) assert 1 == len(tasks) assert "xpto" == tasks[0].name assert not tasks[0].is_subtask
def _call_nikola_list(site, cache=None): if cache is not None: if "files" in cache and "deps" in cache: return cache["files"], cache["deps"] files = [] deps = defaultdict(list) for task in generate_tasks("render_site", site.gen_tasks("render_site", "Task", "")): files.extend(task.targets) for target in task.targets: deps[target].extend(task.file_dep) for task in generate_tasks("post_render", site.gen_tasks("render_site", "LateTask", "")): files.extend(task.targets) for target in task.targets: deps[target].extend(task.file_dep) if cache is not None: cache["files"] = files cache["deps"] = deps return files, deps
def _call_nikola_list(site, cache=None): if cache is not None: if 'files' in cache and 'deps' in cache: return cache['files'], cache['deps'] files = [] deps = defaultdict(list) for task in generate_tasks('render_site', site.gen_tasks('render_site', "Task", '')): files.extend(task.targets) for target in task.targets: deps[target].extend(task.file_dep) for task in generate_tasks('post_render', site.gen_tasks('render_site', "LateTask", '')): files.extend(task.targets) for target in task.targets: deps[target].extend(task.file_dep) if cache is not None: cache['files'] = files cache['deps'] = deps return files, deps
def testGeneratorBaseOnly(self): def f_xpto(): yield {'basename':'xpto', 'name':None, 'doc': 'xxx doc'} tasks = sorted(generate_tasks("f_xpto", f_xpto())) assert 1 == len(tasks) assert isinstance(tasks[0], Task) assert "xpto" == tasks[0].name assert tasks[0].has_subtask assert 'xxx doc' == tasks[0].doc
def testGeneratorBaseOnly(self): def f_xpto(): yield {"basename": "xpto", "name": None, "doc": "xxx doc"} tasks = sorted(generate_tasks("f_xpto", f_xpto())) assert 1 == len(tasks) assert isinstance(tasks[0], Task) assert "xpto" == tasks[0].name assert tasks[0].has_subtask assert "xxx doc" == tasks[0].doc
def testGenerator(self): def f_xpto(): for i in range(3): yield {'name':str(i), 'actions' :["xpto -%d"%i]} tasks = generate_tasks("xpto", f_xpto()) assert isinstance(tasks[0], Task) assert 4 == len(tasks) assert "xpto:0" == tasks[1].name assert not tasks[0].is_subtask assert tasks[1].is_subtask
def testGeneratorReturnTaskObj(self): def foo(base_name): for i in range(3): name = "%s-%d" % (base_name, i) yield Task(name, actions=["xpto -%d"%i]) tasks = generate_tasks("foo", foo('bar')) assert 3 == len(tasks) assert tasks[0].name == 'bar-0' assert tasks[1].name == 'bar-1' assert tasks[2].name == 'bar-2'
def testGeneratorBasename(self): def f_xpto(): for i in range(3): yield {'basename':str(i), 'actions' :["xpto"]} tasks = sorted(generate_tasks("xpto", f_xpto()), key=lambda t:t.name) assert isinstance(tasks[0], Task) assert 3 == len(tasks) assert "0" == tasks[0].name assert not tasks[0].is_subtask assert not tasks[1].is_subtask
def load_tasks(self, cmd, opt_values, pos_args): if self.quiet: DOIT_CONFIG = { 'verbosity': 0, 'reporter': 'zero', } else: DOIT_CONFIG = { 'reporter': ExecutedOnlyReporter, 'outfile': sys.stderr, } DOIT_CONFIG['default_tasks'] = ['render_site', 'post_render'] tasks = generate_tasks( 'render_site', self.nikola.gen_tasks('render_site', "Task", 'Group of tasks to render the site.')) latetasks = generate_tasks( 'post_render', self.nikola.gen_tasks('post_render', "LateTask", 'Group of tasks to be executes after site is rendered.')) return tasks + latetasks, DOIT_CONFIG
def testGeneratorBasenameName(self): def f_xpto(): for i in range(3): yield {'basename':'xpto', 'name':str(i), 'actions' :["a"]} tasks = sorted(generate_tasks("f_xpto", f_xpto())) assert isinstance(tasks[0], Task) assert 4 == len(tasks) assert "xpto" == tasks[0].name assert "xpto:0" == tasks[1].name assert not tasks[0].is_subtask assert tasks[1].is_subtask
def testGenerator(self): def f_xpto(): for i in range(3): yield {"name": str(i), "actions": ["xpto -%d" % i]} tasks = sorted(generate_tasks("xpto", f_xpto())) assert isinstance(tasks[0], Task) assert 4 == len(tasks) assert not tasks[0].is_subtask assert "xpto:0" == tasks[0].task_dep[0] assert "xpto:0" == tasks[1].name assert tasks[1].is_subtask
def load_tasks(self, cmd, opt_values, pos_args): """Load Nikola tasks.""" if self.quiet: DOIT_CONFIG = { 'verbosity': 0, 'reporter': 'zero', } else: DOIT_CONFIG = { 'reporter': ExecutedOnlyReporter, 'outfile': sys.stderr, } DOIT_CONFIG['default_tasks'] = ['render_site', 'post_render'] DOIT_CONFIG.update(self.nikola._doit_config) tasks = generate_tasks( 'render_site', self.nikola.gen_tasks('render_site', "Task", 'Group of tasks to render the site.')) latetasks = generate_tasks( 'post_render', self.nikola.gen_tasks('post_render', "LateTask", 'Group of tasks to be executed after site is rendered.')) signal('initialized').send(self.nikola) return tasks + latetasks, DOIT_CONFIG
def testMultiLevelGenerator(self): def f_xpto(base_name): """second level docstring""" for i in range(3): name = "%s-%d" % (base_name, i) yield {'name':name, 'actions' :["xpto -%d"%i]} def f_first_level(): for i in range(2): yield f_xpto(str(i)) tasks = generate_tasks("xpto", f_first_level()) assert isinstance(tasks[0], Task) assert 7 == len(tasks) assert not tasks[0].is_subtask assert f_xpto.__doc__ == tasks[0].doc assert tasks[1].is_subtask assert "xpto:0-0" == tasks[1].name assert "xpto:1-2" == tasks[-1].name
def testEmpty(self): tasks = generate_tasks('xx', None) assert len(tasks) == 0
def testUseDocstring(self): tasks = generate_tasks("dict",{'actions':['xpto 14']}, "my doc") assert "my doc" == tasks[0].doc
def testDocstringNotUsed(self): mytask = {'actions':['xpto 14'], 'doc':'from dict'} tasks = generate_tasks("dict", mytask, "from docstring") assert "from dict" == tasks[0].doc
def testBaseName(self): tasks = generate_tasks("function_name", {"basename": "real_task_name", "actions": ["xpto 14"]}) assert isinstance(tasks[0], Task) assert "real_task_name" == tasks[0].name
def testDict(self): tasks = generate_tasks("my_name", {'actions':['xpto 14']}) assert isinstance(tasks[0], Task) assert "my_name" == tasks[0].name
def testDocstringNotUsed(self): mytask = {"actions": ["xpto 14"], "doc": "from dict"} tasks = generate_tasks("dict", mytask, "from docstring") assert "from dict" == tasks[0].doc
def testTaskObj(self): tasks = generate_tasks("foo", Task('bar', None)) assert 1 == len(tasks) assert tasks[0].name == 'bar'
def testUseDocstring(self): tasks = generate_tasks("dict", {"actions": ["xpto 14"]}, "my doc") assert "my doc" == tasks[0].doc
def testDict(self): tasks = generate_tasks("dict",{'actions':['xpto 14']}) assert isinstance(tasks[0],Task)
def load_tasks(self, cmd, params, args): """implements loader interface, return (tasks, config)""" return generate_tasks(get_config('exp-prefix'), self._gen_tasks()), self.DOIT_CONFIG
def load_tasks(self, cmd, params, args): """implements loader interface, return (tasks, config)""" return generate_tasks('taskname that shows up in log', self._gen_tasks()), self.DOIT_CONFIG