§
    ¥”j%D  ã                  óL  — d Z ddlmZ dZdgZddlmZ ddlmZm	Z	m
Z
mZmZmZmZmZmZmZmZ ddlmZmZmZmZmZmZ ddlmZmZ dd	lmZmZm Z m!Z! dd
l"m#Z# erddl$m%Z% ddlm&Z& ddl'm(Z(m)Z)m*Z* dZ+e	ee,e,f         e,e,gdf         Z- G d„ dee¦  «        Z. G d„ de ¦  «        Z/dS )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                  ó¸   — e Zd ZU dZded<   dZded<   	 edœd*d„Zded<   ded<   ded<   d+d„Zd,d„Z	 d-d.d„Z	d-d/d„Z
d0d „Zd1d"„Zd1d#„Zd0d$„Zd2d&„Zd0d'„Zd0d(„Zd)S )3ÚBeautifulSoupHTMLParserÚreplaceÚstrÚREPLACEÚignoreÚIGNORE©Úon_duplicate_attributeÚsoupr    Úargsr   r-   ú&Union[str, _DuplicateAttributeHandler]Úkwargsc               ó¤   — || _         || _        |j        j        | _        t	          j        | g|¢R i |¤Ž g | _        |                      ¦   «          d S ©N)r.   r-   ÚbuilderÚattribute_dict_classr   Ú__init__Úalready_closed_empty_elementÚ_initialize_xml_detector)Úselfr.   r-   r/   r1   s        úf/var/www/finuniver-perm.ru/html/portfolio/venv/lib/python3.11/site-packages/bs4/builder/_htmlparser.pyr6   z BeautifulSoupHTMLParser.__init__T   sc   € ð ˆŒ	Ø&<ˆÔ#Ø$(¤LÔ$EˆÔ!ÝÔ˜DÐ2 4Ð2Ð2Ð2¨6Ð2Ð2Ð2ð -/ˆÔ)à×%Ò%Ñ'Ô'Ð'Ð'Ð'ó    z	List[str]r7   ÚmessageÚreturnÚNonec                ó    — t          |¦  «        ‚r3   r   )r9   r<   s     r:   ÚerrorzBeautifulSoupHTMLParser.erroro   s   € õ # 7Ñ+Ô+Ð+r;   ÚtagÚattrsúList[Tuple[str, Optional[str]]]c                ó`   — |                       ||d¬¦  «         |                      |¦  «         dS )z…Handle 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)r9   rA   rB   s      r:   Úhandle_startendtagz*BeautifulSoupHTMLParser.handle_startendtag   s9   € ð 	×Ò˜S %¸eÐÑDÔDÐDØ×Ò˜3ÑÔÐÐÐr;   TrE   Úboolc                ó4  — |                       ¦   «         }|D ]Y\  }}|€d}||v rG| j        }|| j        k    rŒ |d| j        fv r|||<   Œ1t	          t
          |¦  «        } ||||¦  «         ŒT|||<   ŒZ| j        j        j        r|  	                    ¦   «         \  }}	ndx}}	| j         
                    |dd|||	¬¦  «        }
