+
    CiyL                    X   R t ^ RIHt RtR.t^ RIHt ^ RIt^ RIH	t	H
t
HtHtHtHtHtHtHtHtHt ^ RIHtHtHtHtHtHt ^ RIHtHt ^ R	IHtH t H!t!H"t" ^ R
I#H$t$ ]'       d   ^ RI%H&t& ^ RIH't' ^ RI(H)t)H*t*H+t+ Rt,]
]]-]-3,          ]-]-.R3,          t. ! R R]]4      t/ ! R R]!4      t0R# )zCUse the HTMLParser library to parse HTML files that aren't too bad.)annotationsMITHTMLParserTreeBuilder)
HTMLParserN)AnyCallablecastDictIterableListOptionalTYPE_CHECKINGTupleTypeUnion)AttributeDictCDataCommentDeclarationDoctypeProcessingInstruction)EntitySubstitutionUnicodeDammit)DetectsXMLParsedAsHTMLHTMLHTMLTreeBuilderSTRICTParserRejectedMarkup)BeautifulSoup)NavigableString)	_Encoding
_Encodings
_RawMarkupzhtml.parserc                  R   ] tR t^>t$ RtR]R&   RtR]R&    R]/R R lltR	]R&   R
]R&   R]R&   R R ltR R lt	R*R R llt
R*R R lltR R lt]P                  ! R4      t]P                  ! R4      t]R R l4       tR R ltR R ltR  R! ltR" R# ltR$ R% ltR& R' ltR(tR)# )+BeautifulSoupHTMLParserreplacestrREPLACEignoreIGNOREon_duplicate_attributec               (    V ^8  d   QhRRRRRRRR/# )   soupr   argsr   r+   &Union[str, _DuplicateAttributeHandler]kwargs )formats   "9/usr/lib/python3/dist-packages/bs4/builder/_htmlparser.py__annotate__$BeautifulSoupHTMLParser.__annotate__U   s3     ( (( ( !G	(
 (    c               	    Wn         W n        VP                  P                  V n        \        P
                  ! V .VO5/ VB  . V n        V P                  4        R # N)r.   r+   builderattribute_dict_classr   __init__already_closed_empty_element_initialize_xml_detector)selfr.   r+   r/   r1   s   &&$*,r4   r<    BeautifulSoupHTMLParser.__init__U   sO     	&<#$(LL$E$E!D24262 -/)%%'r7   r0   z	List[str]r=   r   r.   c                    V ^8  d   QhRRRR/# )r-   messager'   returnNoner2   )r3   s   "r4   r5   r6   p   s     , ,S ,T ,r7   c                	    \        V4      hr9   r   )r?   rB   s   &&r4   errorBeautifulSoupHTMLParser.errorp   s     #7++r7   c               $    V ^8  d   QhRRRRRR/# )r-   tagr'   attrsList[Tuple[str, Optional[str]]]rC   rD   r2   )r3   s   "r4   r5   r6      s$         > 	 r7   c                N    V P                  WRR7       V P                  V4       R# )zmHandle an incoming empty-element tag.

html.parser only calls this method when the markup looks like
<tag/>.
F)handle_empty_elementN)handle_starttaghandle_endtag)r?   rI   rJ   s   &&&r4   handle_startendtag*BeautifulSoupHTMLParser.handle_startendtag   s%     	SeD3r7   c               (    V ^8  d   QhRRRRRRRR/# )	r-   rI   r'   rJ   rK   rM   boolrC   rD   r2   )r3   s   "r4   r5   r6      s2     <, <,<, /<, #	<,
 
<,r7   c           	        V P                  4       pV Fg  w  rVVf   RpWT9   dS   V P                  pWpP                  8X  d   K/  VRV P                  39   d   WdV&   KH  \	        \
        V4      pV! WEV4       Kc  WdV&   Ki  	  V P                  P                  P                  '       d   V P                  4       w  rMR;rV P                  P                  VRRWHV	R7      p
V
eI   V
P                  '       d7   V'       d/   V P                  VRR7       V P                  P                  V4       V P                  f   V P!                  V4       R# R# )zHandle an opening tag, e.g. '<tag>'

:param handle_empty_element: True if this tag is known to be
    an empty-element tag (i.e. there is not expected to be any
    closing tag).
N )
sourceline	sourceposF)check_already_closed)r;   r+   r*   r(   r   _DuplicateAttributeHandlerr.   r:   store_line_numbersgetposrN   is_empty_elementrO   r=   append_root_tag_name_root_tag_encountered)r?   rI   rJ   rM   	attr_dictkeyvalueon_duperV   rW   tagObjs   &&&&       r4   rN   'BeautifulSoupHTMLParser.handle_starttag   s4    $(#<#<#>	JC } 55kk)t|| 44%*cN"#=wGGIE2!&#%  , 99///$(KKM!J	%))J**tY + 
 &"9"9"9>R s? --44S9&&&s+ 'r7   c               $    V ^8  d   QhRRRRRR/# )r-   rI   r'   rX   rS   rC   rD   r2   )r3   s   "r4   r5   r6      s!     ) ) )D )D )r7   c                    V'       d.   WP                   9   d   V P                   P                  V4       R# V P                  P                  V4       R# )zHandle a closing tag, e.g. '</tag>'

