Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/planemo/linters/xsd.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 """Tool linting module that lints Galaxy tool against experimental XSD.""" | |
| 2 import copy | |
| 3 import os | |
| 4 import tempfile | |
| 5 | |
| 6 import galaxy.tool_util | |
| 7 | |
| 8 import planemo.lint | |
| 9 | |
| 10 TOOL_XSD = os.path.join(os.path.dirname(galaxy.tool_util.__file__), 'xsd', "galaxy.xsd") | |
| 11 | |
| 12 | |
| 13 def lint_tool_xsd(tool_xml, lint_ctx): | |
| 14 """Write a temp file out and lint it.""" | |
| 15 with tempfile.NamedTemporaryFile() as tf: | |
| 16 _clean_root(tool_xml).write(tf.name) | |
| 17 planemo.lint.lint_xsd(lint_ctx, TOOL_XSD, tf.name) | |
| 18 | |
| 19 | |
| 20 def _clean_root(tool_xml): | |
| 21 """XSD assumes macros have been expanded, so remove them.""" | |
| 22 clean_tool_xml = copy.deepcopy(tool_xml) | |
| 23 to_remove = [] | |
| 24 for macros_el in clean_tool_xml.getroot().findall("macros"): | |
| 25 to_remove.append(macros_el) | |
| 26 for macros_el in to_remove: | |
| 27 clean_tool_xml.getroot().remove(macros_el) | |
| 28 return clean_tool_xml |
