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 linters for a tool's command description.
A command description describes how to build the command-line to execute
from supplied inputs.
"""
from typing import TYPE_CHECKING
from galaxy.tool_util.lint import Linter
if TYPE_CHECKING:
from galaxy.tool_util.lint import LintContext
from galaxy.tool_util.parser.interface import ToolSource
[docs]class CommandMissing(Linter):
[docs] @classmethod
def lint(cls, tool_source: "ToolSource", lint_ctx: "LintContext"):
tool_xml = getattr(tool_source, "xml_tree", None)
if not tool_xml:
return
root = tool_xml.find("./command")
if root is None:
root = tool_xml.getroot()
command = tool_xml.find("./command")
if command is None:
lint_ctx.error(
"No command tag found, must specify a command template to execute.", linter=cls.name(), node=root
)
[docs]class CommandEmpty(Linter):
[docs] @classmethod
def lint(cls, tool_source: "ToolSource", lint_ctx: "LintContext"):
tool_xml = getattr(tool_source, "xml_tree", None)
if not tool_xml:
return
root = tool_xml.find("./command")
if root is None:
root = tool_xml.getroot()
command = tool_xml.find("./command")
if command is not None and command.text is None:
lint_ctx.error("Command is empty.", linter=cls.name(), node=root)
[docs]class CommandTODO(Linter):
[docs] @classmethod
def lint(cls, tool_source: "ToolSource", lint_ctx: "LintContext"):
tool_xml = getattr(tool_source, "xml_tree", None)
if not tool_xml:
return
command = tool_xml.find("./command")
if command is not None and command.text is not None and "TODO" in command.text:
lint_ctx.warn("Command template contains TODO text.", linter=cls.name(), node=command)
[docs]class CommandInterpreterDeprecated(Linter):
[docs] @classmethod
def lint(cls, tool_source: "ToolSource", lint_ctx: "LintContext"):
tool_xml = getattr(tool_source, "xml_tree", None)
if not tool_xml:
return
command = tool_xml.find("./command")
if command is None:
return
interpreter_type = command.attrib.get("interpreter", None)
if interpreter_type is not None:
lint_ctx.warn("Command uses deprecated 'interpreter' attribute.", linter=cls.name(), node=command)
[docs]class CommandInfo(Linter):
[docs] @classmethod
def lint(cls, tool_source: "ToolSource", lint_ctx: "LintContext"):
tool_xml = getattr(tool_source, "xml_tree", None)
if not tool_xml:
return
command = tool_xml.find("./command")
if command is None:
return
interpreter_type = command.attrib.get("interpreter", None)
interpreter_info = ""
if interpreter_type:
interpreter_info = f" with interpreter of type [{interpreter_type}]"
lint_ctx.info(f"Tool contains a command{interpreter_info}.", linter=cls.name(), node=command)