:param tag: A tag name.
:param check_already_closed: True if this tag is expected to
   be the closing portion of an empty-element tag,
   e.g. '<tag></tag>'.
N)r=   remover.   rO   )r?   rI   rX   s   &&&r4   rO   %BeautifulSoupHTMLParser.handle_endtag   s:      C+L+L$L
 --44S9II##C(r7   c                    V ^8  d   QhRRRR/# r-   datar'   rC   rD   r2   )r3   s   "r4   r5   r6      s     $ $ $ $r7   c                <    V P                   P                  V4       R# )z4Handle some textual data that shows up between tags.N)r.   handle_datar?   rl   s   &&r4   rn   #BeautifulSoupHTMLParser.handle_data   s    		d#r7   z^([0-9]+)(.*)z^([0-9a-f]+)(.*)c                    V ^8  d   QhRRRR/# )r-   namer'   rC   zTuple[str, bool, str]r2   )r3   s   "r4   r5   r6      s     4; 4;3 4;CX 4;r7   c                   RpRpRp^
pV P                   pVP                  R4      '       g   VP                  R4      '       d   VR,          p^pV P                  pRp \        W4      pVf   RpTpM\        P                  ! V4      w  r#W#V3#   \         dQ    TP                  T4      pTe9   \        TP                  4       ^ ,          T4      pTP                  4       ^,          p Li ; i)aX  Convert a numeric character reference into an actual character.

:param name: The number of the character reference, as
  obtained by html.parser

:return: A 3-tuple (dereferenced, replacement_added,
  extra_data). `dereferenced` is the dereferenced character
  reference, or the empty string if there was no
  reference. `replacement_added` is True if the reference
  could only be dereferenced by replacing content with U+FFFD
  REPLACEMENT CHARACTER. `extra_data` is a portion of data
  following the character reference, which was deemed to be
  normal data and not part of the reference at all.
rU   FxX:   NNN)	&_DECIMAL_REFERENCE_WITH_FOLLOWING_DATA
startswith"_HEX_REFERENCE_WITH_FOLLOWING_DATAint
ValueErrorsearchgroupsr   numeric_character_reference)	clsrr   dereferencedreplacement_added
extra_databasereg	real_namematchs	   &&       r4   (_dereference_numeric_character_reference@BeautifulSoupHTMLParser._dereference_numeric_character_reference   s      !&
88??34??3#7#78DD88C"&		/DI$ LJ.;.W.WXa.b+L
::-  	/ JJt$E q 148	"\\^A.
	/s   B AC('C(c                    V ^8  d   QhRRRR/# r-   rr   r'   rC   rD   r2   )r3   s   "r4   r5   r6     s     ) )3 )4 )r7   c                    V P                  V4      w  r#pV'       d   RV P                  n        Ve   V P                  V4       Ve   V P                  V4       R# R# )zHandle a numeric character reference by converting it to the
corresponding Unicode character and treating it as textual
data.

:param name: Character number, possibly in hexadecimal.
TN)r   r.   contains_replacement_charactersrn   )r?   rr   r   r   r   s   &&   r4   handle_charref&BeautifulSoupHTMLParser.handle_charref  sV     7;6c6cdh6i38<DII5#\*!Z( "r7   c                    V ^8  d   QhRRRR/# r   r2   )r3   s   "r4   r5   r6   ,  s      S T r7   c                    \         P                  P                  V4      pVe   TpM	RV,          pV P                  V4       R# )zHandle a named entity reference by converting it to the
corresponding Unicode character(s) and treating it as textual
data.

