Warning

This document is for an in-development version of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.

Source code for galaxy.tool_util.linters.command

"""This module contains a linting function for a tool's command description.

A command description describes how to build the command-line to execute
from supplied inputs.
"""


[docs]def lint_command(tool_xml, lint_ctx): """Ensure tool contains exactly one command and check attributes.""" root = tool_xml.getroot() commands = root.findall("command") if len(commands) > 1: lint_ctx.error("More than one command tag found, behavior undefined.") return if len(commands) == 0: lint_ctx.error("No command tag found, must specify a command template to execute.") return command = get_command(tool_xml) if "TODO" in command: lint_ctx.warn("Command template contains TODO text.") command_attrib = command.attrib interpreter_type = None for key, value in command_attrib.items(): if key == "interpreter": interpreter_type = value elif key == "detect_errors": detect_errors = value if detect_errors not in ["default", "exit_code", "aggressive"]: lint_ctx.warn("Unknown detect_errors attribute [%s]" % detect_errors) interpreter_info = "" if interpreter_type: interpreter_info = " with interpreter of type [%s]" % interpreter_type if interpreter_type: lint_ctx.info("Command uses deprecated 'interpreter' attribute.") lint_ctx.info("Tool contains a command%s." % interpreter_info)
[docs]def get_command(tool_xml): """Get command XML element from supplied XML root.""" root = tool_xml.getroot() commands = root.findall("command") command = None if len(commands) == 1: command = commands[0] return command