HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: sport3497 (1034)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib64/python3.10/site-packages/bs4/builder/__pycache__/_lxml.cpython-310.pyc
o

�hd:�
@s�dZddgZzddlmZWney&ZzddlmZWYdZ[ndZ[wwddlmZddlm	Z	ddl
mZdd	lm
Z
mZmZmZmZdd
lmZmZmZmZmZmZmZmZddlmZdZd
d�ZGdd�de�ZGdd�dee�Z dS)�MIT�LXMLTreeBuilderForXML�LXMLTreeBuilder�)�CallableN)�BytesIO)�StringIO)�etree)�Comment�Doctype�NamespacedAttribute�ProcessingInstruction�XMLProcessingInstruction)�DetectsXMLParsedAsHTML�FAST�HTML�HTMLTreeBuilder�
PERMISSIVE�ParserRejectedMarkup�TreeBuilder�XML)�EncodingDetector�lxmlcCstdd�t|���D��S)zInvert a dictionary.css�|]	\}}||fVqdS�N�)�.0�k�vrr�D/usr/local/CyberCP/lib/python3.10/site-packages/bs4/builder/_lxml.py�	<genexpr>'s�z_invert.<locals>.<genexpr>)�dict�list�items)�drrr�_invert%sr#cs�eZdZejZdZeZdZ	dgZ
e	eee
egZdZedd�Zee�Z�fdd�Zd	d
�Zdd�Zd
d�Zd*�fdd�	Zdd�Z			d+dd�Zdd�Zdd�Zifdd�Zdd�Zdd�Z d d!�Z!d"d#�Z"d$d%�Z#d&d'�Z$d(d)�Z%�Z&S),rTzlxml-xml�xmliz$http://www.w3.org/XML/1998/namespace)r$cs tt|��|�|�|j�dS)z�Let the BeautifulSoup object know about the standard namespace
        mapping.

        :param soup: A `BeautifulSoup`.
        N)�superr�initialize_soup�_register_namespaces�DEFAULT_NSMAPS)�self�soup��	__class__rrr&Dsz%LXMLTreeBuilderForXML.initialize_soupcCs6t|���D]\}}|r||jjvr||jj|<qdS)a�Let the BeautifulSoup object know about namespaces encountered
        while parsing the document.

        This might be useful later on when creating CSS selectors.

        This will track (almost) all namespaces, even ones that were
        only in scope for part of the document. If two namespaces have
        the same prefix, only the first one encountered will be
        tracked. Un-prefixed namespaces are not tracked.

        :param mapping: A dictionary mapping namespace prefixes to URIs.
        N)r r!r*�_namespaces)r)�mapping�key�valuerrrr'Ms

��z*LXMLTreeBuilderForXML._register_namespacescCs"|jdur|jStj|dd|d�S)z�Find the default parser for the given encoding.

        :param encoding: A string.
        :return: Either a parser object or a class, which
          will be instantiated with default arguments.
        NFT��target�strip_cdata�recover�encoding)�_default_parserr�	XMLParser�r)r5rrr�default_parseres

�z$LXMLTreeBuilderForXML.default_parsercCs(|�|�}t|t�r||dd|d�}|S)z�Instantiate an appropriate parser for the given encoding.

        :param encoding: A string.
        :return: A parser object such as an `etree.XMLParser`.
        FTr1)r9�
isinstancer)r)r5�parserrrr�
parser_forqs

�z LXMLTreeBuilderForXML.parser_forNcsP||_|durt|�|_d|_|jg|_t|j�g|_t	t
|�jdi|��dS)Nr)r6�set�empty_element_tagsr*�DEFAULT_NSMAPS_INVERTED�nsmapsrr(�active_namespace_prefixesr%r�__init__)r)r;r>�kwargsr+rrrB�s

zLXMLTreeBuilderForXML.__init__cCs,|ddkrt|dd��dd��Sd|fS)Nr�{��})�tuple�split)r)�tagrrr�	_getNsTag�szLXMLTreeBuilderForXML._getNsTagc
cs��|j}|rt|_tj|dd�nt|_t|t�r3t|�dkr,|ddkr,|dd�}|d|dfVt|t�rB|�	d�d|dfV|g}|g}t
|||||d	�}|jD]
}	|j|	|dfVqTdS)
aARun any preliminary steps necessary to make incoming markup
        acceptable to the parser.

        lxml really wants to get a bytestring and convert it to
        Unicode itself. So instead of using UnicodeDammit to convert
        the bytestring to Unicode using different encodings, this
        implementation uses EncodingDetector to iterate over the
        encodings, and tell lxml to try to parse the document as each
        one in turn.

        :param markup: Some markup -- hopefully 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 converting the
         document to Unicode and parsing it. Each strategy will be tried 
         in turn.
        �)�
