Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/planemo/tool_lint.py @ 2:6af9afd405e9 draft
"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
author | shellac |
---|---|
date | Thu, 14 May 2020 14:56:58 -0400 |
parents | 26e78fe6e8c4 |
children |
comparison
equal
deleted
inserted
replaced
1:75ca89e9b81c | 2:6af9afd405e9 |
---|---|
1 from __future__ import absolute_import | |
2 | |
3 from os.path import basename | |
4 | |
5 from galaxy.tool_util.lint import lint_tool_source | |
6 | |
7 from planemo.exit_codes import ( | |
8 EXIT_CODE_GENERIC_FAILURE, | |
9 EXIT_CODE_OK, | |
10 ) | |
11 from planemo.io import ( | |
12 coalesce_return_codes, | |
13 error, | |
14 info, | |
15 ) | |
16 from planemo.tools import ( | |
17 is_tool_load_error, | |
18 yield_tool_sources_on_paths, | |
19 ) | |
20 | |
21 LINTING_TOOL_MESSAGE = "Linting tool %s" | |
22 | |
23 | |
24 def lint_tools_on_path(ctx, paths, lint_args, **kwds): | |
25 assert_tools = kwds.get("assert_tools", True) | |
26 recursive = kwds.get("recursive", False) | |
27 exit_codes = [] | |
28 for (tool_path, tool_xml) in yield_tool_sources_on_paths(ctx, paths, recursive): | |
29 if handle_tool_load_error(tool_path, tool_xml): | |
30 exit_codes.append(EXIT_CODE_GENERIC_FAILURE) | |
31 continue | |
32 info("Linting tool %s" % tool_path) | |
33 if not lint_tool_source(tool_xml, name=basename(tool_path), **lint_args): | |
34 error("Failed linting") | |
35 exit_codes.append(EXIT_CODE_GENERIC_FAILURE) | |
36 else: | |
37 exit_codes.append(EXIT_CODE_OK) | |
38 return coalesce_return_codes(exit_codes, assert_at_least_one=assert_tools) | |
39 | |
40 | |
41 def handle_tool_load_error(tool_path, tool_xml): | |
42 """ Return True if tool_xml is tool load error (invalid XML), and | |
43 print a helpful error message. | |
44 """ | |
45 is_error = False | |
46 if is_tool_load_error(tool_xml): | |
47 info("Could not lint %s due to malformed xml." % tool_path) | |
48 is_error = True | |
49 return is_error |