How to use the planemo.templates.render function in planemo

To help you get started, we’ve selected a few planemo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github galaxyproject / planemo / planemo / tool_builder.py View on Github external
def _render(kwds, template_str=TOOL_TEMPLATE):
    """ Apply supplied template variables to TOOL_TEMPLATE to generate
    the final tool.
    """
    return templates.render(template_str, **kwds)
github galaxyproject / planemo / planemo / training / tool_input.py View on Github external
for ind, param in enumerate(tmp_wf_param_values):
            self.wf_param_values = param
            self.level = cur_level + 1
            paramlist_in_repeat = self.get_lower_param_desc()
            if paramlist_in_repeat != '':
                # add first click
                repeat_paramlist += templates.render(INPUT_ADD_REPEAT, **{
                    'space': SPACE * (self.level),
                    'repeat_label': self.tool_inp_desc['title']})
                repeat_paramlist += paramlist_in_repeat
            self.level = cur_level
        self.wf_param_values = tmp_wf_param_values

        repeat_desc = ''
        if repeat_paramlist != '':
            repeat_desc += templates.render(INPUT_SECTION, **{
                'space': SPACE * self.level,
                'section_label': self.tool_inp_desc['title']}) + repeat_paramlist
        return repeat_desc
github galaxyproject / planemo / planemo / training / tutorial.py View on Github external
def write_hands_on_tutorial(self, add_z_file_links=True):
        """Write the content of the hands-on tutorial in the corresponding file."""
        if add_z_file_links:
            self.body = templates.render(TUTO_HAND_ON_BODY_TEMPLATE, **{
                "z_file_links": "\n>    ".join(self.zenodo_file_links),
                "body": self.body
            })
        # write in the tutorial file with the metadata on the top
        metadata = self.get_tuto_metata()
        with open(self.tuto_fp, 'w') as md:
            md.write(templates.render(TUTO_HAND_ON_TEMPLATE, **{
                "metadata": metadata,
                "body": self.body
            }))

        # create the bibliography file
        self.write_bibliography()
github galaxyproject / planemo / planemo / shed / __init__.py View on Github external
tool_id=tool_id,
            tool_name=tool_name,
            description=description,
        )
        other_paths = paths[:]
        other_paths.remove(tool_path)
        tool_excludes = excludes + list(other_paths)
        repo_dict = {
            "include": default_include,
            "exclude": tool_excludes,
        }
        for key in ["name", "description", "long_description"]:
            template_key = "%s_template" % key
            template = auto_tool_repos.get(template_key)
            if template:
                value = templates.render(template, **template_vars)
                repo_dict[key] = value
        return repo_dict
github galaxyproject / planemo / planemo / training.py View on Github external
def format_repeat_param_desc(step_params, step_inputs, tp_desc, level, wf_steps):
    """Format the description (label and value) for parameters in a repeat"""
    repeat_inp_desc = get_tool_input(tp_desc)
    params = get_lower_params(step_params, tp_desc['name'])
    inputs = get_lower_inputs(step_inputs, tp_desc['name'])
    repeat_paramlist = ''
    for r in range(len(params)):
        r_inputs = inputs[str(r)] if str(r) in inputs else inputs
        paramlist_in_repeat = get_param_desc(params[r], r_inputs, repeat_inp_desc, level+2, wf_steps)
        if paramlist_in_repeat != '':
            # add first click
            context = {'space': SPACE * (level+1), 'repeat_label': tp_desc['title']}
            repeat_paramlist += templates.render(INPUT_ADD_REPEAT, **context)
            # add description of parameters in the repeat
            context = {
                'space': SPACE * (level+1),
                'section_label': "%s: %s" % (r+1, tp_desc['title'])}
            repeat_paramlist += templates.render(INPUT_SECTION, **context)
            repeat_paramlist += paramlist_in_repeat
    if repeat_paramlist != '':
        context = {'space': SPACE * level, 'section_label': tp_desc['title']}
        repeat_paramlist = templates.render(INPUT_SECTION, **context) + repeat_paramlist
    return repeat_paramlist
github galaxyproject / planemo / planemo / training / tool_input.py View on Github external
def get_formatted_repeat_desc(self):
        """Format the description (label and value) for parameters in a repeat."""
        tool_inp = {}
        for inp in self.tool_inp_desc["inputs"]:
            tool_inp.setdefault(inp['name'], inp)
        repeat_paramlist = ''
        tmp_wf_param_values = self.wf_param_values
        cur_level = self.level
        for ind, param in enumerate(tmp_wf_param_values):
            self.wf_param_values = param
            self.level = cur_level + 1
            paramlist_in_repeat = self.get_lower_param_desc()
            if paramlist_in_repeat != '':
                # add first click
                repeat_paramlist += templates.render(INPUT_ADD_REPEAT, **{
                    'space': SPACE * (self.level),
                    'repeat_label': self.tool_inp_desc['title']})
                repeat_paramlist += paramlist_in_repeat
            self.level = cur_level
        self.wf_param_values = tmp_wf_param_values

        repeat_desc = ''
        if repeat_paramlist != '':
            repeat_desc += templates.render(INPUT_SECTION, **{
                'space': SPACE * self.level,
                'section_label': self.tool_inp_desc['title']}) + repeat_paramlist
        return repeat_desc
github galaxyproject / planemo / planemo / training / tutorial.py View on Github external
def write_bibliography(self):
        """Write the content of the bibliography file for the tutorial."""
        with open(self.bib_fp, 'w') as bib:
            bib.write(templates.render(TUTO_BIBLIOGRAPHY_TEMPLATE, **{
                "body": self.body
            }))
github galaxyproject / planemo / planemo / training.py View on Github external
paramlist += format_inputs(step_inputs, tp_desc, wf_steps, level)
        # info("data_collection parameters are currently not supported")
    elif tp_desc['type'] == 'section':
        paramlist += format_section_param_desc(step_params, step_inputs, tp_desc, level, wf_steps)
    elif tp_desc['type'] == 'conditional':
        paramlist += format_conditional_param_desc(step_params, step_inputs, tp_desc, level, wf_steps)
    elif tp_desc['type'] == 'repeat':
        paramlist += format_repeat_param_desc(step_params, step_inputs, tp_desc, level, wf_steps)
    else:
        param_value = get_param_value(step_params, tp_desc, force_default)
        if param_value is not None:
            context = {
                'space': SPACE * level,
                'param_label': tp_desc['label'],
                'param_value': param_value}
            paramlist += templates.render(INPUT_PARAM, **context)
    return paramlist
github galaxyproject / planemo / planemo / training / tool_input.py View on Github external
def get_empty_input():
    """Get the string for an empty input."""
    return templates.render(INPUT_FILE_TEMPLATE, **{
        'space': 1 * SPACE,
        'icon': 'param-file',
        'input_name': 'Input file',
        'input_value': 'File'
    })
github galaxyproject / planemo / planemo / training / tutorial.py View on Github external
# extract the data library from Zenodo and the links for the tutorial
        if self.zenodo_link != '':
            info("Create the data library from Zenodo")
            self.prepare_data_library_from_zenodo()

        # create tutorial skeleton from workflow and copy workflow file
        if self.hands_on:
            info("Create tutorial skeleton from workflow (if it is provided)")
            self.create_hands_on_tutorial(ctx)
            self.export_workflow_file()

        # create slide skeleton
        if self.slides:
            with open(self.slide_fp, 'w') as slide_f:
                slide_f.write(
                    templates.render(TUTO_SLIDES_TEMPLATE, **{"metadata": self.get_tuto_metata()}))