From a2494bb119fc60e1b024b439249cb00280457d04 Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Tue, 17 Dec 2013 11:11:04 -0800 Subject: [PATCH] Move loading DTD into a function as the call caused a hang when loaded into wsgi --- htsworkflow/util/ethelp.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/htsworkflow/util/ethelp.py b/htsworkflow/util/ethelp.py index 7398963..f2f3e01 100644 --- a/htsworkflow/util/ethelp.py +++ b/htsworkflow/util/ethelp.py @@ -5,11 +5,6 @@ import os LOGGER = logging.getLogger(__name__) import lxml.etree -try: - XHTML_RDF_DTD = lxml.etree.DTD(external_id='-//W3C//DTD XHTML+RDFa 1.0//EN') -except lxml.etree.DTDParseError as e: - XHTML_RDF_DTD = None - LOGGER.warn("Unable to load XHTML DTD %s" % (str(e),)) def indent(elem, level=0): """ @@ -49,8 +44,11 @@ def validate_xhtml(html, base_url='http://localhost'): Returns True if it passed validation and False if it fails. """ - if XHTML_RDF_DTD is None: - return None + try: + XHTML_RDF_DTD = lxml.etree.DTD(external_id='-//W3C//DTD XHTML+RDFa 1.0//EN') + except lxml.etree.DTDParseError as e: + LOGGER.warn("Unable to load XHTML DTD %s" % (str(e),)) + return try: root = lxml.etree.fromstring(html, base_url=base_url) -- 2.30.2