Skip to content

Commit

Permalink
Fixup docs in planemo.xml.validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Sep 22, 2016
1 parent 1ac6094 commit d6da3a8
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions planemo/xml/validation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Module describing abstractions for validating XML content."""
import abc
import subprocess

Expand All @@ -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
"""
Expand All @@ -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:
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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.