summaryrefslogtreecommitdiff
path: root/beautifulsoup/builder/_lxml.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonard.richardson@canonical.com>2011-02-20 19:50:45 -0500
committerLeonard Richardson <leonard.richardson@canonical.com>2011-02-20 19:50:45 -0500
commit2fa73e2cb99b0816148ade6150f378993907534e (patch)
treecf7e2371881c680990157cae621f6045f5941f56 /beautifulsoup/builder/_lxml.py
parente6320fad4cd162ab6c7dfe02be5206f5c3f8c25b (diff)
parentce3742abd4c7fe39247569e82e2b3acdd6052bb1 (diff)
Added a registry for tree builders and made it possible to find a tree builder that has the features you want from the BeautifulSoup constructor.
Diffstat (limited to 'beautifulsoup/builder/_lxml.py')
-rw-r--r--beautifulsoup/builder/_lxml.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/beautifulsoup/builder/_lxml.py b/beautifulsoup/builder/_lxml.py
index c2f368c..4c7a826 100644
--- a/beautifulsoup/builder/_lxml.py
+++ b/beautifulsoup/builder/_lxml.py
@@ -5,13 +5,24 @@ __all__ = [
from lxml import etree
from beautifulsoup.element import Comment, Doctype
-from beautifulsoup.builder import TreeBuilder, HTMLTreeBuilder
+from beautifulsoup.builder import (
+ FAST,
+ HTML,
+ HTMLTreeBuilder,
+ PERMISSIVE,
+ TreeBuilder,
+ XML)
from beautifulsoup.dammit import UnicodeDammit
import types
+LXML = 'lxml'
+
class LXMLTreeBuilderForXML(TreeBuilder):
DEFAULT_PARSER_CLASS = etree.XMLParser
+ # Well, it's permissive by XML parser standards.
+ features = [LXML, XML, FAST, PERMISSIVE]
+
@property
def default_parser(self):
# This can either return a parser object or a class, which
@@ -79,6 +90,8 @@ class LXMLTreeBuilderForXML(TreeBuilder):
class LXMLTreeBuilder(HTMLTreeBuilder, LXMLTreeBuilderForXML):
+ features = [LXML, HTML, FAST]
+
@property
def default_parser(self):
return etree.HTMLParser