commit/galaxy-central: dannon: 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.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/fd753316154e/ Changeset: fd753316154e User: dannon Date: 2015-02-12 19:56:33+00:00 Summary: 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. Affected #: 2 files diff -r 2e13b048a9b707224b1f499dbdaf12a45ffd413c -r fd753316154e8ad2a92bebffda9441c8614a06f5 lib/galaxy/util/__init__.py --- a/lib/galaxy/util/__init__.py +++ b/lib/galaxy/util/__init__.py @@ -169,11 +169,15 @@ 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 diff -r 2e13b048a9b707224b1f499dbdaf12a45ffd413c -r fd753316154e8ad2a92bebffda9441c8614a06f5 lib/galaxy/visualization/registry.py --- a/lib/galaxy/visualization/registry.py +++ b/lib/galaxy/visualization/registry.py @@ -7,8 +7,6 @@ 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 @@ 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 @@ 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 Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org