diff options
author | Shubham Saini <shubham6405@gmail.com> | 2019-08-05 08:32:33 +0000 |
---|---|---|
committer | Shubham Saini <shubham6405@gmail.com> | 2019-08-05 08:32:33 +0000 |
commit | 227b2d30a8675b44918f9d9ca89b24144a938215 (patch) | |
tree | 9f8e6a28724514b6fdf463a9ab2067a7ef309b72 /venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/html5lib/treebuilders/__init__.py | |
parent | 842a8cfbbbdb1f92889d892e4859dbd5d40c5be8 (diff) |
removing venv files
Diffstat (limited to 'venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/html5lib/treebuilders/__init__.py')
-rw-r--r-- | venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/html5lib/treebuilders/__init__.py | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/html5lib/treebuilders/__init__.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/html5lib/treebuilders/__init__.py deleted file mode 100644 index 2ce5c87..0000000 --- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/html5lib/treebuilders/__init__.py +++ /dev/null | |||
@@ -1,88 +0,0 @@ | |||
1 | """A collection of modules for building different kinds of trees from HTML | ||
2 | documents. | ||
3 | |||
4 | To create a treebuilder for a new type of tree, you need to do | ||
5 | implement several things: | ||
6 | |||
7 | 1. A set of classes for various types of elements: Document, Doctype, Comment, | ||
8 | Element. These must implement the interface of ``base.treebuilders.Node`` | ||
9 | (although comment nodes have a different signature for their constructor, | ||
10 | see ``treebuilders.etree.Comment``) Textual content may also be implemented | ||
11 | as another node type, or not, as your tree implementation requires. | ||
12 | |||
13 | 2. A treebuilder object (called ``TreeBuilder`` by convention) that inherits | ||
14 | from ``treebuilders.base.TreeBuilder``. This has 4 required attributes: | ||
15 | |||
16 | * ``documentClass`` - the class to use for the bottommost node of a document | ||
17 | * ``elementClass`` - the class to use for HTML Elements | ||
18 | * ``commentClass`` - the class to use for comments | ||
19 | * ``doctypeClass`` - the class to use for doctypes | ||
20 | |||
21 | It also has one required method: | ||
22 | |||
23 | * ``getDocument`` - Returns the root node of the complete document tree | ||
24 | |||
25 | 3. If you wish to run the unit tests, you must also create a ``testSerializer`` | ||
26 | method on your treebuilder which accepts a node and returns a string | ||
27 | containing Node and its children serialized according to the format used in | ||
28 | the unittests | ||
29 | |||
30 | """ | ||
31 | |||
32 | from __future__ import absolute_import, division, unicode_literals | ||
33 | |||
34 | from .._utils import default_etree | ||
35 | |||
36 | treeBuilderCache = {} | ||
37 | |||
38 | |||
39 | def getTreeBuilder(treeType, implementation=None, **kwargs): | ||
40 | """Get a TreeBuilder class for various types of trees with built-in support | ||
41 | |||
42 | :arg treeType: the name of the tree type required (case-insensitive). Supported | ||
43 | values are: | ||
44 | |||
45 | * "dom" - A generic builder for DOM implementations, defaulting to a | ||
46 | xml.dom.minidom based implementation. | ||
47 | * "etree" - A generic builder for tree implementations exposing an | ||
48 | ElementTree-like interface, defaulting to xml.etree.cElementTree if | ||
49 | available and xml.etree.ElementTree if not. | ||
50 | * "lxml" - A etree-based builder for lxml.etree, handling limitations | ||
51 | of lxml's implementation. | ||
52 | |||
53 | :arg implementation: (Currently applies to the "etree" and "dom" tree | ||
54 | types). A module implementing the tree type e.g. xml.etree.ElementTree | ||
55 | or xml.etree.cElementTree. | ||
56 | |||
57 | :arg kwargs: Any additional options to pass to the TreeBuilder when | ||
58 | creating it. | ||
59 | |||
60 | Example: | ||
61 | |||
62 | >>> from html5lib.treebuilders import getTreeBuilder | ||
63 | >>> builder = getTreeBuilder('etree') | ||
64 | |||
65 | """ | ||
66 | |||
67 | treeType = treeType.lower() | ||
68 | if treeType not in treeBuilderCache: | ||
69 | if treeType == "dom": | ||
70 | from . import dom | ||
71 | # Come up with a sane default (pref. from the stdlib) | ||
72 | if implementation is None: | ||
73 | from xml.dom import minidom | ||
74 | implementation = minidom | ||
75 | # NEVER cache here, caching is done in the dom submodule | ||
76 | return dom.getDomModule(implementation, **kwargs).TreeBuilder | ||
77 | elif treeType == "lxml": | ||
78 | from . import etree_lxml | ||
79 | treeBuilderCache[treeType] = etree_lxml.TreeBuilder | ||
80 | elif treeType == "etree": | ||
81 | from . import etree | ||
82 | if implementation is None: | ||
83 | implementation = default_etree | ||
84 | # NEVER cache here, caching is done in the etree submodule | ||
85 | return etree.getETreeModule(implementation, **kwargs).TreeBuilder | ||
86 | else: | ||
87 | raise ValueError("""Unrecognised treebuilder "%s" """ % treeType) | ||
88 | return treeBuilderCache.get(treeType) | ||