comparison env/lib/python3.7/site-packages/planemo/linters/conda_requirements.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 """Ensure requirements are matched in best practice conda channels."""
2
3 from planemo.conda import (
4 BEST_PRACTICE_CHANNELS,
5 best_practice_search,
6 tool_source_conda_targets,
7 )
8
9 lint_tool_types = ["*"]
10
11
12 def lint_requirements_in_conda(tool_source, lint_ctx):
13 """Check requirements of tool source against best practice Conda channels."""
14 conda_targets = tool_source_conda_targets(tool_source)
15 if not conda_targets:
16 lint_ctx.warn("No valid package requirement tags found to check against Conda.")
17 return
18
19 for conda_target in conda_targets:
20 (best_hit, exact) = best_practice_search(conda_target)
21 conda_target_str = conda_target.package
22 if conda_target.version:
23 conda_target_str += "@%s" % (conda_target.version)
24 if best_hit and exact:
25 template = "Requirement [%s] matches target in best practice Conda channel [%s]."
26 message = template % (conda_target_str, best_hit.get("channel"))
27 lint_ctx.info(message)
28 elif best_hit:
29 template = "Requirement [%s] doesn't exactly match available version [%s] in best practice Conda channel [%s]."
30 message = template % (conda_target_str, best_hit['version'], best_hit.get("channel"))
31 lint_ctx.warn(message)
32 else:
33 template = "Requirement [%s] doesn't match any recipe in a best practice conda channel [%s]."
34 message = template % (conda_target_str, BEST_PRACTICE_CHANNELS)
35 lint_ctx.warn(message)