14
14
from . import treebuilders
15
15
from .treebuilders .base import Marker
16
16
17
- from . import utils
17
+ from . import _utils
18
18
from .constants import (
19
19
spaceCharacters , asciiUpper2Lower ,
20
20
specialElements , headingElements , cdataElements , rcdataElements ,
@@ -344,7 +344,7 @@ def parseRCDataRawtext(self, token, contentType):
344
344
self .phase = self .phases ["text" ]
345
345
346
346
347
- @utils .memoize
347
+ @_utils .memoize
348
348
def getPhases (debug ):
349
349
def log (function ):
350
350
"""Logger that records which phase processes each token"""
@@ -586,13 +586,13 @@ class BeforeHeadPhase(Phase):
586
586
def __init__ (self , parser , tree ):
587
587
Phase .__init__ (self , parser , tree )
588
588
589
- self .startTagHandler = utils .MethodDispatcher ([
589
+ self .startTagHandler = _utils .MethodDispatcher ([
590
590
("html" , self .startTagHtml ),
591
591
("head" , self .startTagHead )
592
592
])
593
593
self .startTagHandler .default = self .startTagOther
594
594
595
- self .endTagHandler = utils .MethodDispatcher ([
595
+ self .endTagHandler = _utils .MethodDispatcher ([
596
596
(("head" , "body" , "html" , "br" ), self .endTagImplyHead )
597
597
])
598
598
self .endTagHandler .default = self .endTagOther
@@ -632,7 +632,7 @@ class InHeadPhase(Phase):
632
632
def __init__ (self , parser , tree ):
633
633
Phase .__init__ (self , parser , tree )
634
634
635
- self .startTagHandler = utils .MethodDispatcher ([
635
+ self .startTagHandler = _utils .MethodDispatcher ([
636
636
("html" , self .startTagHtml ),
637
637
("title" , self .startTagTitle ),
638
638
(("noframes" , "style" ), self .startTagNoFramesStyle ),
@@ -645,7 +645,7 @@ def __init__(self, parser, tree):
645
645
])
646
646
self .startTagHandler .default = self .startTagOther
647
647
648
- self .endTagHandler = utils .MethodDispatcher ([
648
+ self .endTagHandler = _utils .MethodDispatcher ([
649
649
("head" , self .endTagHead ),
650
650
(("br" , "html" , "body" ), self .endTagHtmlBodyBr )
651
651
])
@@ -735,14 +735,14 @@ class InHeadNoscriptPhase(Phase):
735
735
def __init__ (self , parser , tree ):
736
736
Phase .__init__ (self , parser , tree )
737
737
738
- self .startTagHandler = utils .MethodDispatcher ([
738
+ self .startTagHandler = _utils .MethodDispatcher ([
739
739
("html" , self .startTagHtml ),
740
740
(("basefont" , "bgsound" , "link" , "meta" , "noframes" , "style" ), self .startTagBaseLinkCommand ),
741
741
(("head" , "noscript" ), self .startTagHeadNoscript ),
742
742
])
743
743
self .startTagHandler .default = self .startTagOther
744
744
745
- self .endTagHandler = utils .MethodDispatcher ([
745
+ self .endTagHandler = _utils .MethodDispatcher ([
746
746
("noscript" , self .endTagNoscript ),
747
747
("br" , self .endTagBr ),
748
748
])
@@ -799,7 +799,7 @@ class AfterHeadPhase(Phase):
799
799
def __init__ (self , parser , tree ):
800
800
Phase .__init__ (self , parser , tree )
801
801
802
- self .startTagHandler = utils .MethodDispatcher ([
802
+ self .startTagHandler = _utils .MethodDispatcher ([
803
803
("html" , self .startTagHtml ),
804
804
("body" , self .startTagBody ),
805
805
("frameset" , self .startTagFrameset ),
@@ -809,8 +809,8 @@ def __init__(self, parser, tree):
809
809
("head" , self .startTagHead )
810
810
])
811
811
self .startTagHandler .default = self .startTagOther
812
- self .endTagHandler = utils .MethodDispatcher ([(("body" , "html" , "br" ),
813
- self .endTagHtmlBodyBr )])
812
+ self .endTagHandler = _utils .MethodDispatcher ([(("body" , "html" , "br" ),
813
+ self .endTagHtmlBodyBr )])
814
814
self .endTagHandler .default = self .endTagOther
815
815
816
816
def processEOF (self ):
@@ -871,7 +871,7 @@ def __init__(self, parser, tree):
871
871
# Set this to the default handler
872
872
self .processSpaceCharacters = self .processSpaceCharactersNonPre
873
873
874
- self .startTagHandler = utils .MethodDispatcher ([
874
+ self .startTagHandler = _utils .MethodDispatcher ([
875
875
("html" , self .startTagHtml ),
876
876
(("base" , "basefont" , "bgsound" , "command" , "link" , "meta" ,
877
877
"script" , "style" , "title" ),
@@ -918,7 +918,7 @@ def __init__(self, parser, tree):
918
918
])
919
919
self .startTagHandler .default = self .startTagOther
920
920
921
- self .endTagHandler = utils .MethodDispatcher ([
921
+ self .endTagHandler = _utils .MethodDispatcher ([
922
922
("body" , self .endTagBody ),
923
923
("html" , self .endTagHtml ),
924
924
(("address" , "article" , "aside" , "blockquote" , "button" , "center" ,
@@ -1588,9 +1588,9 @@ def endTagOther(self, token):
1588
1588
class TextPhase (Phase ):
1589
1589
def __init__ (self , parser , tree ):
1590
1590
Phase .__init__ (self , parser , tree )
1591
- self .startTagHandler = utils .MethodDispatcher ([])
1591
+ self .startTagHandler = _utils .MethodDispatcher ([])
1592
1592
self .startTagHandler .default = self .startTagOther
1593
- self .endTagHandler = utils .MethodDispatcher ([
1593
+ self .endTagHandler = _utils .MethodDispatcher ([
1594
1594
("script" , self .endTagScript )])
1595
1595
self .endTagHandler .default = self .endTagOther
1596
1596
@@ -1622,7 +1622,7 @@ class InTablePhase(Phase):
1622
1622
# http://www.whatwg.org/specs/web-apps/current-work/#in-table
1623
1623
def __init__ (self , parser , tree ):
1624
1624
Phase .__init__ (self , parser , tree )
1625
- self .startTagHandler = utils .MethodDispatcher ([
1625
+ self .startTagHandler = _utils .MethodDispatcher ([
1626
1626
("html" , self .startTagHtml ),
1627
1627
("caption" , self .startTagCaption ),
1628
1628
("colgroup" , self .startTagColgroup ),
@@ -1636,7 +1636,7 @@ def __init__(self, parser, tree):
1636
1636
])
1637
1637
self .startTagHandler .default = self .startTagOther
1638
1638
1639
- self .endTagHandler = utils .MethodDispatcher ([
1639
+ self .endTagHandler = _utils .MethodDispatcher ([
1640
1640
("table" , self .endTagTable ),
1641
1641
(("body" , "caption" , "col" , "colgroup" , "html" , "tbody" , "td" ,
1642
1642
"tfoot" , "th" , "thead" , "tr" ), self .endTagIgnore )
@@ -1813,14 +1813,14 @@ class InCaptionPhase(Phase):
1813
1813
def __init__ (self , parser , tree ):
1814
1814
Phase .__init__ (self , parser , tree )
1815
1815
1816
- self .startTagHandler = utils .MethodDispatcher ([
1816
+ self .startTagHandler = _utils .MethodDispatcher ([
1817
1817
("html" , self .startTagHtml ),
1818
1818
(("caption" , "col" , "colgroup" , "tbody" , "td" , "tfoot" , "th" ,
1819
1819
"thead" , "tr" ), self .startTagTableElement )
1820
1820
])
1821
1821
self .startTagHandler .default = self .startTagOther
1822
1822
1823
- self .endTagHandler = utils .MethodDispatcher ([
1823
+ self .endTagHandler = _utils .MethodDispatcher ([
1824
1824
("caption" , self .endTagCaption ),
1825
1825
("table" , self .endTagTable ),
1826
1826
(("body" , "col" , "colgroup" , "html" , "tbody" , "td" , "tfoot" , "th" ,
@@ -1885,13 +1885,13 @@ class InColumnGroupPhase(Phase):
1885
1885
def __init__ (self , parser , tree ):
1886
1886
Phase .__init__ (self , parser , tree )
1887
1887
1888
- self .startTagHandler = utils .MethodDispatcher ([
1888
+ self .startTagHandler = _utils .MethodDispatcher ([
1889
1889
("html" , self .startTagHtml ),
1890
1890
("col" , self .startTagCol )
1891
1891
])
1892
1892
self .startTagHandler .default = self .startTagOther
1893
1893
1894
- self .endTagHandler = utils .MethodDispatcher ([
1894
+ self .endTagHandler = _utils .MethodDispatcher ([
1895
1895
("colgroup" , self .endTagColgroup ),
1896
1896
("col" , self .endTagCol )
1897
1897
])
@@ -1949,7 +1949,7 @@ class InTableBodyPhase(Phase):
1949
1949
# http://www.whatwg.org/specs/web-apps/current-work/#in-table0
1950
1950
def __init__ (self , parser , tree ):
1951
1951
Phase .__init__ (self , parser , tree )
1952
- self .startTagHandler = utils .MethodDispatcher ([
1952
+ self .startTagHandler = _utils .MethodDispatcher ([
1953
1953
("html" , self .startTagHtml ),
1954
1954
("tr" , self .startTagTr ),
1955
1955
(("td" , "th" ), self .startTagTableCell ),
@@ -1958,7 +1958,7 @@ def __init__(self, parser, tree):
1958
1958
])
1959
1959
self .startTagHandler .default = self .startTagOther
1960
1960
1961
- self .endTagHandler = utils .MethodDispatcher ([
1961
+ self .endTagHandler = _utils .MethodDispatcher ([
1962
1962
(("tbody" , "tfoot" , "thead" ), self .endTagTableRowGroup ),
1963
1963
("table" , self .endTagTable ),
1964
1964
(("body" , "caption" , "col" , "colgroup" , "html" , "td" , "th" ,
@@ -2047,15 +2047,15 @@ class InRowPhase(Phase):
2047
2047
# http://www.whatwg.org/specs/web-apps/current-work/#in-row
2048
2048
def __init__ (self , parser , tree ):
2049
2049
Phase .__init__ (self , parser , tree )
2050
- self .startTagHandler = utils .MethodDispatcher ([
2050
+ self .startTagHandler = _utils .MethodDispatcher ([
2051
2051
("html" , self .startTagHtml ),
2052
2052
(("td" , "th" ), self .startTagTableCell ),
2053
2053
(("caption" , "col" , "colgroup" , "tbody" , "tfoot" , "thead" ,
2054
2054
"tr" ), self .startTagTableOther )
2055
2055
])
2056
2056
self .startTagHandler .default = self .startTagOther
2057
2057
2058
- self .endTagHandler = utils .MethodDispatcher ([
2058
+ self .endTagHandler = _utils .MethodDispatcher ([
2059
2059
("tr" , self .endTagTr ),
2060
2060
("table" , self .endTagTable ),
2061
2061
(("tbody" , "tfoot" , "thead" ), self .endTagTableRowGroup ),
@@ -2136,14 +2136,14 @@ class InCellPhase(Phase):
2136
2136
# http://www.whatwg.org/specs/web-apps/current-work/#in-cell
2137
2137
def __init__ (self , parser , tree ):
2138
2138
Phase .__init__ (self , parser , tree )
2139
- self .startTagHandler = utils .MethodDispatcher ([
2139
+ self .startTagHandler = _utils .MethodDispatcher ([
2140
2140
("html" , self .startTagHtml ),
2141
2141
(("caption" , "col" , "colgroup" , "tbody" , "td" , "tfoot" , "th" ,
2142
2142
"thead" , "tr" ), self .startTagTableOther )
2143
2143
])
2144
2144
self .startTagHandler .default = self .startTagOther
2145
2145
2146
- self .endTagHandler = utils .MethodDispatcher ([
2146
+ self .endTagHandler = _utils .MethodDispatcher ([
2147
2147
(("td" , "th" ), self .endTagTableCell ),
2148
2148
(("body" , "caption" , "col" , "colgroup" , "html" ), self .endTagIgnore ),
2149
2149
(("table" , "tbody" , "tfoot" , "thead" , "tr" ), self .endTagImply )
@@ -2212,7 +2212,7 @@ class InSelectPhase(Phase):
2212
2212
def __init__ (self , parser , tree ):
2213
2213
Phase .__init__ (self , parser , tree )
2214
2214
2215
- self .startTagHandler = utils .MethodDispatcher ([
2215
+ self .startTagHandler = _utils .MethodDispatcher ([
2216
2216
("html" , self .startTagHtml ),
2217
2217
("option" , self .startTagOption ),
2218
2218
("optgroup" , self .startTagOptgroup ),
@@ -2222,7 +2222,7 @@ def __init__(self, parser, tree):
2222
2222
])
2223
2223
self .startTagHandler .default = self .startTagOther
2224
2224
2225
- self .endTagHandler = utils .MethodDispatcher ([
2225
+ self .endTagHandler = _utils .MethodDispatcher ([
2226
2226
("option" , self .endTagOption ),
2227
2227
("optgroup" , self .endTagOptgroup ),
2228
2228
("select" , self .endTagSelect )
@@ -2312,13 +2312,13 @@ class InSelectInTablePhase(Phase):
2312
2312
def __init__ (self , parser , tree ):
2313
2313
Phase .__init__ (self , parser , tree )
2314
2314
2315
- self .startTagHandler = utils .MethodDispatcher ([
2315
+ self .startTagHandler = _utils .MethodDispatcher ([
2316
2316
(("caption" , "table" , "tbody" , "tfoot" , "thead" , "tr" , "td" , "th" ),
2317
2317
self .startTagTable )
2318
2318
])
2319
2319
self .startTagHandler .default = self .startTagOther
2320
2320
2321
- self .endTagHandler = utils .MethodDispatcher ([
2321
+ self .endTagHandler = _utils .MethodDispatcher ([
2322
2322
(("caption" , "table" , "tbody" , "tfoot" , "thead" , "tr" , "td" , "th" ),
2323
2323
self .endTagTable )
2324
2324
])
@@ -2466,12 +2466,12 @@ class AfterBodyPhase(Phase):
2466
2466
def __init__ (self , parser , tree ):
2467
2467
Phase .__init__ (self , parser , tree )
2468
2468
2469
- self .startTagHandler = utils .MethodDispatcher ([
2469
+ self .startTagHandler = _utils .MethodDispatcher ([
2470
2470
("html" , self .startTagHtml )
2471
2471
])
2472
2472
self .startTagHandler .default = self .startTagOther
2473
2473
2474
- self .endTagHandler = utils .MethodDispatcher ([("html" , self .endTagHtml )])
2474
+ self .endTagHandler = _utils .MethodDispatcher ([("html" , self .endTagHtml )])
2475
2475
self .endTagHandler .default = self .endTagOther
2476
2476
2477
2477
def processEOF (self ):
@@ -2514,15 +2514,15 @@ class InFramesetPhase(Phase):
2514
2514
def __init__ (self , parser , tree ):
2515
2515
Phase .__init__ (self , parser , tree )
2516
2516
2517
- self .startTagHandler = utils .MethodDispatcher ([
2517
+ self .startTagHandler = _utils .MethodDispatcher ([
2518
2518
("html" , self .startTagHtml ),
2519
2519
("frameset" , self .startTagFrameset ),
2520
2520
("frame" , self .startTagFrame ),
2521
2521
("noframes" , self .startTagNoframes )
2522
2522
])
2523
2523
self .startTagHandler .default = self .startTagOther
2524
2524
2525
- self .endTagHandler = utils .MethodDispatcher ([
2525
+ self .endTagHandler = _utils .MethodDispatcher ([
2526
2526
("frameset" , self .endTagFrameset )
2527
2527
])
2528
2528
self .endTagHandler .default = self .endTagOther
@@ -2571,13 +2571,13 @@ class AfterFramesetPhase(Phase):
2571
2571
def __init__ (self , parser , tree ):
2572
2572
Phase .__init__ (self , parser , tree )
2573
2573
2574
- self .startTagHandler = utils .MethodDispatcher ([
2574
+ self .startTagHandler = _utils .MethodDispatcher ([
2575
2575
("html" , self .startTagHtml ),
2576
2576
("noframes" , self .startTagNoframes )
2577
2577
])
2578
2578
self .startTagHandler .default = self .startTagOther
2579
2579
2580
- self .endTagHandler = utils .MethodDispatcher ([
2580
+ self .endTagHandler = _utils .MethodDispatcher ([
2581
2581
("html" , self .endTagHtml )
2582
2582
])
2583
2583
self .endTagHandler .default = self .endTagOther
@@ -2607,7 +2607,7 @@ class AfterAfterBodyPhase(Phase):
2607
2607
def __init__ (self , parser , tree ):
2608
2608
Phase .__init__ (self , parser , tree )
2609
2609
2610
- self .startTagHandler = utils .MethodDispatcher ([
2610
+ self .startTagHandler = _utils .MethodDispatcher ([
2611
2611
("html" , self .startTagHtml )
2612
2612
])
2613
2613
self .startTagHandler .default = self .startTagOther
@@ -2645,7 +2645,7 @@ class AfterAfterFramesetPhase(Phase):
2645
2645
def __init__ (self , parser , tree ):
2646
2646
Phase .__init__ (self , parser , tree )
2647
2647
2648
- self .startTagHandler = utils .MethodDispatcher ([
2648
+ self .startTagHandler = _utils .MethodDispatcher ([
2649
2649
("html" , self .startTagHtml ),
2650
2650
("noframes" , self .startTagNoFrames )
2651
2651
])
@@ -2707,7 +2707,7 @@ def processEndTag(self, token):
2707
2707
2708
2708
2709
2709
def adjust_attributes (token , replacements ):
2710
- if PY3 or utils .PY27 :
2710
+ if PY3 or _utils .PY27 :
2711
2711
needs_adjustment = viewkeys (token ['data' ]) & viewkeys (replacements )
2712
2712
else :
2713
2713
needs_adjustment = frozenset (token ['data' ]) & frozenset (replacements )
0 commit comments