New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lint extra #350
Lint extra #350
Changes from 8 commits
0a122a9
bb99d5a
a4a1a0f
ba88462
27da608
64011d6
44f16ba
c9b482f
d92927d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
|
||
def is_datasource(tool_xml): | ||
"""Returns true if the tool is a datasource tool""" | ||
return tool_xml.getroot().attrib.get('tool_type', '') == 'data_source' |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,16 +17,37 @@ | |
'citations', | ||
] | ||
|
||
DATASOURCE_TAG_ORDER = [ | ||
'description', | ||
'command', | ||
'inputs', | ||
'request_param_translation', | ||
'uihints', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are uihints even respected for data source tools? Hmm... we can revisit that later though. Can you add macros and configfiles back in the same order as normal tools? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's an awful good question regarding uihints. Yes, sorry, I removed everything I didn't see during very brief greps through the tools directory. |
||
'outputs', | ||
'options', | ||
'help', | ||
'citations', | ||
] | ||
|
||
|
||
# Ensure the XML blocks appear in the correct order prescribed | ||
# by the tool author best practices. | ||
def lint_xml_order(tool_xml, lint_ctx): | ||
tool_root = tool_xml.getroot() | ||
|
||
if tool_root.attrib.get('tool_type', '') == 'data_source': | ||
_validate_for_tags(tool_root, lint_ctx, DATASOURCE_TAG_ORDER) | ||
else: | ||
_validate_for_tags(tool_root, lint_ctx, TAG_ORDER) | ||
|
||
|
||
def _validate_for_tags(root, lint_ctx, tag_ordering): | ||
last_tag = None | ||
last_key = None | ||
for elem in list(tool_xml.getroot()): | ||
for elem in root: | ||
tag = elem.tag | ||
if tag in TAG_ORDER: | ||
key = TAG_ORDER.index(tag) | ||
if tag in tag_ordering: | ||
key = tag_ordering.index(tag) | ||
if last_key: | ||
if last_key > key: | ||
lint_ctx.warn("Best practice violation [%s] elements should come before [%s]" % (tag, last_tag)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can have a boolean. According to https://github.com/galaxy-iuc/standards/blob/master/docs/best_practices/tool_xml.rst#booleans we do not recommend to use booleans for a conditional but it is possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting. Thanks for that, I'll update it accordingly