Example #1
0
def toc_tasks(conf):
    toc_sources = conf.system.content.toc.sources

    tocs = TocDataCache(toc_sources, conf)

    if len(toc_sources) > 0 and not os.path.isdir(
            conf.system.content.toc.output_dir):
        safe_create_directory(conf.system.content.toc.output_dir)

    tasks = []
    for dep_fn, toc_data in tocs.file_iter():
        deps = [dep_fn]
        if 'ref-toc-' in dep_fn:
            base_offset = 8
        else:
            base_offset = 4

        fn_basename = os.path.basename(dep_fn)[base_offset:].replace(
            'yaml', 'rst')

        toc_items = toc_data.ordered_items()

        if toc_data.is_spec() is False:
            out_fn = os.path.join(conf.system.content.toc.output_dir,
                                  fn_basename)

            t = Task(job=write_toc_tree_output,
                     target=out_fn,
                     dependency=dep_fn,
                     description="writing toctree to '{0}'".format(out_fn))
            t.args = (out_fn, toc_items)
            tasks.append(t)
        else:
            deps.extend(toc_data.spec_deps())

        if 'ref-toc' in dep_fn:
            out_fn = os.path.join(conf.system.content.toc.output_dir,
                                  hyph_concat('table', fn_basename))

            reft = Task(
                job=write_toc_table,
                target=out_fn,
                dependency=deps,
                description="write table of contents generator".format(out_fn))
            reft.args = (out_fn, toc_items)
            tasks.append(reft)
        else:
            out_fn = os.path.join(conf.system.content.toc.output_dir,
                                  hyph_concat('dfn-list', fn_basename))
            dt = Task(job=write_dfn_list_output,
                      target=out_fn,
                      dependency=deps,
                      description="write definition list toc to '{0}'".format(
                          out_fn))
            dt.args = (out_fn, toc_items)
            tasks.append(dt)

    logger.info('added tasks for {0} toc generation tasks'.format(len(tasks)))

    return tasks
Example #2
0
def example_tasks(conf):
    # In the beginning of this operation, which executes in the main thread, we
    # read all files in "source/includes/" and sub-directories that start with
    # "example-*"

    example_sources = conf.system.content.examples.sources

    # process the corpus of example data.
    d = ExampleDataCache(example_sources, conf)

    if len(example_sources) > 0 and not os.path.isdir(
            conf.system.content.examples.output_dir):
        safe_create_directory(conf.system.content.examples.output_dir)

    tasks = []
    for fn, exmpf in d.file_iter():
        if exmpf.collection is None or exmpf.collection.options.base_file is True:
            continue
        basename = conf.system.content.examples.get_basename(fn)
        out_fn = os.path.join(conf.system.content.examples.output_dir,
                              basename) + '.rst'

        t = Task(
            job=write_full_example,
            description='generate an example for ' + fn,
            target=out_fn,
            dependency=fn,
        )
        t.args = (exmpf.collection, exmpf.examples, out_fn)

        tasks.append(t)

    logger.info("added tasks for {0} example generation tasks".format(
        len(tasks)))
    return tasks
Example #3
0
def step_tasks(conf):
    step_sources = conf.system.content.steps.sources
    s = StepDataCache(step_sources, conf)

    if len(step_sources) > 0 and not os.path.isdir(
            conf.system.content.steps.output_dir):
        safe_create_directory(conf.system.content.steps.output_dir)

    tasks = []
    for fn, stepf in s.file_iter():
        basename = conf.system.content.steps.get_basename(fn)

        out_fn = os.path.join(conf.system.content.steps.output_dir,
                              basename) + '.rst'

        t = Task(job=write_steps,
                 description='generate a stepfile for ' + fn,
                 target=out_fn,
                 dependency=fn)
        t.args = (stepf, out_fn, conf)

        tasks.append(t)

    logger.info("added tasks for {0} step generation tasks".format(len(tasks)))
    return tasks
Example #4
0
def option_tasks(conf):
    option_sources = conf.system.content.options.sources
    o = OptionDataCache(option_sources, conf)

    if len(option_sources) > 0 and not os.path.isdir(
            conf.system.content.options.output_dir):
        safe_create_directory(conf.system.content.options.output_dir)

    tasks = []
    for dep_fn, option in o.content_iter():
        if option.program.startswith('_'):
            continue

        out_fn = hyph_concat(option.directive, option.program,
                             option.name) + '.rst'
        output_fn = os.path.join(conf.system.content.options.fn_prefix, out_fn)

        t = Task(job=write_options,
                 description='generating option file "{0}" from "{1}"'.format(
                     output_fn, dep_fn),
                 target=output_fn,
                 dependency=[dep_fn])
        t.args = (option, output_fn, conf)

        tasks.append(t)

    logger.info("added tasks for {0} option generation tasks".format(
        len(tasks)))
    return tasks
Example #5
0
    def test_single_runner_task(self):
        self.assertEqual(self.app.queue, [])
        self.assertEqual(self.app.results, [])

        t = Task()
        t.job = sum
        t.args = [[ 1 , 2 ], 0]

        self.app._run_single(t)
        self.assertEqual(self.app.results[0], 3)
Example #6
0
    def test_single_runner_task(self):
        self.assertEqual(self.app.queue, [])
        self.assertEqual(self.app.results, [])

        t = Task()
        t.job = sum
        t.args = [[ 1 , 2 ], 0]

        self.app._run_single(t)
        self.assertEqual(self.app.results[0], 3)
Example #7
0
def extract_tasks(conf):
    extract_sources = conf.system.content.extracts.sources

    extracts = ExtractDataCache(extract_sources, conf)

    if len(extract_sources) > 0 and not os.path.isdir(
            conf.system.content.extracts.output_dir):
        safe_create_directory(conf.system.content.extracts.output_dir)

    tasks = []
    for dep_fn, extract in extracts.content_iter():
        t = Task(job=write_extract_file,
                 description="generating extract file: " + extract.target,
                 target=extract.target,
                 dependency=dep_fn)
        t.args = (extract, extract.target)
        tasks.append(t)

        include_statement = get_include_statement(extract.target_project_path)

        for verb, adjc, noun in [(prepend_to_file, 'prepend', extract.prepend),
                                 (append_to_file, 'append', extract.append)]:
            if noun:
                if not isinstance(noun, list):
                    files = [noun]
                else:
                    files = noun

                for fn in files:
                    t = Task(
                        job=verb,
                        target=fn,
                        dependency=dep_fn,
                        description="{0} extract include for '{0}' to '{1}'".
                        format(adjc, extract.target, fn))
                    t.args = (fn, include_statement)
                    tasks.append(t)

    logger.info("added tasks for {0} extract generation tasks".format(
        len(tasks)))

    return tasks
Example #8
0
def release_tasks(conf):
    release_sources = conf.system.content.releases.sources

    rel = ReleaseDataCache(release_sources, conf)

    if len(release_sources) > 0 and not os.path.isdir(
            conf.system.content.releases.output_dir):
        safe_create_directory(conf.system.content.releases.output_dir)

    tasks = []

    for dep_fn, release in rel.content_iter():
        t = Task(job=write_release_file,
                 description='generating release spec file: ' + release.target,
                 target=release.target,
                 dependency=dep_fn)
        t.args = (release, release.target, conf)

        tasks.append(t)

    logger.info("added tasks for {0} release generation tasks".format(
        len(tasks)))
    return tasks