From d35d9b2b5a9ab6e1861abc30768a2d8eaea7b310 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Fri, 21 Sep 2007 15:22:47 +0000 Subject: Simplify SAX calling sequence. svn path=/scripts/rpki/sax_utils.py; revision=1004 --- scripts/rpki/sax_utils.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'scripts/rpki/sax_utils.py') diff --git a/scripts/rpki/sax_utils.py b/scripts/rpki/sax_utils.py index 06862524..058deeb2 100644 --- a/scripts/rpki/sax_utils.py +++ b/scripts/rpki/sax_utils.py @@ -2,7 +2,7 @@ """SAX utilities.""" -import xml.sax +import xml.sax, lxml.sax class handler(xml.sax.handler.ContentHandler): """SAX handler for RPKI protocols. @@ -68,3 +68,11 @@ class handler(xml.sax.handler.ContentHandler): text = self.text.encode("ascii").strip() self.text = "" self.stack[-1].endElement(self.stack, name, text) + + @classmethod + def saxify(cls, elt): + """Create a one-off SAX parser, parse an ETree, return the result. + """ + self = cls() + lxml.sax.saxify(elt, self) + return self.result -- cgit v1.2.3