ó
    …~i%D  ã                  ó<  • S r SSKJr  SrS/rSSKJr  SSKJrJ	r	J
r
JrJrJrJrJrJrJrJr  SSKJrJrJrJrJrJr  SSKJrJr  SS	KJrJrJ r J!r!  SS
K"J#r#  \(       a  SSK$J%r%  SSKJ&r&  SSK'J(r(J)r)J*r*  Sr+\	\\,\,4   \,\,/S4   r- " S S\\5      r. " S S\ 5      r/g)zCUse the HTMLParser library to parse HTML files that aren't too bad.é    )ÚannotationsÚMITÚHTMLParserTreeBuilder)Ú
HTMLParser)Ú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.parserNc                  ó  • \ rS rSr% SrS\S'   SrS\S'    \S.       SS jjrS\S
'   S\S'   S	\S'   SS jr      SS jr	 S       S S jjr
SS!S jjrS"S jrS#S jrS#S jrS"S jrS$S jrS"S jrS"S jrSrg)%ÚBeautifulSoupHTMLParseré=   ÚreplaceÚstrÚREPLACEÚignoreÚIGNORE©Úon_duplicate_attributeÚsoupr    r.   ú&Union[str, _DuplicateAttributeHandler]c               ó´   • Xl         X l        UR                  R                  U l        [        R
                  " U /UQ70 UD6  / U l        U R                  5         g ©N)r/   r.   ÚbuilderÚattribute_dict_classr   Ú__init__Úalready_closed_empty_elementÚ_initialize_xml_detector)Úselfr/   r.   ÚargsÚkwargss        ÚT/home/mande/repo/quber/.venv/lib/python3.13/site-packages/bs4/builder/_htmlparser.pyr5   Ú BeautifulSoupHTMLParser.__init__T   sO   € ð Œ	Ø&<Ô#Ø$(§L¡L×$EÑ$EˆÔ!Ü×Ò˜DÐ2 4Ò2¨6Ò2ð -/ˆÔ)à×%Ñ%Õ'ó    z	List[str]r6   c                ó   • [        U5      er2   r   )r8   Úmessages     r;   ÚerrorÚBeautifulSoupHTMLParser.erroro   s   € ô # 7Ó+Ð+r=   c                óF   • U R                  XSS9  U R                  U5        g)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)r8   ÚtagÚattrss      r;   Úhandle_startendtagÚ*BeautifulSoupHTMLParser.handle_startendtag   s%   € ð 	×Ñ˜S¸eÐÑDØ×Ñ˜3Õr=   c           	     óp  • U R                  5       nU Hc  u  pVUc  SnXT;   aP  U R                  nXpR                  :X  a  M,  USU R                  4;   a  XdU'   MD  [	        [
        U5      nU" XEU5        M_  XdU'   Me     U R                  R                  R                  (       a  U R                  5       u  p‰OS=p‰U R                  R                  USSXHU	S9n
U
bC  U
R                  (       a2  U(       a+  U R                  USS9  U R                  R                  U5        U R                  c  U R!                  U5        gg)z³Handle 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)r4   r.   r,   r*   r	   Ú_DuplicateAttributeHandlerr/   r3   Ústore_line_numbersÚgetposrD   Úis_empty_elementrE   r6   ÚappendÚ_root_tag_nameÚ_root_tag_encountered)r8   rF   rG   rC   Ú	attr_dictÚkeyÚvalueÚon_duperL   rM   ÚtagObjs              r;   rD   Ú'BeautifulSoupHTMLParser.handle_starttagŽ   s.  € ð $(×#<Ñ#<Ó#>ˆ	Û‰JˆCð ‰}Ø�ØÓð ×5Ñ5�ØŸk™kÓ)ÙØ  t§|¡|Ð 4Ó4Ø%*˜c“Nä"Ô#=¸wÓG�GÙ˜I¨EÖ2à!&˜#“ñ%  ð, �9‰9×Ñ×/×/Ø$(§K¡K£MÑ!ˆJ˜	à%)Ð)ˆJØ—‘×*Ñ*Ø��t˜YÈð +ð 
ˆð Ñ &×"9×"9Ö>Rð ×Ñ˜s¸ÐÑ?ð ×-Ñ-×4Ñ4°SÔ9à×ÑÑ&Ø×&Ñ& sÕ+ð 'r=   c                óž   • U(       a+  XR                   ;   a  U R                   R                  U5        gU R                  R                  U5        g)zÄHandle 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)r6   Úremover/   rE   )r8   rF   rN   s      r;   rE   Ú%BeautifulSoupHTMLParser.handle_endtagÌ   s:   € ö   C×+LÑ+LÓ$Lð
 ×-Ñ-×4Ñ4°SÕ9à�I‰I×#Ñ# CÕ(r=   c                ó:   • U R                   R                  U5        g)z4Handle some textual data that shows up between tags.N)r/   Úhandle_data©r8   Údatas     r;   r`   Ú#BeautifulSoupHTMLParser.handle_dataÞ   s   € à�	‰	×Ñ˜dÕ#r=   c                ód  • UR                  S5      (       a  [        UR                  S5      S5      nO=UR                  S5      (       a  [        UR                  S5      S5      nO[        U5      n[        R                  " U5      u  p4U(       a  SU R
                  l        U R                  U5        g)z·Handle 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.