:param name: Name of the entity reference.
Nz&%s)r   HTML_ENTITY_TO_CHARACTERgetrn   )r?   rr   	characterrl   s   &&  r4   handle_entityref(BeautifulSoupHTMLParser.handle_entityref,  s>     '??CCDI	 D 4<Dr7   c                    V ^8  d   QhRRRR/# rk   r2   )r3   s   "r4   r5   r6   ?  s     # #3 #4 #r7   c                    V P                   P                  4        V P                   P                  V4       V P                   P                  \        4       R# )z?Handle an HTML comment.

:param data: The text of the comment.
N)r.   endDatarn   r   ro   s   &&r4   handle_comment&BeautifulSoupHTMLParser.handle_comment?  s8    
 					d#		'"r7   c                    V ^8  d   QhRRRR/# )r-   declr'   rC   rD   r2   )r3   s   "r4   r5   r6   H  s     # # # #r7   c                    V P                   P                  4        V\        R4      R pV P                   P                  V4       V P                   P                  \        4       R# )zIHandle a DOCTYPE declaration.

:param data: The text of the declaration.
zDOCTYPE N)r.   r   lenrn   r   )r?   r   s   &&r4   handle_decl#BeautifulSoupHTMLParser.handle_declH  sI    
 			C
O%&		d#		'"r7   c                    V ^8  d   QhRRRR/# rk   r2   )r3   s   "r4   r5   r6   R  s        r7   c                &   VP                  4       P                  R4      '       d   \        pV\        R4      R pM\        pV P
                  P                  4        V P
                  P                  V4       V P
                  P                  V4       R# )zkHandle a declaration of unknown type -- probably a CDATA block.

:param data: The text of the declaration.
zCDATA[N)upperrx   r   r   r   r.   r   rn   )r?   rl   r   s   && r4   unknown_decl$BeautifulSoupHTMLParser.unknown_declR  si     ::<""8,,CH(DC				d#		#r7   c                    V ^8  d   QhRRRR/# rk   r2   )r3   s   "r4   r5   r6   a  s     1 1c 1d 1r7   c                    V P                   P                  4        V P                   P                  V4       V P                  V4       V P                   P                  \        4       R# )zLHandle a processing instruction.

:param data: The text of the instruction.
N)r.   r   rn   _document_might_be_xmlr   ro   s   &&r4   	handle_pi!BeautifulSoupHTMLParser.handle_pia  sG    
 					d###D)		/0r7   )r=   r;   r+   r.   N)T)__name__
__module____qualname____firstlineno__r(   __annotations__r*   r<   rF   rP   rN   rO   rn   recompilerw   ry   classmethodr   r   r   r   r   r   r   __static_attributes__r2   r7   r4   r%   r%   >   s     GS FC( JQ	(. CB"++
,  <,|)$$ .0ZZ-H*)+4F)G&4; 4;l)&##1 1r7   r%   c                     a  ] tR tRt$ RtRtR]R&   RtR]R&   ]t	R]R	&   ]	]
].tR
]R&   R]R&   RtR]R&   RR V 3R llltRR R llt]3R R lltRtV ;t# )r   il  zA Beautiful soup `bs4.builder.TreeBuilder` that uses the
:py:class:`html.parser.HTMLParser` parser, found in the Python
standard library.

FrS   is_xmlT	picklabler'   NAMEzIterable[str]featuresz$Tuple[Iterable[Any], Dict[str, Any]]parser_argsTRACKS_LINE_NUMBERSc               $    V ^8  d   QhRRRRRR/# )r-   r   zOptional[Iterable[Any]]parser_kwargszOptional[Dict[str, Any]]r1   r   r2   )r3   s   "r4   r5   "HTMLParserTreeBuilder.__annotate__}  s(     8 8,8 08 	8r7   c                   < \        4       pR F   pWS9   g   K  VP                  V4      pWdV&   K"  	  \        \        V `  ! R/ VB  T;'       g    . pT;'       g    / pVP                  V4       RVR&   W3V n        R# )aB  Constructor.

