Mercurial > repos > guerler > springsuite
diff planemo/lib/python3.7/site-packages/galaxy/tool_util/linters/citations.py @ 1:56ad4e20f292 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author | guerler |
---|---|
date | Fri, 31 Jul 2020 00:32:28 -0400 (2020-07-31) |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/planemo/lib/python3.7/site-packages/galaxy/tool_util/linters/citations.py Fri Jul 31 00:32:28 2020 -0400 @@ -0,0 +1,35 @@ +"""This module contains a citation lint function. + +Citations describe references that should be used when consumers +of the tool publish results. +""" + + +def lint_citations(tool_xml, lint_ctx): + """Ensure tool contains at least one valid citation.""" + root = tool_xml.getroot() + citations = root.findall("citations") + if len(citations) > 1: + lint_ctx.error("More than one citation section found, behavior undefined.") + return + + if len(citations) == 0: + lint_ctx.warn("No citations found, consider adding citations to your tool.") + return + + valid_citations = 0 + for citation in citations[0]: + if citation.tag != "citation": + lint_ctx.warn("Unknown tag discovered in citations block [%s], will be ignored." % citation.tag) + continue + citation_type = citation.attrib.get("type") + if citation_type not in ('bibtex', 'doi'): + lint_ctx.warn("Unknown citation type discovered [%s], will be ignored.", citation_type) + continue + if citation.text is None or not citation.text.strip(): + lint_ctx.error('Empty %s citation.' % citation_type) + continue + valid_citations += 1 + + if valid_citations > 0: + lint_ctx.valid("Found %d likely valid citations.", valid_citations)