1414from . import treebuilders
1515from .treebuilders .base import Marker
1616
17- from . import utils
17+ from . import _utils
1818from .constants import (
1919 spaceCharacters , asciiUpper2Lower ,
2020 specialElements , headingElements , cdataElements , rcdataElements ,
@@ -344,7 +344,7 @@ def parseRCDataRawtext(self, token, contentType):
344344 self .phase = self .phases ["text" ]
345345
346346
347- @utils .memoize
347+ @_utils .memoize
348348def getPhases (debug ):
349349 def log (function ):
350350 """Logger that records which phase processes each token"""
@@ -586,13 +586,13 @@ class BeforeHeadPhase(Phase):
586586 def __init__ (self , parser , tree ):
587587 Phase .__init__ (self , parser , tree )
588588
589- self .startTagHandler = utils .MethodDispatcher ([
589+ self .startTagHandler = _utils .MethodDispatcher ([
590590 ("html" , self .startTagHtml ),
591591 ("head" , self .startTagHead )
592592 ])
593593 self .startTagHandler .default = self .startTagOther
594594
595- self .endTagHandler = utils .MethodDispatcher ([
595+ self .endTagHandler = _utils .MethodDispatcher ([
596596 (("head" , "body" , "html" , "br" ), self .endTagImplyHead )
597597 ])
598598 self .endTagHandler .default = self .endTagOther
@@ -632,7 +632,7 @@ class InHeadPhase(Phase):
632632 def __init__ (self , parser , tree ):
633633 Phase .__init__ (self , parser , tree )
634634
635- self .startTagHandler = utils .MethodDispatcher ([
635+ self .startTagHandler = _utils .MethodDispatcher ([
636636 ("html" , self .startTagHtml ),
637637 ("title" , self .startTagTitle ),
638638 (("noframes" , "style" ), self .startTagNoFramesStyle ),
@@ -645,7 +645,7 @@ def __init__(self, parser, tree):
645645 ])
646646 self .startTagHandler .default = self .startTagOther
647647
648- self .endTagHandler = utils .MethodDispatcher ([
648+ self .endTagHandler = _utils .MethodDispatcher ([
649649 ("head" , self .endTagHead ),
650650 (("br" , "html" , "body" ), self .endTagHtmlBodyBr )
651651 ])
@@ -735,14 +735,14 @@ class InHeadNoscriptPhase(Phase):
735735 def __init__ (self , parser , tree ):
736736 Phase .__init__ (self , parser , tree )
737737
738- self .startTagHandler = utils .MethodDispatcher ([
738+ self .startTagHandler = _utils .MethodDispatcher ([
739739 ("html" , self .startTagHtml ),
740740 (("basefont" , "bgsound" , "link" , "meta" , "noframes" , "style" ), self .startTagBaseLinkCommand ),
741741 (("head" , "noscript" ), self .startTagHeadNoscript ),
742742 ])
743743 self .startTagHandler .default = self .startTagOther
744744
745- self .endTagHandler = utils .MethodDispatcher ([
745+ self .endTagHandler = _utils .MethodDispatcher ([
746746 ("noscript" , self .endTagNoscript ),
747747 ("br" , self .endTagBr ),
748748 ])
@@ -799,7 +799,7 @@ class AfterHeadPhase(Phase):
799799 def __init__ (self , parser , tree ):
800800 Phase .__init__ (self , parser , tree )
801801
802- self .startTagHandler = utils .MethodDispatcher ([
802+ self .startTagHandler = _utils .MethodDispatcher ([
803803 ("html" , self .startTagHtml ),
804804 ("body" , self .startTagBody ),
805805 ("frameset" , self .startTagFrameset ),
@@ -809,8 +809,8 @@ def __init__(self, parser, tree):
809809 ("head" , self .startTagHead )
810810 ])
811811 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 )])
814814 self .endTagHandler .default = self .endTagOther
815815
816816 def processEOF (self ):
@@ -871,7 +871,7 @@ def __init__(self, parser, tree):
871871 # Set this to the default handler
872872 self .processSpaceCharacters = self .processSpaceCharactersNonPre
873873
874- self .startTagHandler = utils .MethodDispatcher ([
874+ self .startTagHandler = _utils .MethodDispatcher ([
875875 ("html" , self .startTagHtml ),
876876 (("base" , "basefont" , "bgsound" , "command" , "link" , "meta" ,
877877 "script" , "style" , "title" ),
@@ -918,7 +918,7 @@ def __init__(self, parser, tree):
918918 ])
919919 self .startTagHandler .default = self .startTagOther
920920
921- self .endTagHandler = utils .MethodDispatcher ([
921+ self .endTagHandler = _utils .MethodDispatcher ([
922922 ("body" , self .endTagBody ),
923923 ("html" , self .endTagHtml ),
924924 (("address" , "article" , "aside" , "blockquote" , "button" , "center" ,
@@ -1588,9 +1588,9 @@ def endTagOther(self, token):
15881588 class TextPhase (Phase ):
15891589 def __init__ (self , parser , tree ):
15901590 Phase .__init__ (self , parser , tree )
1591- self .startTagHandler = utils .MethodDispatcher ([])
1591+ self .startTagHandler = _utils .MethodDispatcher ([])
15921592 self .startTagHandler .default = self .startTagOther
1593- self .endTagHandler = utils .MethodDispatcher ([
1593+ self .endTagHandler = _utils .MethodDispatcher ([
15941594 ("script" , self .endTagScript )])
15951595 self .endTagHandler .default = self .endTagOther
15961596
@@ -1622,7 +1622,7 @@ class InTablePhase(Phase):
16221622 # http://www.whatwg.org/specs/web-apps/current-work/#in-table
16231623 def __init__ (self , parser , tree ):
16241624 Phase .__init__ (self , parser , tree )
1625- self .startTagHandler = utils .MethodDispatcher ([
1625+ self .startTagHandler = _utils .MethodDispatcher ([
16261626 ("html" , self .startTagHtml ),
16271627 ("caption" , self .startTagCaption ),
16281628 ("colgroup" , self .startTagColgroup ),
@@ -1636,7 +1636,7 @@ def __init__(self, parser, tree):
16361636 ])
16371637 self .startTagHandler .default = self .startTagOther
16381638
1639- self .endTagHandler = utils .MethodDispatcher ([
1639+ self .endTagHandler = _utils .MethodDispatcher ([
16401640 ("table" , self .endTagTable ),
16411641 (("body" , "caption" , "col" , "colgroup" , "html" , "tbody" , "td" ,
16421642 "tfoot" , "th" , "thead" , "tr" ), self .endTagIgnore )
@@ -1813,14 +1813,14 @@ class InCaptionPhase(Phase):
18131813 def __init__ (self , parser , tree ):
18141814 Phase .__init__ (self , parser , tree )
18151815
1816- self .startTagHandler = utils .MethodDispatcher ([
1816+ self .startTagHandler = _utils .MethodDispatcher ([
18171817 ("html" , self .startTagHtml ),
18181818 (("caption" , "col" , "colgroup" , "tbody" , "td" , "tfoot" , "th" ,
18191819 "thead" , "tr" ), self .startTagTableElement )
18201820 ])
18211821 self .startTagHandler .default = self .startTagOther
18221822
1823- self .endTagHandler = utils .MethodDispatcher ([
1823+ self .endTagHandler = _utils .MethodDispatcher ([
18241824 ("caption" , self .endTagCaption ),
18251825 ("table" , self .endTagTable ),
18261826 (("body" , "col" , "colgroup" , "html" , "tbody" , "td" , "tfoot" , "th" ,
@@ -1885,13 +1885,13 @@ class InColumnGroupPhase(Phase):
18851885 def __init__ (self , parser , tree ):
18861886 Phase .__init__ (self , parser , tree )
18871887
1888- self .startTagHandler = utils .MethodDispatcher ([
1888+ self .startTagHandler = _utils .MethodDispatcher ([
18891889 ("html" , self .startTagHtml ),
18901890 ("col" , self .startTagCol )
18911891 ])
18921892 self .startTagHandler .default = self .startTagOther
18931893
1894- self .endTagHandler = utils .MethodDispatcher ([
1894+ self .endTagHandler = _utils .MethodDispatcher ([
18951895 ("colgroup" , self .endTagColgroup ),
18961896 ("col" , self .endTagCol )
18971897 ])
@@ -1949,7 +1949,7 @@ class InTableBodyPhase(Phase):
19491949 # http://www.whatwg.org/specs/web-apps/current-work/#in-table0
19501950 def __init__ (self , parser , tree ):
19511951 Phase .__init__ (self , parser , tree )
1952- self .startTagHandler = utils .MethodDispatcher ([
1952+ self .startTagHandler = _utils .MethodDispatcher ([
19531953 ("html" , self .startTagHtml ),
19541954 ("tr" , self .startTagTr ),
19551955 (("td" , "th" ), self .startTagTableCell ),
@@ -1958,7 +1958,7 @@ def __init__(self, parser, tree):
19581958 ])
19591959 self .startTagHandler .default = self .startTagOther
19601960
1961- self .endTagHandler = utils .MethodDispatcher ([
1961+ self .endTagHandler = _utils .MethodDispatcher ([
19621962 (("tbody" , "tfoot" , "thead" ), self .endTagTableRowGroup ),
19631963 ("table" , self .endTagTable ),
19641964 (("body" , "caption" , "col" , "colgroup" , "html" , "td" , "th" ,
@@ -2047,15 +2047,15 @@ class InRowPhase(Phase):
20472047 # http://www.whatwg.org/specs/web-apps/current-work/#in-row
20482048 def __init__ (self , parser , tree ):
20492049 Phase .__init__ (self , parser , tree )
2050- self .startTagHandler = utils .MethodDispatcher ([
2050+ self .startTagHandler = _utils .MethodDispatcher ([
20512051 ("html" , self .startTagHtml ),
20522052 (("td" , "th" ), self .startTagTableCell ),
20532053 (("caption" , "col" , "colgroup" , "tbody" , "tfoot" , "thead" ,
20542054 "tr" ), self .startTagTableOther )
20552055 ])
20562056 self .startTagHandler .default = self .startTagOther
20572057
2058- self .endTagHandler = utils .MethodDispatcher ([
2058+ self .endTagHandler = _utils .MethodDispatcher ([
20592059 ("tr" , self .endTagTr ),
20602060 ("table" , self .endTagTable ),
20612061 (("tbody" , "tfoot" , "thead" ), self .endTagTableRowGroup ),
@@ -2136,14 +2136,14 @@ class InCellPhase(Phase):
21362136 # http://www.whatwg.org/specs/web-apps/current-work/#in-cell
21372137 def __init__ (self , parser , tree ):
21382138 Phase .__init__ (self , parser , tree )
2139- self .startTagHandler = utils .MethodDispatcher ([
2139+ self .startTagHandler = _utils .MethodDispatcher ([
21402140 ("html" , self .startTagHtml ),
21412141 (("caption" , "col" , "colgroup" , "tbody" , "td" , "tfoot" , "th" ,
21422142 "thead" , "tr" ), self .startTagTableOther )
21432143 ])
21442144 self .startTagHandler .default = self .startTagOther
21452145
2146- self .endTagHandler = utils .MethodDispatcher ([
2146+ self .endTagHandler = _utils .MethodDispatcher ([
21472147 (("td" , "th" ), self .endTagTableCell ),
21482148 (("body" , "caption" , "col" , "colgroup" , "html" ), self .endTagIgnore ),
21492149 (("table" , "tbody" , "tfoot" , "thead" , "tr" ), self .endTagImply )
@@ -2212,7 +2212,7 @@ class InSelectPhase(Phase):
22122212 def __init__ (self , parser , tree ):
22132213 Phase .__init__ (self , parser , tree )
22142214
2215- self .startTagHandler = utils .MethodDispatcher ([
2215+ self .startTagHandler = _utils .MethodDispatcher ([
22162216 ("html" , self .startTagHtml ),
22172217 ("option" , self .startTagOption ),
22182218 ("optgroup" , self .startTagOptgroup ),
@@ -2222,7 +2222,7 @@ def __init__(self, parser, tree):
22222222 ])
22232223 self .startTagHandler .default = self .startTagOther
22242224
2225- self .endTagHandler = utils .MethodDispatcher ([
2225+ self .endTagHandler = _utils .MethodDispatcher ([
22262226 ("option" , self .endTagOption ),
22272227 ("optgroup" , self .endTagOptgroup ),
22282228 ("select" , self .endTagSelect )
@@ -2312,13 +2312,13 @@ class InSelectInTablePhase(Phase):
23122312 def __init__ (self , parser , tree ):
23132313 Phase .__init__ (self , parser , tree )
23142314
2315- self .startTagHandler = utils .MethodDispatcher ([
2315+ self .startTagHandler = _utils .MethodDispatcher ([
23162316 (("caption" , "table" , "tbody" , "tfoot" , "thead" , "tr" , "td" , "th" ),
23172317 self .startTagTable )
23182318 ])
23192319 self .startTagHandler .default = self .startTagOther
23202320
2321- self .endTagHandler = utils .MethodDispatcher ([
2321+ self .endTagHandler = _utils .MethodDispatcher ([
23222322 (("caption" , "table" , "tbody" , "tfoot" , "thead" , "tr" , "td" , "th" ),
23232323 self .endTagTable )
23242324 ])
@@ -2466,12 +2466,12 @@ class AfterBodyPhase(Phase):
24662466 def __init__ (self , parser , tree ):
24672467 Phase .__init__ (self , parser , tree )
24682468
2469- self .startTagHandler = utils .MethodDispatcher ([
2469+ self .startTagHandler = _utils .MethodDispatcher ([
24702470 ("html" , self .startTagHtml )
24712471 ])
24722472 self .startTagHandler .default = self .startTagOther
24732473
2474- self .endTagHandler = utils .MethodDispatcher ([("html" , self .endTagHtml )])
2474+ self .endTagHandler = _utils .MethodDispatcher ([("html" , self .endTagHtml )])
24752475 self .endTagHandler .default = self .endTagOther
24762476
24772477 def processEOF (self ):
@@ -2514,15 +2514,15 @@ class InFramesetPhase(Phase):
25142514 def __init__ (self , parser , tree ):
25152515 Phase .__init__ (self , parser , tree )
25162516
2517- self .startTagHandler = utils .MethodDispatcher ([
2517+ self .startTagHandler = _utils .MethodDispatcher ([
25182518 ("html" , self .startTagHtml ),
25192519 ("frameset" , self .startTagFrameset ),
25202520 ("frame" , self .startTagFrame ),
25212521 ("noframes" , self .startTagNoframes )
25222522 ])
25232523 self .startTagHandler .default = self .startTagOther
25242524
2525- self .endTagHandler = utils .MethodDispatcher ([
2525+ self .endTagHandler = _utils .MethodDispatcher ([
25262526 ("frameset" , self .endTagFrameset )
25272527 ])
25282528 self .endTagHandler .default = self .endTagOther
@@ -2571,13 +2571,13 @@ class AfterFramesetPhase(Phase):
25712571 def __init__ (self , parser , tree ):
25722572 Phase .__init__ (self , parser , tree )
25732573
2574- self .startTagHandler = utils .MethodDispatcher ([
2574+ self .startTagHandler = _utils .MethodDispatcher ([
25752575 ("html" , self .startTagHtml ),
25762576 ("noframes" , self .startTagNoframes )
25772577 ])
25782578 self .startTagHandler .default = self .startTagOther
25792579
2580- self .endTagHandler = utils .MethodDispatcher ([
2580+ self .endTagHandler = _utils .MethodDispatcher ([
25812581 ("html" , self .endTagHtml )
25822582 ])
25832583 self .endTagHandler .default = self .endTagOther
@@ -2607,7 +2607,7 @@ class AfterAfterBodyPhase(Phase):
26072607 def __init__ (self , parser , tree ):
26082608 Phase .__init__ (self , parser , tree )
26092609
2610- self .startTagHandler = utils .MethodDispatcher ([
2610+ self .startTagHandler = _utils .MethodDispatcher ([
26112611 ("html" , self .startTagHtml )
26122612 ])
26132613 self .startTagHandler .default = self .startTagOther
@@ -2645,7 +2645,7 @@ class AfterAfterFramesetPhase(Phase):
26452645 def __init__ (self , parser , tree ):
26462646 Phase .__init__ (self , parser , tree )
26472647
2648- self .startTagHandler = utils .MethodDispatcher ([
2648+ self .startTagHandler = _utils .MethodDispatcher ([
26492649 ("html" , self .startTagHtml ),
26502650 ("noframes" , self .startTagNoFrames )
26512651 ])
@@ -2707,7 +2707,7 @@ def processEndTag(self, token):
27072707
27082708
27092709def adjust_attributes (token , replacements ):
2710- if PY3 or utils .PY27 :
2710+ if PY3 or _utils .PY27 :
27112711 needs_adjustment = viewkeys (token ['data' ]) & viewkeys (replacements )
27122712 else :
27132713 needs_adjustment = frozenset (token ['data' ]) & frozenset (replacements )
0 commit comments