Mercurial > repos > bcclaywell > argo_navis
comparison venv/lib/python2.7/site-packages/planemo/linters/xsd.py @ 0:d67268158946 draft
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
author | bcclaywell |
---|---|
date | Mon, 12 Oct 2015 17:43:33 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d67268158946 |
---|---|
1 """ Tool linting module that lints Galaxy tool against experimental XSD. | |
2 """ | |
3 import copy | |
4 import os | |
5 import tempfile | |
6 | |
7 from planemo.xml import XSDS_PATH | |
8 import planemo.lint | |
9 | |
10 TOOL_XSD = os.path.join(XSDS_PATH, "tool", "galaxy.xsd") | |
11 | |
12 | |
13 def lint_tool_xsd(root, lint_ctx): | |
14 """ Write a temp file out and lint it. | |
15 """ | |
16 with tempfile.NamedTemporaryFile() as tf: | |
17 _clean_root(root).write(tf.name) | |
18 planemo.lint.lint_xsd(lint_ctx, TOOL_XSD, tf.name) | |
19 | |
20 | |
21 def _clean_root(root): | |
22 """ XSD assumes macros have been expanded, so remove them. | |
23 """ | |
24 clean_root = copy.deepcopy(root) | |
25 to_remove = [] | |
26 for macros_el in clean_root.findall("macros"): | |
27 to_remove.append(macros_el) | |
28 for macros_el in to_remove: | |
29 clean_root.getroot().remove(macros_el) | |
30 return clean_root |