HEX
Server: LiteSpeed
System: Linux s787.bom1.mysecurecloudhost.com 4.18.0-477.13.1.lve.el8.x86_64 #1 SMP Thu Jun 1 16:40:47 EDT 2023 x86_64
User: mobilech (5348)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //usr/local/lib64/python3.6/site-packages/lxml/html/__pycache__/soupparser.cpython-36.pyc
3

��?e�'�@sTdZdddgZddlZddlmZmZy0ddlmZmZm	Z	m
Z
mZmZm
Z
ee
fZWn8ek
r�ddlmZmZm	Z	m
Z
mZmZeZYnXdd	d�Zdd
d�Zddd�Zdd
�Zejdej�jZGdd�d�Zdd�Zdd�ZyddlmZWn"ek
�rddlmZYnXejd�jZye Wne!k
�rFe"Z YnXdd�Z#dS)z5External interface to the BeautifulSoup HTML parser.
�
fromstring�parse�convert_tree�N)�etree�html)�
BeautifulSoup�Tag�Comment�ProcessingInstruction�NavigableString�Declaration�Doctype)rrr	r
rrcKst|||f|�S)a�Parse a string of HTML data into an Element tree using the
    BeautifulSoup parser.

    Returns the root ``<html>`` Element of the tree.

    You can pass a different BeautifulSoup parser through the
    `beautifulsoup` keyword, and a diffent Element factory function
    through the `makeelement` keyword.  By default, the standard
    ``BeautifulSoup`` class and the default factory of `lxml.html` are
    used.
    )�_parse)�data�
beautifulsoup�makeelement�bsargs�r�4/tmp/pip-build-_veujq9v/lxml/lxml/html/soupparser.pyrscKs,t|d�st|�}t|||f|�}tj|�S)aYParse a file into an ElemenTree using the BeautifulSoup parser.

    You can pass a different BeautifulSoup parser through the
    `beautifulsoup` keyword, and a diffent Element factory function
    through the `makeelement` keyword.  By default, the standard
    ``BeautifulSoup`` class and the default factory of `lxml.html` are
    used.
    �read)�hasattr�openrr�ElementTree)�filerrr�rootrrrr$s	
cCs.t||�}|j�}x|D]}|j|�qW|S)aConvert a BeautifulSoup tree to a list of Element trees.

    Returns a list instead of a single root Element to support
    HTML-like soup with more than one root element.

    You can pass a different Element factory through the `makeelement`
    keyword.
    )�
_convert_tree�getchildren�remove)�beautiful_soup_treerr�children�childrrrr3s
	

cKs�|dkrt}t|d�r&d|kr&d|d<t|d�r@d|kr@d|d<||f|�}t||�}t|�dkrx|djdkrx|dSd|_|S)	NZ
HTML_ENTITIESZconvertEntitiesrZDEFAULT_BUILDER_FEATURES�featureszhtml.parser�r)rrr�len�tag)�sourcerrr�treerrrrrEs


rz`(?:\s|[<!])*DOCTYPE\s*HTML(?:\s+PUBLIC)?(?:\s+(\'[^\']*\'|"[^"]*"))?(?:\s+(\'[^\']*\'|"[^"]*"))?c@seZdZdd�Zdd�ZdS)�
_PseudoTagcCsd|_g|_||_dS)Nr)�name�attrs�contents)�selfr*rrr�__init__`sz_PseudoTag.__init__cCs
|jj�S)N)r*�__iter__)r+rrrr-esz_PseudoTag.__iter__N)�__name__�
__module__�__qualname__r,r-rrrrr'^sr'cCs|dkrtjj}d}}d}}xft|�D]Z\}}t|t�rn|dkrH|}|}|dkr�|jr�|jj�dkr�|}q*|dkr*t|t�r*|}q*W|dkr�g}}	|j	}
n2|j	d|�}|j	||d�}
|j	|dd�}	|dk	�r|
j
|�}|
d|�|j	|
|dd�|_	nt|
�}t|�}||�}|}
x2t
|�D]&}||�}|dk	�r2|
j|�|}
�q2W|}
x.|	D]&}||�}|dk	�rf|
j|�|}
�qfW|dk	�ry|j�}Wntk
�r�|j}YnXt|�}|�s�n>|j�\}}|j�j}|�o�|dd�|_|�o|dd�|_|S)Nrr"���r1)r�html_parserr�	enumerate�
isinstancerr(�lower�_DECLARATION_OR_DOCTYPEr*�indexr'�_init_node_converters�reversedZaddpreviousZaddnextZoutput_ready�AttributeError�string�_parse_doctype_declaration�groupsZgetroottree�docinfo�	public_idZ
system_url)rrZfirst_element_idxZlast_element_idxZ	html_rootZdeclaration�i�eZpre_rootZ	post_root�roots�convert_nodeZres_root�prevZ	convertedZdoctype_string�matchZexternal_idZsys_urir>rrrrisd