stacklevelrurENF�utf8)�known_definite_encodings�user_encodings�is_html�exclude_encodings)
�is_xmlr�processing_instruction_classr�warn_if_markup_looks_like_xmlr
r:�str�len�encoder�	encodings�markup)
r)rY�user_specified_encodingrQ�document_declared_encodingrPrNrO�detectorr5rrr�prepare_markup�s4��


��
�z$LXMLTreeBuilderForXML.prepare_markupc
Cs�t|t�r
t|�}n	t|t�rt|�}|�|j�}z4|�|jj	�|_
|j
�|�t|�dkrF|�|j�}t|�dkr@|j
�|�t|�dks.|j
�
�WdStttjfya}zt|��d}~ww)Nr)r:�bytesrrUr�read�
CHUNK_SIZEr<r*�original_encodingr;�feedrV�close�UnicodeDecodeError�LookupErrorr�ParserErrorr)r)rY�data�errrrb�s$


���zLXMLTreeBuilderForXML.feedcCs|jg|_dSr)r?r@)r)rrrrc�szLXMLTreeBuilderForXML.closecCsRt|�}d}t|�dkrt|j�dkr|j�d�nEt|�dkr_|�|�|j�t|��t|jd�}|�|�d|vr@|d=|j�|�|��}t	|�
��D]\}}td|d�}|||<qPi}	t	|�
��D]#\}
}|�|
�\}}
|dur{||	|
<qg|�
|�}t||
|�}
||	|
<qg|	}|�|�\}}|�
|�}|jj|||||jdd�dS)NrrE�����xmlnszhttp://www.w3.org/2000/xmlns/)�
namespaces)rrVr@�appendr'r#rA�update�copyr r!rrJ�_prefix_for_namespacer*�handle_starttag)r)�name�attrs�nsmap�nsprefix�current_mapping�prefix�	namespace�	attribute�	new_attrs�attrr0rrr�start�sB

�





�zLXMLTreeBuilderForXML.startcCs<|durdSt|j�D]}|dur||vr||SqdS)z9Find the currently active prefix for the given namespace.N)�reversedr@)r)rx�inverted_nsmaprrrrp4s�z+LXMLTreeBuilderForXML._prefix_for_namespacecCs�|j��|jjd}|�|�\}}d}|dur.t|j�D]}|dur-||vr-||}nq|j�||�t|j�dkrL|j��}|durN|j	��dSdSdS)NrirE)
r*�endData�tagStackrJr}r@�
handle_endtagrV�poprA)r)rr�
completed_tagrxrur~�out_of_scope_nsmaprrr�end=s"
�
�zLXMLTreeBuilderForXML.endcCs4|j��|d|}|j�|�|j�|j�dS)N� )r*r�handle_datarS)r)r2rgrrr�piSs
zLXMLTreeBuilderForXML.picCs|j�|�dSr)r*r��r)�contentrrrrgYszLXMLTreeBuilderForXML.datacCs(|j��t�|||�}|j�|�dSr)r*rr
�for_name_and_ids�object_was_parsed)r)rr�pubid�system�doctyperrrr�\s
zLXMLTreeBuilderForXML.doctypecCs&|j��|j�|�|j�t�dS)z#Handle comments as Comment objects.N)r*rr�r	r�rrr�commentas
zLXMLTreeBuilderForXML.commentcC�d|S)�See `TreeBuilder`.z)<?xml version="1.0" encoding="utf-8"?>
%sr�r)�fragmentrrr�test_fragment_to_documentg�z/LXMLTreeBuilderForXML.test_fragment_to_document)NN)NNN)'�__name__�
__module__�__qualname__rr7�DEFAULT_PARSER_CLASSrRr
rS�NAME�ALTERNATE_NAMES�LXMLrrr�featuresr`rr(r#r?r&r'r9r<rBrJr]rbrcr|rpr�r�rgr�r�r��
__classcell__rrr+rr)s<
		
�H?	c@sFeZdZeZdgZeeeeegZ	dZ
eZdd�Z
dd�Zdd�Zd	S)
rz	lxml-htmlFcCstjSr)r�
HTMLParserr8rrrr9uszLXMLTreeBuilder.default_parserc
CsZ|jj}z|�|�|_|j�|�|j��WdStttj	fy,}zt
|��d}~wwr)r*rar<r;rbrcrdrerrfr)r)rYr5rhrrrrbxs��zLXMLTreeBuilder.feedcCr�)r�z<html><body>%s</body></html>rr�rrrr��r�z)LXMLTreeBuilder.test_fragment_to_documentN)r�r�r�r�r�r�rrrr�rRrrSr9rbr�rrrrrls
)!�__license__�__all__�collections.abcr�ImportErrorrh�collections�iorrrr�bs4.elementr	r
rrr
�bs4.builderrrrrrrrr�
bs4.dammitrr�r#rrrrrr�<module>s,���(	E