Úxé   ÚXTN)Ú
startswithÚintÚlstripr   Únumeric_character_referencer/   Úcontains_replacement_charactersr`   )r8   ÚnameÚ	real_namerb   Úreplacement_addeds        r;   Úhandle_charrefÚ&BeautifulSoupHTMLParser.handle_charrefâ   s…   € ð �?‰?˜3×ÑÜ˜DŸK™K¨Ó,¨bÓ1‰IØ�_‰_˜S×!Ñ!Ü˜DŸK™K¨Ó,¨bÓ1‰Iä˜D›	ˆIä"/×"KÒ"KÈIÓ"VÑˆÞØ8<ˆD�I‰IÔ5Ø×Ñ˜Õr=   c                óz   • [         R                  R                  U5      nUb  UnOSU-  nU R                  U5        g)z¨Handle 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Úgetr`   )r8   rm   Ú	characterrb   s       r;   Úhandle_entityrefÚ(BeautifulSoupHTMLParser.handle_entityrefú   s>   € ô '×?Ñ?×CÑCÀDÓIˆ	ØÑ Ø‰Dð ˜4‘<ˆDØ×Ñ˜Õr=   c                ó¬   • U R                   R                  5         U R                   R                  U5        U R                   R                  [        5        g)z?Handle an HTML comment.

:param data: The text of the comment.
N)r/   ÚendDatar`   r   ra   s     r;   Úhandle_commentÚ&BeautifulSoupHTMLParser.handle_comment  s8   € ð
 	�	‰	×ÑÔØ�	‰	×Ñ˜dÔ#Ø�	‰	×Ñœ'Õ"r=   c                óÈ   • U R                   R                  5         U[        S5      S nU R                   R                  U5        U R                   R                  [        5        g)zIHandle a DOCTYPE declaration.

:param data: The text of the declaration.
zDOCTYPE N)r/   ry   Úlenr`   r   )r8   Údecls     r;   Úhandle_declÚ#BeautifulSoupHTMLParser.handle_decl  sI   € ð
 	�	‰	×ÑÔØ”C˜
“OÐ%Ð&ˆØ�	‰	×Ñ˜dÔ#Ø�	‰	×Ñœ'Õ"r=   c                ó"  • UR                  5       R                  S5      (       a  [        nU[        S5      S nO[        nU R
                  R                  5         U R
                  R                  U5        U R
                  R                  U5        g)zkHandle a declaration of unknown type -- probably a CDATA block.

:param data: The text of the declaration.
zCDATA[N)Úupperrh   r   r}   r   r/   ry   r`   )r8   rb   Úclss      r;   Úunknown_declÚ$BeautifulSoupHTMLParser.unknown_decl   si   € ð �:‰:‹<×"Ñ" 8×,Ñ,ÜˆCØœ˜H›˜Ð(‰DäˆCØ�	‰	×ÑÔØ�	‰	×Ñ˜dÔ#Ø�	‰	×Ñ˜#Õr=   c                óÎ   • U R                   R                  5         U R                   R                  U5        U R                  U5        U R                   R                  [        5        g)zLHandle a processing instruction.

:param data: The text of the instruction.
N)r/   ry   r`   Ú_document_might_be_xmlr   ra   s     r;   Ú	handle_piÚ!BeautifulSoupHTMLParser.handle_pi/  sG   € ð
 	�	‰	×ÑÔØ�	‰	×Ñ˜dÔ#Ø×#Ñ# DÔ)Ø�	‰	×ÑÔ/Õ0r=   )r6   r4   r.   r/   N)r/   r    r9   r   r.   r0   r:   r   )r?   r)   ÚreturnÚNone)rF   r)   rG   úList[Tuple[str, Optional[str]]]rŠ   r‹   )T)rF   r)   rG   rŒ   rC   ÚboolrŠ   r‹   )rF   r)   rN   r�   rŠ   r‹   )rb   r)   rŠ   r‹   )rm   r)   rŠ   r‹   )r~   r)   rŠ   r‹   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r*   Ú__annotations__r,   r5   r@   rH   rD   rE   r`   rp   rv   rz   r   r„   rˆ   Ú__static_attributes__© r=   r;   r&   r&   =   sâ   ‡ ð €GˆSÓð €FˆCÓðð$ JQñ	(àð(ð ð(ð !Gð	(ð
 õ(ð. CÓBØ"+Ó+Ø
Óô,ð  Øð Ø>ð à	ô ð& &*ð	<,àð<,ð /ð<,ð #ð	<,ð
 
õ<,ö|)ô$$ôô0ô&#ô#ô÷1r=   r&   c                  óÐ   ^ • \ rS rSr% SrSrS\S'   SrS\S'   \r	S\S	'   \	\
\/rS
\S'   S\S'   SrS\S'     S     SU 4S jjjr   S         SS jjr\4SS jjrSrU =r$ )r   i:  z‹A Beautiful soup `bs4.builder.TreeBuilder` that uses the
:py:class:`html.parser.HTMLParser` parser, found in the Python
standard library.

