mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
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:
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user