Skip to content
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

XSD Updates #566

Merged
merged 2 commits into from
Sep 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "planemo/xml/xsd/tool"]
path = planemo/xml/xsd/tool
url = https://github.com/JeanFred/Galaxy-XSD
[submodule "planemo/cwl/cwl2script"]
path = planemo/cwl/cwl2script
url = https://github.com/common-workflow-language/cwl2script.git
Expand Down
8 changes: 4 additions & 4 deletions planemo/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
from planemo.xml import validation


def lint_dois(root, lint_ctx):
dois = find_dois_for_xml(root)
def lint_dois(tool_xml, lint_ctx):
dois = find_dois_for_xml(tool_xml)
for publication in dois:
is_doi(publication, lint_ctx)


def find_dois_for_xml(root):
def find_dois_for_xml(tool_xml):
dois = []
for element in root.root.findall("citations"):
for element in tool_xml.getroot().findall("citations"):
for citation in list(element):
if citation.tag == 'citation' and citation.attrib.get('type', '') == 'doi':
dois.append(citation.text)
Expand Down
4 changes: 2 additions & 2 deletions planemo/linters/doi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import planemo.lint


def lint_tool_dois(root, lint_ctx):
planemo.lint.lint_dois(root, lint_ctx)
def lint_tool_dois(tool_xml, lint_ctx):
planemo.lint.lint_dois(tool_xml, lint_ctx)
14 changes: 7 additions & 7 deletions planemo/linters/xsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
TOOL_XSD = os.path.join(XSDS_PATH, "tool", "galaxy.xsd")


def lint_tool_xsd(root, lint_ctx):
def lint_tool_xsd(tool_xml, lint_ctx):
"""Write a temp file out and lint it."""
with tempfile.NamedTemporaryFile() as tf:
_clean_root(root).write(tf.name)
_clean_root(tool_xml).write(tf.name)
planemo.lint.lint_xsd(lint_ctx, TOOL_XSD, tf.name)


def _clean_root(root):
def _clean_root(tool_xml):
"""XSD assumes macros have been expanded, so remove them."""
clean_root = copy.deepcopy(root)
clean_tool_xml = copy.deepcopy(tool_xml)
to_remove = []
for macros_el in clean_root.findall("macros"):
for macros_el in clean_tool_xml.getroot().findall("macros"):
to_remove.append(macros_el)
for macros_el in to_remove:
clean_root.getroot().remove(macros_el)
return clean_root
clean_tool_xml.getroot().remove(macros_el)
return clean_tool_xml
1 change: 0 additions & 1 deletion planemo/xml/xsd/tool
Submodule tool deleted from 2b4658
Loading