[Lxml-checkins] r43899 - lxml/branch/html/src/lxml/html
ianb at codespeak.net
ianb at codespeak.net
Wed May 30 17:49:36 CEST 2007
Author: ianb
Date: Wed May 30 17:49:36 2007
New Revision: 43899
Modified:
lxml/branch/html/src/lxml/html/__init__.py
Log:
use CommentBase instead of _Comment as a superclass; switch to ElementDefaultClassLookup
Modified: lxml/branch/html/src/lxml/html/__init__.py
==============================================================================
--- lxml/branch/html/src/lxml/html/__init__.py (original)
+++ lxml/branch/html/src/lxml/html/__init__.py Wed May 30 17:49:36 2007
@@ -80,25 +80,15 @@
parts.append(self.tail or '')
return ''.join(parts)
-class HtmlComment(etree._Comment, HtmlMixin):
+class HtmlComment(etree.CommentBase, HtmlMixin):
pass
class HtmlElement(etree.ElementBase, HtmlMixin):
pass
-class HtmlLookup(etree.CustomElementClassLookup):
-
- def lookup(self, node_type, document, namespace, name):
- if node_type == 'element':
- return HtmlElement
- elif node_type == 'comment':
- return HtmlComment
- else:
- # Delegate
- return None
-
html_parser = etree.HTMLParser()
-html_parser.setElementClassLookup(HtmlLookup())
+html_parser.setElementClassLookup(etree.ElementDefaultClassLookup(
+ element=HtmlElement, comment=HtmlComment))
def HTML(html):
# FIXME: should this notice a fragment and parse accordingly?
More information about the lxml-checkins
mailing list