comparison planemo/lib/python3.7/site-packages/galaxy/tool_util/linters/command.py @ 1:56ad4e20f292 draft

"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author guerler
date Fri, 31 Jul 2020 00:32:28 -0400
parents
children
comparison
equal deleted inserted replaced
0:d30785e31577 1:56ad4e20f292
1 """This module contains a linting function for a tool's command description.
2
3 A command description describes how to build the command-line to execute
4 from supplied inputs.
5 """
6
7
8 def lint_command(tool_xml, lint_ctx):
9 """Ensure tool contains exactly one command and check attributes."""
10 root = tool_xml.getroot()
11 commands = root.findall("command")
12 if len(commands) > 1:
13 lint_ctx.error("More than one command tag found, behavior undefined.")
14 return
15
16 if len(commands) == 0:
17 lint_ctx.error("No command tag found, must specify a command template to execute.")
18 return
19
20 command = get_command(tool_xml)
21 if "TODO" in command:
22 lint_ctx.warn("Command template contains TODO text.")
23
24 command_attrib = command.attrib
25 interpreter_type = None
26 for key, value in command_attrib.items():
27 if key == "interpreter":
28 interpreter_type = value
29 elif key == "detect_errors":
30 detect_errors = value
31 if detect_errors not in ["default", "exit_code", "aggressive"]:
32 lint_ctx.warn("Unknown detect_errors attribute [%s]" % detect_errors)
33
34 interpreter_info = ""
35 if interpreter_type:
36 interpreter_info = " with interpreter of type [%s]" % interpreter_type
37 if interpreter_type:
38 lint_ctx.info("Command uses deprecated 'interpreter' attribute.")
39 lint_ctx.info("Tool contains a command%s." % interpreter_info)
40
41
42 def get_command(tool_xml):
43 """Get command XML element from supplied XML root."""
44 root = tool_xml.getroot()
45 commands = root.findall("command")
46 command = None
47 if len(commands) == 1:
48 command = commands[0]
49 return command