|
�:|
j        r3|r1|                      |d¬¦  «         | j                             |¦  «         | j        €|                      |¦  «         dS dS )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)r5   r-   r+   r)   r	   Ú_DuplicateAttributeHandlerr.   r4   Ústore_line_numbersÚgetposrF   Úis_empty_elementrG   r7   ÚappendÚ_root_tag_nameÚ_root_tag_encountered)r9   rA   rB   rE   Ú	attr_dictÚkeyÚvalueÚon_duperL   rM   ÚtagObjs              r:   rF   z'BeautifulSoupHTMLParser.handle_starttagŽ   sv  € ð $(×#<Ò#<Ñ#>Ô#>ˆ	Øð 	'ð 	'‰JˆC�ð ˆ}Ø�Ø�iÐÐð Ô5�Ø˜dœkÒ)Ð)ØØ  t¤|Ð 4Ð4Ð4Ø%*�I˜c‘N�Nå"Õ#=¸wÑGÔG�GØ�G˜I s¨EÑ2Ô2Ð2Ð2à!&�	˜#‘�ð Œ9ÔÔ/ð 	*Ø$(§K¢K¡M¤MÑ!ˆJ˜	˜	à%)Ð)ˆJ˜Ø”×*Ò*Ø��t˜Y°:Èð +ñ 
ô 
ˆð Ð &Ô"9ÐÐ>RÐð ×Ò˜s¸ÐÑ?Ô?Ð?ð Ô-×4Ò4°SÑ9Ô9Ð9àÔÐ&Ø×&Ò& sÑ+Ô+Ð+Ð+Ð+ð 'Ð&r;   rN   c                óˆ   — |r%|| j         v r| j                              |¦  «         dS | j                             |¦  «         dS )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)r7   Úremover.   rG   )r9   rA   rN   s      r:   rG   z%BeautifulSoupHTMLParser.handle_endtagÌ   sT   € ð  ð 	) C¨4Ô+LÐ$LÐ$Lð
 Ô-×4Ò4°SÑ9Ô9Ð9Ð9Ð9àŒI×#Ò# CÑ(Ô(Ð(Ð(Ð(r;   Údatac                ó:   — | j                              |¦  «         dS )z4Handle some textual data that shows up between tags.N)r.   Úhandle_data©r9   r]   s     r:   r_   z#BeautifulSoupHTMLParser.handle_dataÞ   s   € àŒ	×Ò˜dÑ#Ô#Ð#Ð#Ð#r;   Únamec                ó|  — |                      d¦  «        r$t          |                     d¦  «        d¦  «        }nH|                      d¦  «        r$t          |                     d¦  «        d¦  «        }nt          |¦  «        }t          j        |¦  «        \  }}|rd| j        _        |                      |¦  «         dS )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_   )r9   ra   Ú	real_namer]   Úreplacement_addeds        r:   Úhandle_charrefz&BeautifulSoupHTMLParser.handle_charrefâ   s³   € ð �?Š?˜3ÑÔð 	"Ý˜DŸKšK¨Ñ,Ô,¨bÑ1Ô1ˆIˆIØ�_Š_˜SÑ!Ô!ð 	"Ý˜DŸKšK¨Ñ,Ô,¨bÑ1Ô1ˆIˆIå˜D™	œ	ˆIå"/Ô"KÈIÑ"VÔ"VÑˆÐØð 	=Ø8<ˆDŒIÔ5Ø×Ò˜ÑÔÐÐÐr;   c                ó‚   — t           j                             |¦  «        }|�|}nd|z  }|                      |¦  «         dS )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_   )r9   ra   Ú	characterr]   s       r:   Úhandle_entityrefz(BeautifulSoupHTMLParser.handle_entityrefú   sL   € õ 'Ô?×CÒCÀDÑIÔIˆ	ØÐ ØˆDˆDð ˜4‘<ˆDØ×Ò˜ÑÔÐÐÐr;   c                óª   — | j                              ¦   «          | j                              |¦  «         | j                              t          ¦  «         dS )zOHandle an HTML comment.

        :param data: The text of the comment.
        N)r.   ÚendDatar_   r   r`   s     r:   Úhandle_commentz&BeautifulSoupHTMLParser.handle_comment  sJ   € ð
 	Œ	×ÒÑÔÐØŒ	×Ò˜dÑ#Ô#Ð#ØŒ	×Ò�'Ñ"Ô"Ð"Ð"Ð"r;   Údeclc                óØ   — | j                              ¦   «          |t          d¦  «        d…         }| j                              |¦  «         | j                              t          ¦  «         dS )zYHandle a DOCTYPE declaration.

        :param data: The text of the declaration.
        zDOCTYPE N)r.   rt   Úlenr_   r   )r9   rv   s     r:   Úhandle_declz#BeautifulSoupHTMLParser.handle_decl  s`   € ð
 	Œ	×ÒÑÔÐØ•C˜