:param parser_args: Positional arguments to pass into
    the BeautifulSoupHTMLParser constructor, once it's
    invoked.
:param parser_kwargs: Keyword arguments to pass into
    the BeautifulSoupHTMLParser constructor, once it's
    invoked.
:param kwargs: Keyword arguments for the superclass constructor.
Fconvert_charrefsN)r+   r2   )dictpopsuperr   r<   updater   )r?   r   r   r1   extra_parser_kwargsargrb   	__class__s   &&&,   r4   r<   HTMLParserTreeBuilder.__init__}  s    $ #f.C}

3+0C( / 	#T3=f=!''R%++01,1()'7r7   c          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
r-   markupr#   user_specified_encodingzOptional[_Encoding]document_declared_encodingexclude_encodingszOptional[_Encodings]rC   zDIterable[Tuple[str, Optional[_Encoding], Optional[_Encoding], bool]]r2   )r3   s   "r4   r5   r     sD     F FF "5F %8	F
 0F 
NFr7   c              #  l  "   \        V\        4      '       d   VRRR3x  R# . pV'       d   VP                  V4       . pV'       d   VP                  V4       \        VVVRVR7      pVP                  f   \        R4      hVP                  VP                  VP                  VP                  3x  R# 5i)a  Run any preliminary steps necessary to make incoming markup
acceptable to the parser.

:param markup: Some markup -- probably a bytestring.
:param user_specified_encoding: The user asked to try this encoding.
:param document_declared_encoding: The markup itself claims to be
    in this encoding.
:param exclude_encodings: The user asked _not_ to try any of
    these encodings.

:yield: A series of 4-tuples: (markup, encoding, declared encoding,
     has undergone character replacement)

    Each 4-tuple represents a strategy for parsing the document.
    This TreeBuilder uses Unicode, Dammit to convert the markup
    into Unicode, so the ``markup`` element of the tuple will
    always be a string.
NFT)known_definite_encodingsuser_encodingsis_htmlr   zPCould not convert input to Unicode, and html.parser will not accept bytestrings.)	
isinstancer'   r]   r   unicode_markupr   original_encodingdeclared_html_encodingr   )r?   r   r   r   r   r   r   dammits   &&&&&   r4   prepare_markup$HTMLParserTreeBuilder.prepare_markup  s     2 fc""4u-- 57 "
 %++,CD*,% !!"<=%=)/
   ( 'b 
 %%((--66	 s   *B4B4A,B4c               $    V ^8  d   QhRRRRRR/# )r-   r   r#   _parser_classztype[BeautifulSoupHTMLParser]rC   rD   r2   )r3   s   "r4   r5   r     s#     1 1: 15R 1pt 1r7   c                ,   V P                   w  r4\        V\        4      '       g   Q hV P                  f   Q hV! V P                  .VO5/ VB p VP	                  V4       VP                  4        . Tn        R#   \         d   p\        T4      hRp?ii ; i)z
:param markup: The markup to feed into the parser.
:param _parser_class: An HTMLParser subclass to use. This is only intended for use in unit tests.
N)	r   r   r'   r.   feedcloseAssertionErrorr   r=   )r?   r   r   r/   r1   parseres   &&&    r4   r   HTMLParserTreeBuilder.feed  s    
 '' &#&&&&
 yy$$$tyy:4:6:	*KKLLN /1+  	* 'q))		*s   !A8 8BBB)r   )NN)NNN)r   r   r   r   __doc__r   r   r   
HTMLPARSERr   r   r   r   r   r<   r   r%   r   r   __classcell__)r   s   @r4   r   r   l  sn     FDItD##T62Hm255 !%$8 8<FP Ul 1 1r7   )1r   
__future__r   __license____all__html.parserr   r   typingr   r   r   r	   r
   r   r   r   r   r   r   bs4.elementr   r   r   r   r   r   
bs4.dammitr   r   bs4.builderr   r   r   r   bs4.exceptionsr   bs4r   r    bs4._typingr!   r"   r#   r   r'   rY   r%   r   r2   r7   r4   <module>r      s    I "   # 	     9  0!+  
%tCH~sC&@$&FG k1j*@ k1\	T1O T1r7   