509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
¹'¾YÛ'  ã               @   sT  d Z dddgZddlZddlmZmZ y0ddlmZmZm	Z	m
Z
mZmZmZ eefZW n8 ek
rŽ   ddlmZmZm	Z	m
Z
mZmZ eZY nX dd	d„Zdd
d„Zddd„Zdd„ ZejdejƒjZG dd„ dƒZdd„ Zdd„ ZyddlmZ W n" ek
�r   ddlmZ Y nX ejdƒjZye  W n e!k
�rF   e"Z Y nX dd„ Z#dS )z5External interface to the BeautifulSoup HTML parser.
Ú
fromstringÚparseÚconvert_treeé    N)ÚetreeÚhtml)ÚBeautifulSoupÚTagÚCommentÚProcessingInstructionÚNavigableStringÚDeclarationÚDoctype)r   r   r	   r
   r   r   c             K   s   t | ||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   ú"/usr/lib64/python3.6/soupparser.pyr      s    c             K   s,   t | dƒst| ƒ} t| ||f|Ž}tj|ƒS )aY  Parse 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Úopenr   r   ZElementTree)Úfiler   r   r   Úrootr   r   r   r   $   s    	
c             C   s.   t | |ƒ}|jƒ }x|D ]}|j|ƒ qW |S )a  Convert 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_treeZgetchildrenÚremove)Úbeautiful_soup_treer   r   ZchildrenÚchildr   r   r   r   3   s
    	

c             K   s‚   |d krt }t|dƒr&d|kr&d|d< t|dƒr@d|kr@d|d< || f|Ž}t||ƒ}t|ƒdkrx|d jdkrx|d S d|_|S )	NZHTML_ENTITIESZconvertEntitiesr   ZDEFAULT_BUILDER_FEATURESZfeatureszhtml.parseré   r   )r   r   r   ÚlenÚtag)Úsourcer   r   r   Ztreer   r   r   r   r   E   s    


r   z`(?:\s|[<!])*DOCTYPE\s*HTML(?:\s+PUBLIC)?(?:\s+(\'[^\']*\'|"[^"]*"))?(?:\s+(\'[^\']*\'|"[^"]*"))?c               @   s   e Zd Zdd„ Zdd„ ZdS )Ú
_PseudoTagc             C   s   d| _ g | _|| _d S )Nr   )ÚnameÚattrsÚcontents)Úselfr%   r   r   r   Ú__init__`   s    z_PseudoTag.__init__c             C   s
   | j jƒ S )N)r%   Ú__iter__)r&   r   r   r   r(   e   s    z_PseudoTag.__iter__N)Ú__name__Ú
__module__Ú__qualname__r'   r(   r   r   r   r   r"   ^   s   r"   c             C   s  |d krt jj}d  }}d  }}xft| ƒD ]Z\}}t|tƒrn|d krH|}|}|d kr„|jr„|jjƒ dkr„|}q*|d kr*t|tƒr*|}q*W |d kr g  }}	| j	}
n2| j	d |… }| j	||d … }
| j	|d d … }	|d k	�r|
j
|ƒ}|
d |… |j	 |
|d d …  |_	nt|
ƒ}t|ƒ}||ƒ}|}x2t|ƒD ]&}||ƒ}|d k	�r2|j|ƒ |}�q2W |}x.|	D ]&}||ƒ}|d k	�rf|j|ƒ |}�qfW |d k	�ry|jƒ }W n tk
�rÂ   |j}Y nX t|ƒ}|�sÔn>|jƒ \}}|jƒ j}|�oú|dd… |_|�o|dd… |_|S )Nr   r   éÿÿÿÿr,   )r   Zhtml_parserr   Ú	enumerateÚ
isinstancer   r#   ÚlowerÚ_DECLARATION_OR_DOCTYPEr%   Úindexr"   Ú_init_node_convertersÚreversedZaddpreviousZaddnextZoutput_readyÚAttributeErrorÚstringÚ_parse_doctype_declarationÚgroupsZgetroottreeÚdocinfoZ	public_idZ
system_url)r   r   Zfirst_element_idxZlast_element_idxZ	html_rootZdeclarationÚiÚeZpre_rootZ	post_rootÚrootsÚconvert_nodeZres_rootÚprevZ	convertedZdoctype_stringÚmatchZexternal_idZsys_urir8   r   r   r   r   i   sd    


&








