Update original parse_xml function with Carl's fix. It's safe, and I know I saw that same doctype deprecation somewhere else, might as well share it.

This commit is contained in:
Dannon Baker
2015-02-12 14:56:33 -05:00
parent 5029a819d5
commit c45710da57
2 changed files with 9 additions and 17 deletions
+8 -4
View File
@@ -169,11 +169,15 @@ def unique_id(KEY_SIZE=128):
return md5(str( random.getrandbits( KEY_SIZE ) )).hexdigest()
def parse_xml(fname):
def parse_xml( fname ):
"""Returns a parsed xml tree"""
tree = ElementTree.parse(fname)
root = tree.getroot()
ElementInclude.include(root)
# handle deprecation warning for XMLParsing a file with DOCTYPE
class DoctypeSafeCallbackTarget( ElementTree.TreeBuilder ):
def doctype( *args ):
pass
tree = ElementTree.ElementTree()
root = tree.parse( fname, parser=ElementTree.XMLParser( target=DoctypeSafeCallbackTarget() ) )
ElementInclude.include( root )
return tree
+1 -13
View File
@@ -7,8 +7,6 @@ Lower level of visualization framework which does three main things:
import os
import shutil
import glob
from xml.etree import ElementTree
from xml.etree import ElementInclude
from galaxy import util
import galaxy.model
@@ -85,16 +83,6 @@ def hasattr_recursive( item, attr_key ):
return True
def parse_xml( fname ):
# handle deprecation warning for XMLParsing a file with DOCTYPE
class DoctypeSafeCallbackTarget( ElementTree.TreeBuilder ):
def doctype( *args ):
pass
tree = ElementTree.ElementTree()
root = tree.parse( fname, parser=ElementTree.XMLParser( target=DoctypeSafeCallbackTarget() ) )
ElementInclude.include( root )
return tree
# ------------------------------------------------------------------- the registry
class VisualizationsRegistry( pluginframework.PageServingPluginManager ):
@@ -406,7 +394,7 @@ class VisualizationsConfigParser( object ):
Parse the given XML file for visualizations data.
:returns: visualization config dictionary
"""
xml_tree = parse_xml( xml_filepath )
xml_tree = util.parse_xml( xml_filepath )
visualization = self.parse_visualization( xml_tree.getroot() )
return visualization