Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/galaxy/tool_util/linters/citations.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 """This module contains a citation lint function. | |
2 | |
3 Citations describe references that should be used when consumers | |
4 of the tool publish results. | |
5 """ | |
6 | |
7 | |
8 def lint_citations(tool_xml, lint_ctx): | |
9 """Ensure tool contains at least one valid citation.""" | |
10 root = tool_xml.getroot() | |
11 citations = root.findall("citations") | |
12 if len(citations) > 1: | |
13 lint_ctx.error("More than one citation section found, behavior undefined.") | |
14 return | |
15 | |
16 if len(citations) == 0: | |
17 lint_ctx.warn("No citations found, consider adding citations to your tool.") | |
18 return | |
19 | |
20 valid_citations = 0 | |
21 for citation in citations[0]: | |
22 if citation.tag != "citation": | |
23 lint_ctx.warn("Unknown tag discovered in citations block [%s], will be ignored." % citation.tag) | |
24 continue | |
25 citation_type = citation.attrib.get("type") | |
26 if citation_type not in ('bibtex', 'doi'): | |
27 lint_ctx.warn("Unknown citation type discovered [%s], will be ignored.", citation_type) | |
28 continue | |
29 if citation.text is None or not citation.text.strip(): | |
30 lint_ctx.error('Empty %s citation.' % citation_type) | |
31 continue | |
32 valid_citations += 1 | |
33 | |
34 if valid_citations > 0: | |
35 lint_ctx.valid("Found %d likely valid citations.", valid_citations) |