r   c                s˜   i ‰g ‰‡‡fdd„}‡‡fdd„‰d‡‡fdd„	‰dd„ ‰d	d
„ ‰ |t tƒ‡‡‡‡fdd„ƒ}|tƒdd„ ƒ}|tƒdd„ ƒ}|tƒ‡ fdd„ƒ}ˆS )Nc                 s   ‡‡‡ fdd„}|S )Nc                s$   xˆD ]}| ˆ |< ˆj |ƒ qW | S )N)Úappend)ÚhandlerÚt)Ú
convertersÚordered_node_typesÚtypesr   r   ÚaddÃ   s    
z5_init_node_converters.<locals>.converter.<locals>.addr   )rD   rE   )rB   rC   )rD   r   Ú	converterÂ   s    z(_init_node_converters.<locals>.converterc                s$   xˆD ]}t | |ƒrˆ | S qW d S )N)r.   )ZnoderA   )rB   rC   r   r   Úfind_best_converterÊ   s    

z2_init_node_converters.<locals>.find_best_converterc                sP   yˆ t | ƒ }W n( tk
r8   ˆ| ƒ }ˆ t | ƒ< Y nX |d krFd S || |ƒS )N)ÚtypeÚKeyError)Úbs_nodeÚparentr@   )rB   rG   r   r   r<   Ð   s    z+_init_node_converters.<locals>.convert_nodec             S   s\   t | tƒrFi }xH| jƒ D ](\}}t |tƒr4dj|ƒ}t|ƒ||< qW ntdd„ | D ƒƒ}|S )Nú c             s   s   | ]\}}|t |ƒfV  qd S )N)Úunescape)Ú.0ÚkÚvr   r   r   ú	<genexpr>â   s    z;_init_node_converters.<locals>.map_attrs.<locals>.<genexpr>)r.   ÚdictÚitemsÚlistÚjoinrM   )Zbs_attrsÚattribsrO   rP   r   r   r   Ú	map_attrsÚ   s    


z(_init_node_converters.<locals>.map_attrsc             S   s:   t | ƒdkr| jpd| | _n| d jp*d| | d _d S )Nr   Ú r   r,   r,   )r   ÚtextÚtail)rK   rY   r   r   r   Úappend_textå   s    z*_init_node_converters.<locals>.append_textc                s¦   | j }|d k	r2|rˆ|ƒnd }tj|| j|d�}n|r>ˆ|ƒni }ˆ| j|d�}xP| D ]H}yˆt|ƒ }W n tk
r~   Y nX |d k	rV|||ƒ qVˆ ||ƒ qVW |S )N)Zattrib)r$   r   Z
SubElementr#   rH   rI   )rJ   rK   r$   rV   Úresr   r@   )r<   rB   r   rW   r   r   Úconvert_tagí   s     

z*_init_node_converters.<locals>.convert_tagc             S   s    t j| ƒ}|d k	r|j|ƒ |S )N)r   ZHtmlCommentr?   )rJ   rK   r\   r   r   r   Úconvert_comment  s    

z._init_node_converters.<locals>.convert_commentc             S   s>   | j dƒr| d d… } tj| jddƒŽ }|d k	r:|j|ƒ |S )Nú?r   rL   r,   )Úendswithr   r
   Úsplitr?   )rJ   rK   r\   r   r   r   Ú
convert_pi  s    

z)_init_node_converters.<locals>.convert_pic                s   |d k	rˆ |t | ƒƒ d S )N)rM   )rJ   rK   )r[   r   r   Úconvert_text  s    z+_init_node_converters.<locals>.convert_text)N)r   r"   r	   r
   r   )r   rF   r]   r^   rb   rc   r   )r[   r<   rB   rG   r   rW   rC   r   r2   ¾   s    
r2   )Úname2codepointz&(\w+);c             C   s   | sdS dd„ }t || ƒS )NrX   c             S   s2   yt t| jdƒ ƒS  tk
r,   | jdƒS X d S )Nr   r   )Úunichrrd   ÚgrouprI   )Úmr   r   r   Úunescape_entity5  s    z!unescape.<locals>.unescape_entity)Úhandle_entities)r5   rh   r   r   r   rM   1  s    rM   )NN)NN)N)$Ú__doc__Ú__all__ÚreZlxmlr   r   Zbs4r   r   r	   r
   r   r   r   r0   ÚImportErrorr   r   r   r   ÚcompileÚ
IGNORECASEr>   r6   r"   r   r2   Zhtml.entitiesrd   ZhtmlentitydefsÚsubri   re   Ú	NameErrorÚchrrM   r   r   r   r   Ú<module>   s:   
$ 




Uc
