Skip to content

Commit

Permalink
remove lxml based schema linter
Browse files Browse the repository at this point in the history
now in galaxy core galaxyproject/galaxy#17081
  • Loading branch information
bernt-matthias committed Jan 16, 2024
1 parent 0b5df63 commit 1fbbc0e
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions planemo/xml/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import subprocess
from collections import namedtuple

from galaxy.util import unicodify
from galaxy.util.commands import which

try:
Expand All @@ -14,7 +13,7 @@
XMLLINT_COMMAND = "xmllint --noout --schema {0} {1} 2>&1"
INSTALL_VALIDATOR_MESSAGE = (
"This feature requires an external dependency "
"to function, pleaes install xmllint (e.g 'brew "
"to function, please install xmllint (e.g 'brew "
"install libxml2' or 'apt-get install "
"libxml2-utils'."
)
Expand All @@ -41,27 +40,11 @@ def enabled(self):
ValidationResult = namedtuple("ValidationResult", ["passed", "output"])


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

def validate(self, schema_path, target_path):
try:
xsd_doc = etree.parse(schema_path)
xsd = etree.XMLSchema(xsd_doc)
xml = etree.parse(target_path)
passed = xsd.validate(xml)
return ValidationResult(passed, xsd.error_log)
except etree.XMLSyntaxError as e:
return ValidationResult(False, unicodify(e))

def enabled(self):
return etree is not None


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

def validate(self, schema_path, target_path):
print("XmllintValidator")
command = XMLLINT_COMMAND.format(schema_path, target_path)
p = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
stdout, _ = p.communicate()
Expand All @@ -72,7 +55,7 @@ def enabled(self):
return bool(which("xmllint"))


VALIDATORS = [LxmlValidator(), XmllintValidator()]
VALIDATORS = [XmllintValidator()]


def get_validator(require=True):
Expand Down

0 comments on commit 1fbbc0e

Please sign in to comment.