From: Zac Medico Date: Mon, 12 Apr 2010 00:17:31 +0000 (-0700) Subject: Avoid XMLParser.doctype deprecation warnings with >=python-2.7. X-Git-Tag: v2.2_rc68~654 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ab02fdd64eb215464325dfade55aad115d687a7f;p=portage.git Avoid XMLParser.doctype deprecation warnings with >=python-2.7. --- diff --git a/pym/repoman/herdbase.py b/pym/repoman/herdbase.py index 6f92abfb8..9e20aa173 100644 --- a/pym/repoman/herdbase.py +++ b/pym/repoman/herdbase.py @@ -4,7 +4,7 @@ # Distributed under the terms of the GNU General Public License v2 import errno -import xml.etree.ElementTree as ET +import xml.etree.ElementTree from xml.parsers.expat import ExpatError from portage.exception import FileNotFound, ParseError, PermissionDenied @@ -36,13 +36,22 @@ class HerdBase(object): def maintainer_in_herd(self, nick_name, herd_name): return _make_email(nick_name) in self.herd_to_emails[herd_name] +class _HerdsTreeBuilder(xml.etree.ElementTree.TreeBuilder): + """ + Implements doctype() as required to avoid deprecation warnings with + >=python-2.7. + """ + def doctype(self, name, pubid, system): + pass def make_herd_base(filename): herd_to_emails = dict() all_emails = set() try: - xml_tree = ET.parse(filename) + xml_tree = xml.etree.ElementTree.parse(filename, + parser=xml.etree.ElementTree.XMLParser( + target=_HerdsTreeBuilder())) except ExpatError as e: raise ParseError("metadata.xml: " + str(e)) except EnvironmentError as e: