Permalink
Browse files

Fixup docs in planemo.xml.validation.

  • Loading branch information...
jmchilton committed Sep 22, 2016
1 parent 1ac6094 commit d6da3a800a7e68036baa4378dee5e0861ad37658
Showing with 14 additions and 4 deletions.
  1. +14 −4 planemo/xml/validation.py
@@ -1,3 +1,4 @@
"""Module describing abstractions for validating XML content."""
import abc
import subprocess

@@ -17,18 +18,20 @@


class XsdValidator(object):
"""Class allowing validation of XML files against XSD schema."""

__metaclass__ = abc.ABCMeta

@abc.abstractmethod
def validate(self, schema_path, target_path):
""" Validate ``target_path`` against ``schema_path``.
"""Validate ``target_path`` against ``schema_path``.
:return type: ValidationResult
"""

@abc.abstractmethod
def enabled(self):
""" Return True iff system has dependencies for this validator.
"""Return True iff system has dependencies for this validator.
:return type: bool
"""
@@ -37,7 +40,7 @@ def enabled(self):


class LxmlValidator(XsdValidator):
""" Validate XSD files using lxml library. """
"""Validate XSD files using lxml library."""

def validate(self, schema_path, target_path):
try:
@@ -54,7 +57,7 @@ def enabled(self):


class XmllintValidator(XsdValidator):
""" Validate XSD files with the external tool xmllint. """
"""Validate XSD files with the external tool xmllint."""

def validate(self, schema_path, target_path):
command = XMLLINT_COMMAND.format(schema_path, target_path)
@@ -71,6 +74,7 @@ def enabled(self):


def get_validator(require=True):
"""Return a :class:`XsdValidator` object based on available dependencies."""
for validator in VALIDATORS:
if validator.enabled():
return validator
@@ -79,3 +83,9 @@ def get_validator(require=True):
raise Exception(INSTALL_VALIDATOR_MESSAGE)

return None


__all__ = [
"get_validator",
"XsdValidator",
]

0 comments on commit d6da3a8

Please sign in to comment.