Mercurial > repos > shellac > guppy_basecaller
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/env/lib/python3.7/site-packages/planemo/tool_lint.py Thu May 14 14:56:58 2020 -0400 @@ -0,0 +1,49 @@ +from __future__ import absolute_import + +from os.path import basename + +from galaxy.tool_util.lint import lint_tool_source + +from planemo.exit_codes import ( + EXIT_CODE_GENERIC_FAILURE, + EXIT_CODE_OK, +) +from planemo.io import ( + coalesce_return_codes, + error, + info, +) +from planemo.tools import ( + is_tool_load_error, + yield_tool_sources_on_paths, +) + +LINTING_TOOL_MESSAGE = "Linting tool %s" + + +def lint_tools_on_path(ctx, paths, lint_args, **kwds): + assert_tools = kwds.get("assert_tools", True) + recursive = kwds.get("recursive", False) + exit_codes = [] + for (tool_path, tool_xml) in yield_tool_sources_on_paths(ctx, paths, recursive): + if handle_tool_load_error(tool_path, tool_xml): + exit_codes.append(EXIT_CODE_GENERIC_FAILURE) + continue + info("Linting tool %s" % tool_path) + if not lint_tool_source(tool_xml, name=basename(tool_path), **lint_args): + error("Failed linting") + exit_codes.append(EXIT_CODE_GENERIC_FAILURE) + else: + exit_codes.append(EXIT_CODE_OK) + return coalesce_return_codes(exit_codes, assert_at_least_one=assert_tools) + + +def handle_tool_load_error(tool_path, tool_xml): + """ Return True if tool_xml is tool load error (invalid XML), and + print a helpful error message. + """ + is_error = False + if is_tool_load_error(tool_xml): + info("Could not lint %s due to malformed xml." % tool_path) + is_error = True + return is_error