‘O”OÐ%Ð%Ô&ˆØŒ	×Ò˜dÑ#Ô#Ð#ØŒ	×Ò�'Ñ"Ô"Ð"Ð"Ð"r;   c                ó:  — |                      ¦   «                              d¦  «        rt          }|t          d¦  «        d…         }nt          }| j                             ¦   «          | j                             |¦  «         | j                             |¦  «         dS )z{Handle a declaration of unknown type -- probably a CDATA block.

        :param data: The text of the declaration.
        zCDATA[N)Úupperrf   r   rx   r   r.   rt   r_   )r9   r]   Úclss      r:   Úunknown_declz$BeautifulSoupHTMLParser.unknown_decl   sˆ   € ð �:Š:‰<Œ<×"Ò" 8Ñ,Ô,ð 	ÝˆCØ�˜H™œ˜˜Ô(ˆDˆDåˆCØŒ	×ÒÑÔÐØŒ	×Ò˜dÑ#Ô#Ð#ØŒ	×Ò˜#ÑÔÐÐÐr;   c                óÔ   — | j                              ¦   «          | j                              |¦  «         |                      |¦  «         | j                              t          ¦  «         dS )z\Handle a processing instruction.

        :param data: The text of the instruction.
        N)r.   rt   r_   Ú_document_might_be_xmlr   r`   s     r:   Ú	handle_piz!BeautifulSoupHTMLParser.handle_pi/  s_   € ð
 	Œ	×ÒÑÔÐØŒ	×Ò˜dÑ#Ô#Ð#Ø×#Ò# DÑ)Ô)Ð)ØŒ	×ÒÕ/Ñ0Ô0Ð0Ð0Ð0r;   N)r.   r    r/   r   r-   r0   r1   r   )r<   r(   r=   r>   )rA   r(   rB   rC   r=   r>   )T)rA   r(   rB   rC   rE   rI   r=   r>   )rA   r(   rN   rI   r=   r>   )r]   r(   r=   r>   )ra   r(   r=   r>   )rv   r(   r=   r>   )Ú__name__Ú
__module__Ú__qualname__r)   Ú__annotations__r+   r6   r@   rH   rF   rG   r_   rm   rr   ru   ry   r}   r€   © r;   r:   r&   r&   =   sy  € € € € € € ð €GÐÐÐÑð €FÐÐÐÑðð$ JQð	(ð (ð (ð (ð (ð (ð. CÐBÐBÑBØ+Ð+Ð+Ñ+ØÐÐÑð,ð ,ð ,ð ,ð  ð  ð  ð  ð& &*ð	<,ð <,ð <,ð <,ð <,ð|)ð )ð )ð )ð )ð$$ð $ð $ð $ðð ð ð ð0ð ð ð ð&#ð #ð #ð #ð#ð #ð #ð #ðð ð ð ð1ð 1ð 1ð 1ð 1ð 1r;   r&   c                  óž   ‡ — e Zd ZU dZdZded<   dZded<   eZded<   ee	e
gZd	ed
<   ded<   dZded<   	 	 d#d$ˆ fd„Z	 	 	 d%d&d„Zefd'd"„Zˆ xZS )(r   z—A Beautiful soup `bs4.builder.TreeBuilder` that uses the
    :py:class:`html.parser.HTMLParser` parser, found in the Python
    standard library.

    FrI   Úis_xmlTÚ	picklabler(   ÚNAMEzIterable[str]Úfeaturesz$Tuple[Iterable[Any], Dict[str, Any]]Úparser_argsÚTRACKS_LINE_NUMBERSNúOptional[Iterable[Any]]Úparser_kwargsúOptional[Dict[str, Any]]r1   r   c                ó   •— t          ¦   «         }dD ] }||v r|                     |¦  «        }|||<   Œ! t          t          | ¦  «        j        di |¤Ž |pg }|pi }|                     |¦  «         d|d<   ||f| _        dS )a‚  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   r6   Úupdater‹   )r9   r‹   rŽ   r1   Úextra_parser_kwargsÚargrX   Ú	__class__s          €r:   r6   zHTMLParserTreeBuilder.__init__K  s­   ø€ õ$ #™fœfÐØ.ð 	1ð 	1ˆCØ�fˆ}ˆ}ØŸ
š
 3™œ�Ø+0Ð# CÑ(øØ3�Õ# TÑ*Ô*Ô3Ð=Ð=°fÐ=Ð=Ð=Ø!Ð' RˆØ%Ð+¨ˆØ×ÒÐ0Ñ1Ô1Ð1Ø,1ˆÐ(Ñ)Ø'¨Ð7ˆÔÐÐr;   Úmarkupr$   Úuser_specified_encodingúOptional[_Encoding]Údocument_declared_encodingÚexclude_encodingsúOptional[_Encodings]r=   úDIterable[Tuple[str, Optional[_Encoding], Optional[_Encoding], bool]]c              #  ó8  K  — t          |t          ¦  «        r
|dddfV — dS g }|r|                     |¦  «         g }|r|                     |¦  «         t          |||d|¬¦  «        }|j        €t          d¦  «        ‚|j        |j        |j        |j        fV — dS )a2  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(   rS   r   Úunicode_markupr   Úoriginal_encodingÚdeclared_html_encodingrj   )r9   r™   rš   rœ   r�   r¡   r¢   Údammits           r:   Úprepare_markupz$HTMLParserTreeBuilder.prepare_markupi  sý   è è € õ2 �f�cÑ"Ô"ð 	à˜4  uÐ-Ð-Ð-Ð-ØˆFð 57Ð Ø"ð 	Eð
 %×+Ò+Ð,CÑDÔDÐDà*,ˆØ%ð 	>ð ×!Ò!Ð"<Ñ=Ô=Ð=åØØ%=Ø)ØØ/ð
ñ 
ô 
ˆð Ô Ð(õ 'Øbñô ð ð
 Ô%ØÔ(ØÔ-ØÔ6ð	ð ð ð ð ð r;   Ú_parser_classútype[BeautifulSoupHTMLParser]r>   c                ó"  — | j         \  }}t          |t          ¦  «        sJ ‚| j        €J ‚ || j        g|¢R i |¤Ž}	 |                     |¦  «         |                     ¦   «          n!# t          $ r}t          |¦  «        ‚d}~ww xY wg |_        dS )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   r7   )r9   r™   rª   r/   r1   ÚparserÚes          r:   r­   zHTMLParserTreeBuilder.feed±  s¾   € ð
 Ô'‰ˆˆfõ ˜&¥#Ñ&Ô&Ð&Ð&Ð&ð
 ŒyÐ$Ð$Ð$Ø�˜tœyÐ:¨4Ð:Ð:Ð:°6Ð:Ð:ˆð	*Ø�KŠK˜ÑÔÐØ�LŠL‰NŒNˆNˆNøÝð 	*ð 	*ð 	*õ ' qÑ)Ô)Ð)øøøøð		*øøøð
 /1ˆÔ+Ð+Ð+s   ½)A' Á'
BÁ1B Â B)NN)r‹   r�   rŽ   r�   r1   r   )NNN)
r™   r$   rš   r›   rœ   r›   r�   rž   r=   rŸ   )r™   r$   rª   r«   r=   r>   )r�   r‚   rƒ   Ú__doc__r‡   r„   rˆ   Ú
HTMLPARSERr‰   r   r   rŠ   rŒ   r6   r©   r&   r­   Ú__classcell__)r˜   s   @r:   r   r   :  s  ø€ € € € € € ðð ð €FÐÐÐÑØ€IÐÐÐÑØ€DÐÐÐÑØ# T¨6Ð2€HÐ2Ð2Ð2Ñ2Ø5Ð5Ð5Ñ5ð !%ÐÐ$Ð$Ð$Ñ$ð 04Ø26ð8ð 8ð 8ð 8ð 8ð 8ð 8ðB 8<Ø:>Ø26ðFð Fð Fð Fð FðP Ulð 1ð 1ð 1ð 1ð 1ð 1ð 1ð 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À      sx  ðà IÐ IØ "Ð "Ð "Ð "Ð "Ð "ð €ð ð€ð #Ð "Ð "Ð "Ð "Ð "ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð 9Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8ðð ð ð ð ð ð ð ð ð ð ð ð 0Ð /Ð /Ð /Ð /Ð /àð Ø!Ð!Ð!Ð!Ð!Ð!Ø+Ð+Ð+Ð+Ð+Ð+ðð ð ð ð ð ð ð ð ð ð €
à% t¨C°¨H¤~°s¸CÐ&@À$Ð&FÔGÐ ðz1ð z1ð z1ð z1ð z1˜jÐ*@ñ z1ô z1ð z1ðzT1ð T1ð T1ð T1ð T1˜Oñ T1ô T1ð T1ð T1ð T1r;   