|
1 | 1 |
|
2 | 2 |
|
3 | 3 | def lint_output(tool_xml, lint_ctx):
|
4 |
| - outputs = tool_xml.findall("./outputs/data") |
5 |
| - if not outputs: |
6 |
| - lint_ctx.warn("Tool contains no outputs, most tools should produce outputs.") |
7 |
| - return |
| 4 | + outputs = tool_xml.findall("./outputs") |
| 5 | + if len(outputs) == 0: |
| 6 | + lint_ctx.warn("Tool contains no outputs section, most tools should produce outputs.") |
| 7 | + if len(outputs) > 1: |
| 8 | + lint_ctx.warn("Tool contains multiple output sections, behavior undefined.") |
8 | 9 |
|
9 | 10 | num_outputs = 0
|
10 |
| - for output in outputs: |
| 11 | + for output in list(outputs[0]): |
| 12 | + if output.tag not in ["data", "collection"]: |
| 13 | + lint_ctx.warn("Unknown element found in outputs [%s]" % output.tag) |
| 14 | + continue |
11 | 15 | num_outputs += 1
|
12 | 16 | output_attrib = output.attrib
|
13 |
| - format_set = False |
14 |
| - if "format" in output_attrib: |
15 |
| - format_set = True |
16 |
| - format = output_attrib["format"] |
17 |
| - if format == "input": |
18 |
| - lint_ctx.warn("Using format='input' on output data, format_source attribute is less ambiguous and should be used instead.") |
19 |
| - elif "format_source" in output_attrib: |
20 |
| - format_set = True |
21 |
| - |
22 |
| - if not format_set: |
23 |
| - lint_ctx.warn("Tool data output doesn't define an output format.") |
24 |
| - |
25 |
| - lint_ctx.info("%d output datasets found.", num_outputs) |
| 17 | + if output.tag == "data": |
| 18 | + format_set = False |
| 19 | + if "format" in output_attrib: |
| 20 | + format_set = True |
| 21 | + format = output_attrib["format"] |
| 22 | + if format == "input": |
| 23 | + lint_ctx.warn("Using format='input' on output data, format_source attribute is less ambiguous and should be used instead.") |
| 24 | + elif "format_source" in output_attrib: |
| 25 | + format_set = True |
| 26 | + if not format_set: |
| 27 | + lint_ctx.warn("Tool data output doesn't define an output format.") |
| 28 | + elif output.tag == "collection": |
| 29 | + if "type" not in output_attrib: |
| 30 | + lint_ctx.warn("Collection output with undefined 'type' found.") |
| 31 | + lint_ctx.info("%d outputs found.", num_outputs) |
0 commit comments