Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/galaxy/tool_util/linters/stdio.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 functions for tool error detection.""" | |
| 2 from .command import get_command | |
| 3 | |
| 4 | |
| 5 def lint_stdio(tool_source, lint_ctx): | |
| 6 tool_xml = getattr(tool_source, "xml_tree", None) | |
| 7 stdios = tool_xml.findall("./stdio") if tool_xml else [] | |
| 8 | |
| 9 if not stdios: | |
| 10 command = get_command(tool_xml) if tool_xml else None | |
| 11 if command is None or not command.get("detect_errors"): | |
| 12 if tool_source.parse_profile() <= "16.01": | |
| 13 lint_ctx.info("No stdio definition found, tool indicates error conditions with output written to stderr.") | |
| 14 else: | |
| 15 lint_ctx.info("No stdio definition found, tool indicates error conditions with non-zero exit codes.") | |
| 16 return | |
| 17 | |
| 18 if len(stdios) > 1: | |
| 19 lint_ctx.error("More than one stdio tag found, behavior undefined.") | |
| 20 return | |
| 21 | |
| 22 stdio = stdios[0] | |
| 23 for child in list(stdio): | |
| 24 if child.tag == "regex": | |
| 25 _lint_regex(child, lint_ctx) | |
| 26 elif child.tag == "exit_code": | |
| 27 _lint_exit_code(child, lint_ctx) | |
| 28 else: | |
| 29 message = "Unknown stdio child tag discovered [%s]. " | |
| 30 message += "Valid options are exit_code and regex." | |
| 31 lint_ctx.warn(message % child.tag) | |
| 32 | |
| 33 | |
| 34 def _lint_exit_code(child, lint_ctx): | |
| 35 for key in child.attrib.keys(): | |
| 36 if key not in ["description", "level", "range"]: | |
| 37 lint_ctx.warn("Unknown attribute [%s] encountered on exit_code tag." % key) | |
| 38 | |
| 39 | |
| 40 def _lint_regex(child, lint_ctx): | |
| 41 for key in child.attrib.keys(): | |
| 42 if key not in ["description", "level", "match", "source"]: | |
| 43 lint_ctx.warn("Unknown attribute [%s] encountered on regex tag." % key) | 