Fr�   Úis_xmlTÚ	picklabler)   ÚNAMEzIterable[str]Úfeaturesz$Tuple[Iterable[Any], Dict[str, Any]]Úparser_argsÚTRACKS_LINE_NUMBERSc                óô   >• [        5       nS H  nXS;   d  M
  UR                  U5      nXdU'   M!     [        [        U ]  " S0 UD6  U=(       d    / nU=(       d    0 nUR                  U5        SUS'   X4U l        g)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.
r-   FÚconvert_charrefsNr”   )ÚdictÚpopÚsuperr   r5   Úupdaterš   )r8   rš   Úparser_kwargsr:   Úextra_parser_kwargsÚargrX   Ú	__class__s          €r;   r5   ÚHTMLParserTreeBuilder.__init__K  s   ø€ ô$ #›fÐÛ.ˆCØ�}ØŸ
™
 3›�Ø+0 CÓ(ñ /ô 	Ô# TÒ3Ñ=°fÒ=Ø!×' RˆØ%×+¨ˆØ×ÑÐ0Ô1Ø,1ˆÐ(Ñ)Ø'Ð7ˆÕr=   c              #  óZ  #   • [        U[        5      (       a	  USSS4v •  g/ nU(       a  UR                  U5        / nU(       a  UR                  U5        [        UUUSUS9nUR                  c  [        S5      eUR                  UR                  UR                  UR                  4v •  g7f)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_htmlÚexclude_encodingszPCould not convert input to Unicode, and html.parser will not accept bytestrings.)	Ú
isinstancer)   rS   r   Úunicode_markupr   Úoriginal_encodingÚdeclared_html_encodingrl   )r8   ÚmarkupÚuser_specified_encodingÚdocument_declared_encodingr«   r¨   r©   Údammits           r;   Úprepare_markupÚ$HTMLParserTreeBuilder.prepare_markupi  sÄ   é € ô2 �fœc×"Ñ"à˜4  uÐ-Ò-Øð 57Ð Þ"ð
 %×+Ñ+Ð,CÔDà*,ˆÞ%ð ×!Ñ!Ð"<Ô=äØØ%=Ø)ØØ/ñ
ˆð × Ñ Ñ(ô 'Øbóð ð
 ×%Ñ%Ø×(Ñ(Ø×-Ñ-Ø×6Ñ6ð	ó ùs   ‚B)B+c                ó$  • U R                   u  p4[        U[        5      (       d   eU R                  c   eU" U R                  /UQ70 UD6n UR	                  U5        UR                  5         / Ul        g! [         a  n[        U5      eSnAff = f)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   r6   )r8   r°   Ú_parser_classr9   r:   ÚparserÚes          r;   r·   ÚHTMLParserTreeBuilder.feed±  s“   € ð
 ×'Ñ'‰ˆô ˜&¤#×&Ñ&Ð&Ð&ð
 �y‰yÑ$Ð$Ð$Ù˜tŸy™yÐ:¨4Ò:°6Ñ:ˆð	*Ø�K‰K˜ÔØ�L‰LŒNð /1ˆÕ+øô ó 	*ô ' qÓ)Ð)ûð		*ús   Á!A5 Á5
BÁ?B
Â
B)rš   )NN)rš   zOptional[Iterable[Any]]r¢   zOptional[Dict[str, Any]]r:   r   )NNN)
r°   r$   r±   úOptional[_Encoding]r²   r¾   r«   zOptional[_Encodings]rŠ   zDIterable[Tuple[str, Optional[_Encoding], Optional[_Encoding], bool]])r°   r$   rº   ztype[BeautifulSoupHTMLParser]rŠ   r‹   )rŽ   r�   r�   r‘   Ú__doc__r–   r’   r—   Ú
HTMLPARSERr˜   r   r   r™   r›   r5   r´   r&   r·   r“   Ú__classcell__)r¥   s   @r;   r   r   :  sÔ   ø‡ ñð €FˆDÓØ€IˆtÓØ€Dˆ#ÓØ# T¨6Ð2€HˆmÓ2Ø5Ó5ð !%Ð˜Ó$ð 04Ø26ð8à,ð8ð 0ð8ð ÷	8ð 8ðB 8<Ø:>Ø26ðFàðFð "5ðFð %8ð	Fð
 0ðFð 
NõFðP Ul÷ 1ô 1r=   )0r¿   Ú
__future__r   Ú__license__Ú__all__Úhtml.parserr   Ú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)   rO   r&   r   r”   r=   r;   Ú<module>rÍ      s®   ðá IÝ "ð €ð ð€õ #÷÷ ÷ ñ ÷÷ ÷ 9÷ó õ 0æÝ!Ý+÷ñ ð €
à% t¨C°¨H¡~°s¸CÐ&@À$Ð&FÑGÐ ôz1˜jÐ*@ô z1ôzT1˜Oõ T1r=   