&








rcs�i�g���fdd�}��fdd��d��fdd�	�dd��d	d
��|tt�����fdd��}|t�d
d��}|t�dd��}|t��fdd��}�S)Ncs���fdd�}|S)Ncs$x�D]}|�|<�j|�qW|S)N)�append)�handler�t)�
converters�ordered_node_types�typesrr�add�s
z5_init_node_converters.<locals>.converter.<locals>.addr)rKrL)rIrJ)rKr�	converter�sz(_init_node_converters.<locals>.convertercs$x�D]}t||�r�|SqWdS)N)r4)�noderH)rIrJrr�find_best_converter�s

z2_init_node_converters.<locals>.find_best_convertercsPy�t|�}Wn(tk
r8�|�}�t|�<YnX|dkrFdS|||�S)N)�type�KeyError)�bs_node�parentrG)rIrOrrrC�sz+_init_node_converters.<locals>.convert_nodecSs\t|t�rFi}xH|j�D](\}}t|t�r4dj|�}t|�||<qWntdd�|D��}|S)N� css|]\}}|t|�fVqdS)N)�unescape)�.0�k�vrrr�	<genexpr>�sz;_init_node_converters.<locals>.map_attrs.<locals>.<genexpr>)r4�dict�items�list�joinrU)Zbs_attrs�attribsrWrXrrr�	map_attrs�s


z(_init_node_converters.<locals>.map_attrscSs:t|�dkr|jpd||_n|djp*d||d_dS)Nr�r"r1r1)r#�text�tail)rSrarrr�append_text�sz*_init_node_converters.<locals>.append_textcs�|j}|dk	r2|r�|�nd}tj||j|d�}n|r>�|�ni}�|j|d�}xP|D]H}y�t|�}Wntk
r~YnX|dk	rV|||�qV�||�qVW|S)N)�attrib)r)r�
SubElementr(rPrQ)rRrSr)r^�resr rG)rCrIrr_rr�convert_tag�s 

z*_init_node_converters.<locals>.convert_tagcSs tj|�}|dk	r|j|�|S)N)rZHtmlCommentrF)rRrSrfrrr�convert_comments

z._init_node_converters.<locals>.convert_commentcSs>|jd�r|dd�}tj|jdd��}|dk	r:|j|�|S)N�?r"rTr1)�endswithrr
�splitrF)rRrSrfrrr�
convert_pis

z)_init_node_converters.<locals>.convert_pics|dk	r�|t|��dS)N)rU)rRrS)rcrr�convert_textsz+_init_node_converters.<locals>.convert_text)N)rr'r	r
r)rrMrgrhrlrmr)rcrCrIrOrr_rJrr8�s
r8)�name2codepointz&(\w+);cCs|sdSdd�}t||�S)Nr`cSs2ytt|jd��Stk
r,|jd�SXdS)Nr"r)�unichrrn�grouprQ)�mrrr�unescape_entity5sz!unescape.<locals>.unescape_entity)�handle_entities)r;rrrrrrU1srU)NN)NN)N)$�__doc__�__all__�re�lxmlrrZbs4rrr	r
rrr
r6�ImportErrorrrrr�compile�
IGNORECASErEr<r'rr8�
html.entitiesrn�htmlentitydefs�subrsro�	NameError�chrrUrrrr�<module>s:
$ 




Uc