403Webshell
Server IP : 192.158.238.246  /  Your IP : 18.117.232.234
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python37/lib/python3.7/site-packages/bs4/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python37/lib/python3.7/site-packages/bs4/__pycache__/element.cpython-37.opt-1.pyc
B

�.�`�@srdZddlZddlZddlZddlZddlZddlmZdZej	ddkZ
e�d�Zdd�Z
Gd	d
�d
e�ZGdd�de�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�dee�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd �d e�ZGd!d"�d"e�ZGd#d$�d$e�ZGd%d&�d&e�ZGd'd(�d(e�ZGd)d*�d*e �Z!dS)+ZMIT�N)�EntitySubstitutionzutf-8�z\s+cs&t�fdd��}|j�fdd��}|S)z>Alias one attribute name to another for backward compatibilitycs
t|��S)N)�getattr)�self)�attr��</opt/alt/python37/lib/python3.7/site-packages/bs4/element.py�aliassz_alias.<locals>.aliascs
t|��S)N)�setattr)r)rrrr	s)�property�setter)rr	r)rr�_aliassr
c@seZdZddd�ZdS)�NamespacedAttributeNcCsV|dkrt�||�}n*|dkr,t�||�}nt�||d|�}||_||_||_|S)N�:)�str�__new__�prefix�name�	namespace)�clsrrr�objrrrrszNamespacedAttribute.__new__)N)�__name__�
__module__�__qualname__rrrrrrsrc@seZdZdZdS)�%AttributeValueWithCharsetSubstitutionz=A stand-in object for a character encoding specified in HTML.N)rrr�__doc__rrrrr,src@s eZdZdZdd�Zdd�ZdS)�CharsetMetaAttributeValuez�A generic stand-in for the value of a meta tag's 'charset' attribute.

    When Beautiful Soup parses the markup '<meta charset="utf8">', the
    value of the 'charset' attribute will be one of these objects.
    cCst�||�}||_|S)N)rr�original_value)rrrrrrr6sz!CharsetMetaAttributeValue.__new__cCs|S)Nr)r�encodingrrr�encode;sz CharsetMetaAttributeValue.encodeN)rrrrrrrrrrr/src@s.eZdZdZe�dej�Zdd�Zdd�Z	dS)�ContentMetaAttributeValueaA generic stand-in for the value of a meta tag's 'content' attribute.

    When Beautiful Soup parses the markup:
     <meta http-equiv="content-type" content="text/html; charset=utf8">

    The value of the 'content' attribute will be one of these objects.
    z((^|;)\s*charset=)([^;]*)cCs6|j�|�}|dkr t�t|�St�||�}||_|S)N)�
CHARSET_RE�searchrrr)rr�matchrrrrrJsz!ContentMetaAttributeValue.__new__cs�fdd�}|j�||j�S)Ncs|�d��S)N�)�group)r#)rrr�rewriteUsz1ContentMetaAttributeValue.encode.<locals>.rewrite)r!�subr)rrr&r)rrrTsz ContentMetaAttributeValue.encodeN)
rrrr�re�compile�Mr!rrrrrrr ?s
r c@sVeZdZdZeddg�Zedg�Zeddg�Zedd��Z	edd	��Z
ed
d��ZdS)
�HTMLAwareEntitySubstitutiona%Entity substitution rules that are aware of some HTML quirks.

    Specifically, the contents of <script> and <style> tags should not
    undergo entity substitution.

    Incoming NavigableString objects are checked to see if they're the
    direct children of a <script> or <style> tag.
    �scriptZstyle�preZtextareacCs.t|t�r&|jdk	r&|jj|jkr&|S||�S)N)�
isinstance�NavigableString�parentr�cdata_containing_tags)r�ns�frrr�_substitute_if_appropriatejs


z6HTMLAwareEntitySubstitution._substitute_if_appropriatecCs|�|tj�S)N)r4r�substitute_html)rr2rrrr5tsz+HTMLAwareEntitySubstitution.substitute_htmlcCs|�|tj�S)N)r4r�substitute_xml)rr2rrrr6ysz*HTMLAwareEntitySubstitution.substitute_xmlN)rrrr�setr1Zpreformatted_tags�preserve_whitespace_tags�classmethodr4r5r6rrrrr+Ys	

r+c@s\eZdZdZejejdd�Zejejdd�Z	d[dd�Z
edd��Zd	d
�Z
d\dd�Zed
�Zed�Zdd�ZeZdd�ZeZeZdd�Zdd�Zd]dd�ZeZdd�Zdd�Zdd�Zd d!�Zdidfd"d#�ZeZ diddfd$d%�Z!e!Z"didfd&d'�Z#e#Z$diddfd(d)�Z%e%Z&e%Z'didfd*d+�Z(e(Z)diddfd,d-�Z*e*Z+e*Z,didfd.d/�Z-e-Z.diddfd0d1�Z/e/Z0e/Z1difd2d3�Z2e2Z3didfd4d5�Z4e4Z5e4Z6ed6d7��Z7ed8d9��Z8d:d;�Z9d<d=�Z:ed>d?��Z;ed@dA��Z<edBdC��Z=edDdE��Z>edFdG��Z?e@�AdH�ZBe@�AdI�ZCd^dJdK�ZDdLdM�ZEd_dOdP�ZFdQdR�ZGdSdT�ZHdUdV�ZIdWdX�ZJdYdZ�ZKdS)`�PageElementzeContains the navigational information for some part of the page
    (either a tag or a piece of text)N)Zhtml�minimalNr;cCs,t|�s|�|�}|dkr |}n||�}|S)z2Format the given string using the given formatter.N)�callable�_formatter_for_name)r�s�	formatter�outputrrr�
format_string�s
zPageElement.format_stringcCs.|jdk	r|jS|jdkr&t|dd�S|jjS)aJIs this element part of an XML tree or an HTML tree?

        This is used when mapping a formatter name ("minimal") to an
        appropriate function (one that performs entity-substitution on
        the contents of <script> and <style> tags, or not). It can be
        inefficient, but it should be called very rarely.
        N�is_xmlF)�	known_xmlr0r�_is_xml)rrrrrD�s
	

zPageElement._is_xmlcCs*|jr|j�|tj�S|j�|tj�SdS)z<Look up a formatter function based on its name and the tree.N)rD�XML_FORMATTERS�getrr6�HTML_FORMATTERSr+)rrrrrr=�s

zPageElement._formatter_for_namecCs|||_||_|dk	r||j_||_|jr0||j_||_|jrD||j_|sf|jdk	rf|jjrf|jjd}||_|rx||j_dS)zNSets up the initial relations between this element and
        other elements.N���)r0�previous_element�next_element�next_sibling�previous_sibling�contents)rr0rIrJrLrKrrr�setup�s zPageElement.setuprKrLcCsV|jstd��||krdS||jkr,td��|j}|j�|�}|��|�||�|S)Nz]Cannot replace one element with another when theelement to be replaced is not part of a tree.z%Cannot replace a Tag with its parent.)r0�
ValueError�index�extract�insert)r�replace_withZ
old_parent�my_indexrrrrS�s
zPageElement.replace_withcCsT|j}|jstd��|j�|�}|��x&t|jdd��D]}|�||�q<W|S)NzSCannot replace an element with its contents when thatelement is not part of a tree.)r0rOrPrQ�reversedrMrR)rZ	my_parentrT�childrrr�unwrap�szPageElement.unwrapcCs|�|�}|�|�|S)N)rS�append)rZwrap_inside�merrr�wraps

zPageElement.wrapcCs�|jdk	r|jj|j�|�=|��}|j}|jdk	rF|j|k	rF||j_|dk	r`||jk	r`|j|_d|_d|_d|_|jdk	r�|j|jk	r�|j|j_|jdk	r�|j|jk	r�|j|j_d|_|_|S)z0Destructively rips this element out of the tree.N)r0rMrP�_last_descendantrJrIrLrK)r�
last_childrJrrrrQs(






zPageElement.extractTcCsL|r|jr|jj}n$|}xt|t�r6|jr6|jd}qW|sH||krHd}|S)z8Finds the last element beneath this object to be parsed.rHN)rKrIr.�TagrM)rZis_initializedZaccept_selfr\rrrr[(s

zPageElement._last_descendantc	Cs�|dkrtd��||kr td��t|t�r<t|t�s<t|�}t|t|j��}t|d�r�|jdk	r�|j|kr�|�	|�}||kr�|d8}|�
�||_d}|dkr�d|_||_n(|j|d}||_||j_
|�d�|_|jdk	r�||j_|�d�}|t|j�k�r\d|_
|}d}x2|dk�r@|dk	�r@|j
}|j}|dk	�rP�qW|dk	�rT||_nd|_n*|j|}||_
|j
dk	�r�||j
_||_|jdk	�r�||j_|j�||�dS)NzCannot insert None into a tag.z Cannot insert a tag into itself.r0r$rF)rOr.rr/�min�lenrM�hasattrr0rPrQrLrIrKr[rJrR)	rZposition�	new_childZ
current_indexZprevious_childZnew_childs_last_elementr0Zparents_next_siblingZ
next_childrrrrR6s\








zPageElement.insertcCs|�t|j�|�dS)z2Appends the given tag to the contents of this tag.N)rRr_rM)r�tagrrrrXxszPageElement.appendcCsR||krtd��|j}|dkr&td��t|t�r8|��|�|�}|�||�dS)z�Makes the given element the immediate predecessor of this one.

        The two elements will have the same parent, and the given element
        will be immediately before this one.
        z&Can't insert an element before itself.Nz2Element has no parent, so 'before' has no meaning.)rOr0r.r:rQrPrR)rZpredecessorr0rPrrr�
insert_before|s

zPageElement.insert_beforecCsV||krtd��|j}|dkr&td��t|t�r8|��|�|�}|�|d|�dS)z�Makes the given element the immediate successor of this one.

        The two elements will have the same parent, and the given element
        will be immediately after this one.
        z%Can't insert an element after itself.Nz1Element has no parent, so 'after' has no meaning.r$)rOr0r.r:rQrPrR)rZ	successorr0rPrrr�insert_after�s

zPageElement.insert_aftercKs|j|j|||f|�S)zjReturns the first item that matches the given criteria and
        appears after this Tag in the document.)�	_find_one�
find_all_next)rr�attrs�text�kwargsrrr�	find_next�szPageElement.find_nextcKs|j|||||jf|�S)zbReturns all items that match the given criteria and appear
        after this Tag in the document.)�	_find_all�
next_elements)rrrgrh�limitrirrrrf�szPageElement.find_all_nextcKs|j|j|||f|�S)z{Returns the closest sibling to this Tag that matches the
        given criteria and appears after this Tag in the document.)re�find_next_siblings)rrrgrhrirrr�find_next_sibling�szPageElement.find_next_siblingcKs|j|||||jf|�S)zqReturns the siblings of this Tag that match the given
        criteria and appear after this Tag in the document.)rk�
next_siblings)rrrgrhrmrirrrrn�szPageElement.find_next_siblingscKs|j|j|||f|�S)zkReturns the first item that matches the given criteria and
        appears before this Tag in the document.)re�find_all_previous)rrrgrhrirrr�
find_previous�szPageElement.find_previouscKs|j|||||jf|�S)zcReturns all items that match the given criteria and appear
        before this Tag in the document.)rk�previous_elements)rrrgrhrmrirrrrq�szPageElement.find_all_previouscKs|j|j|||f|�S)z|Returns the closest sibling to this Tag that matches the
        given criteria and appears before this Tag in the document.)re�find_previous_siblings)rrrgrhrirrr�find_previous_sibling�sz!PageElement.find_previous_siblingcKs|j|||||jf|�S)zrReturns the siblings of this Tag that match the given
        criteria and appear before this Tag in the document.)rk�previous_siblings)rrrgrhrmrirrrrt�sz"PageElement.find_previous_siblingscKs&d}|j||df|�}|r"|d}|S)zOReturns the closest parent of this Tag that matches the given
        criteria.Nr$r)�find_parents)rrrgri�r�lrrr�find_parent�s
zPageElement.find_parentcKs|j||d||jf|�S)zFReturns the parents of this Tag that match the given
        criteria.N)rk�parents)rrrgrmrirrrrw�szPageElement.find_parentscCs|jS)N)rJ)rrrr�next�szPageElement.nextcCs|jS)N)rI)rrrr�previous�szPageElement.previouscKs&d}||||df|�}|r"|d}|S)Nr$rr)r�methodrrgrhrirxryrrrre�s
zPageElement._find_onecs|dkrd|kr|d}|d=t�t�r.�}nt�||f|�}|dkr�|s�|s�|s��dksb�dkrzdd�|D�}t||�St�t�r��fdd�|D�}t||�St|�}	xVyt|�}
Wntk
r�PYnX|
r�|�|
�}|r�|	�|�|r�t|	�|kr�Pq�W|	S)z8Iterates over a generator looking for things that match.N�stringTcss|]}t|t�r|VqdS)N)r.r])�.0�elementrrr�	<genexpr>sz(PageElement._find_all.<locals>.<genexpr>c3s&|]}t|t�r|j�kr|VqdS)N)r.r]r)r�r�)rrrr�s
)	r.�SoupStrainer�	ResultSetrr|�
StopIterationr"rXr_)rrrgrhrm�	generatorriZstrainer�resultZresults�i�foundr)rrrks4





zPageElement._find_allccs$|j}x|dk	r|V|j}qWdS)N)rJ)rr�rrrrl.s
zPageElement.next_elementsccs$|j}x|dk	r|V|j}qWdS)N)rK)rr�rrrrp5s
zPageElement.next_siblingsccs$|j}x|dk	r|V|j}qWdS)N)rI)rr�rrrrs<s
zPageElement.previous_elementsccs$|j}x|dk	r|V|j}qWdS)N)rL)rr�rrrrvCs
zPageElement.previous_siblingsccs$|j}x|dk	r|V|j}qWdS)N)r0)rr�rrrr{Js
zPageElement.parentsz^[a-zA-Z0-9][-.a-zA-Z0-9:_]*$zs^(?P<tag>[a-zA-Z0-9][-.a-zA-Z0-9:_]*)?\[(?P<attribute>[\w-]+)(?P<operator>[=~\|\^\$\*]?)=?"?(?P<value>[^\]"]*)"?\]$cCs.|�||�}t|t�s t|t�r*d�|�}|S)z�Force an attribute value into a string representation.

        A multi-valued attribute will be converted into a
        space-separated stirng.
        � )rFr.�list�tuple�join)r�value�defaultrrr�_attr_value_as_stringas
z!PageElement._attr_value_as_stringcs�s�S��fdd�}|SdS)Ncs|j�ko�|�S)N)r)rb)�function�tag_namerr�_matchpsz1PageElement._tag_name_matches_and.<locals>._matchr)rr�r�r�r)r�r�r�_tag_name_matches_andlsz!PageElement._tag_name_matches_and�cs�|dkr��fdd�S|dkr0��fdd�}|S|dkrF��fdd�S|d	kr\��fd
d�S|dkrr��fdd�S|d
kr���fdd�}|S�fdd�SdS)z�Create a function that performs a CSS selector operation.

        Takes an operator, attribute and optional value. Returns a
        function that will return True for elements that match that
        combination.
        �=cs|����kS)N)r�)�el)�	attributer�rr�<lambda>}�z0PageElement._attribute_checker.<locals>.<lambda>�~cs&|��g�}t|t�s|��}�|kS)N)rFr.r��split)r��attribute_value)r�r�rr�_includes_value�s
z7PageElement._attribute_checker.<locals>._includes_value�^cs|��d����S)Nr�)r��
startswith)r�)r�r�rrr��s�$cs|��d����S)Nr�)r��endswith)r�)r�r�rrr��s�*cs�|��d�kS)Nr�)r�)r�)r�r�rrr��r��|cs"|��d�}|�kp |��d�S)Nr��-)r�r�)r�r�)r�r�rr�_is_or_starts_with_dash�sz?PageElement._attribute_checker.<locals>._is_or_starts_with_dashcs
|���S)N)�has_attr)r�)r�rrr��r�Nr)r�operatorr�r�r�r�r)r�r�r�_attribute_checkertszPageElement._attribute_checkercCs|jS)N)rl)rrrr�
nextGenerator�szPageElement.nextGeneratorcCs|jS)N)rp)rrrr�nextSiblingGenerator�sz PageElement.nextSiblingGeneratorcCs|jS)N)rs)rrrr�previousGenerator�szPageElement.previousGeneratorcCs|jS)N)rv)rrrr�previousSiblingGenerator�sz$PageElement.previousSiblingGeneratorcCs|jS)N)r{)rrrr�parentGenerator�szPageElement.parentGenerator)r;)NNNNN)TT)N)r�)Lrrrrr+r5r6rGrrErArrDr=rNr
ZnextSiblingZpreviousSiblingrSZreplaceWithrWZreplace_with_childrenZreplaceWithChildrenrZrQr[Z_lastRecursiveChildrRrXrcrdrjZfindNextrfZfindAllNextroZfindNextSiblingrnZfindNextSiblingsZfetchNextSiblingsrrZfindPreviousrqZfindAllPreviousZ
fetchPreviousruZfindPreviousSiblingrtZfindPreviousSiblingsZfetchPreviousSiblingsrzZ
findParentrwZfindParentsZfetchParentsr|r}rerkrlrprsrvr{r(r)�tag_name_re�attribselect_rer�r�r�r�r�r�r�r�rrrrr:~s�

	

B
(	
	

+r:c@s\eZdZdZdZdZdd�Zdd�Zdd�Zd	d
�Z	ddd
�Z
edd��Zej
dd��ZdS)r/r�NcCs2t|t�rt�||�}nt�||t�}|��|S)a-Create a new NavigableString.

        When unpickling a NavigableString, this method is called with
        the string in DEFAULT_OUTPUT_ENCODING. That encoding needs to be
        passed in to the superclass's __new__ or the superclass won't know
        how to handle non-ASCII characters.
        )r.rr�DEFAULT_OUTPUT_ENCODINGrN)rr��urrrr�s

zNavigableString.__new__cCst|�|�S)z�A copy of a NavigableString has the same contents and class
        as the original, but it is not connected to the parse tree.
        )�type)rrrr�__copy__�szNavigableString.__copy__cCs
t|�fS)N)r)rrrr�__getnewargs__�szNavigableString.__getnewargs__cCs$|dkr|Std|jj|f��dS)z�text.string gives you text. This is for backwards
        compatibility for Navigable*String, but for CData* it lets you
        get the string without the CData wrapper.rz!'%s' object has no attribute '%s'N)�AttributeError�	__class__r)rrrrr�__getattr__�s
zNavigableString.__getattr__r;cCs|�||�}|j||jS)N)rA�PREFIX�SUFFIX)rr?r@rrr�output_ready�szNavigableString.output_readycCsdS)Nr)rrrrr�szNavigableString.namecCstd��dS)Nz)A NavigableString cannot be given a name.)r�)rrrrrr�s)r;)rrrr�r�rCrr�r�r�r�rrrrrrrr/�s
r/c@seZdZdZddd�ZdS)�PreformattedStringz�A NavigableString not subject to the normal formatting rules.

    The string will be passed into the formatter (to trigger side effects),
    but the return value will be ignored.
    r;cCs|�||�|j||jS)zUCData strings are passed into the formatter.
        But the return value is ignored.)rAr�r�)rr?rrrr��szPreformattedString.output_readyN)r;)rrrrr�rrrrr��sr�c@seZdZdZdZdS)�CDataz	<![CDATA[z]]>N)rrrr�r�rrrrr��sr�c@seZdZdZdZdZdS)�ProcessingInstructionzA SGML processing instruction.z<?�>N)rrrrr�r�rrrrr��sr�c@seZdZdZdZdZdS)�XMLProcessingInstructionzAn XML processing instruction.z<?z?>N)rrrrr�r�rrrrr�sr�c@seZdZdZdZdS)�Commentz<!--z-->N)rrrr�r�rrrrr�sr�c@seZdZdZdZdS)�Declarationz<?z?>N)rrrr�r�rrrrr�sr�c@s eZdZedd��ZdZdZdS)�DoctypecCsN|pd}|dk	r2|d|7}|dk	rF|d|7}n|dk	rF|d|7}t|�S)Nr�z PUBLIC "%s"z "%s"z SYSTEM "%s")r�)rrZpub_idZ	system_idr�rrr�for_name_and_idsszDoctype.for_name_and_idsz
<!DOCTYPE z>
N)rrrr9r�r�r�rrrrr�sr�c	@s>eZdZdZdfdd�Zed�Zdd�Zedd	��Z	e	Z
ed
d��Zejdd��Zd
e
effdd�Zee�Zedd��Zdd
e
effdd�ZeZee�Zdd�Zdgdd�Zdd�Zdhdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Z d-d.�Z!d/d0�Z"d1d2�Z#d3d4�Z$d5d6�Z%did8d9�Z&d:d;�Z'd<d=�Z(e)�rJe'Z(Z&e*dd>d?fd@dA�Z+dBdC�Z,de*d>fdDdE�Z-djdFdG�Z.de*d>fdHdI�Z/de*d>fdJdK�Z0e*d
dLfdMdN�Z1didOdfdPdQ�Z2e2Z3didOddfdRdS�Z4e4Z5e4Z6edTdU��Z7edVdW��Z8dXdYdZgZ9d
Z:e;�<d[�Z=d\d]�Z>dkd^d_�Z?d`da�Z@dbdc�ZAddde�ZBdS)lr]z=Represents a found HTML tag with its attributes and contents.Nc
Cs�|dkrd|_n|j|_|dkr(td��||_||_||_|dk	rJ|j}
n|	rTg}
ntj}
|
|_|dkrni}n4|r�|dk	r�|jr�|�	|j|�}q�t
|�}nt
|�}|r�|j|_n|	|_||_
g|_|�||�d|_|dk	r�|�|�|�|�|_nd|_dS)zBasic constructor.Nz%No value provided for new tag's name.F)�parser_classr�rOrrrr8r+Zcdata_list_attributesZ$_replace_cdata_list_attribute_values�dictrBrCrgrMrN�hiddenZset_up_substitutions�can_be_empty_element)r�parser�builderrrrrgr0r}rBr8rrr�__init__&sB


zTag.__init__r�c	Csht|�d|j|j|j|j|j|jd�}xdD]}t||t||��q,Wx|j	D]}|�
|���qNW|S)z�A copy of a Tag is a new Tag, unconnected to the parse tree.
        Its contents are a copy of the old Tag's contents.
        N)rB)r�r�)r�r�rrZnsprefixrgrDr
rrMrXr�)rZclonerrVrrrr�]s
zTag.__copy__cCst|j�dko|jS)a7Is this tag an empty-element tag? (aka a self-closing tag)

        A tag that has contents is never an empty-element tag.

        A tag that has no contents may or may not be an empty-element
        tag. It depends on the builder used to create the tag. If the
        builder has a designated list of empty-element tags, then only
        a tag whose name shows up in that list is considered an
        empty-element tag.

        If the builder has no designated list of empty-element tags,
        then any tag with no contents is an empty-element tag.
        r)r_rMr�)rrrr�is_empty_elementiszTag.is_empty_elementcCs0t|j�dkrdS|jd}t|t�r*|S|jS)aqConvenience property to get the single string within this tag.

        :Return: If this tag has a single string child, return value
         is that string. If this tag has no children, or more than one
         child, return value is None. If this tag has one child tag,
         return value is the 'string' attribute of the child tag,
         recursively.
        r$Nr)r_rMr.r/r)rrVrrrr{s


z
Tag.stringcCs|��|�|�|��dS)N)�clearrXr�)rrrrrr�sFccs\xV|jD]L}|dkrt|t�r|dk	r4t|�|kr4q|rN|��}t|�dkrNq|VqWdS)z�Yield all strings of certain classes, possibly stripping them.

        By default, yields only NavigableString and CData objects. So
        no comments, processing instructions, etc.
        Nr)�descendantsr.r/r��stripr_)rr��typesZ
descendantrrr�_all_strings�szTag._all_stringsccsx|�d�D]
}|VqWdS)NT)r�)rrrrr�stripped_strings�szTag.stripped_stringsr�cCs|�dd�|j||d�D��S)zP
        Get all child strings, concatenated using the given separator.
        cSsg|]}|�qSrr)r�r>rrr�
<listcomp>�sz Tag.get_text.<locals>.<listcomp>)r�)r�r�)rZ	separatorr�r�rrr�get_text�szTag.get_textcCs8|��|}x&|dk	r2|j}|j��g|_|}qWdS)z/Recursively destroys the contents of this tree.N)rQrJ�__dict__r�rM)rr�r|rrr�	decompose�s

z
Tag.decomposecCs^|r:xT|jdd�D] }t|t�r,|��q|��qWn x|jdd�D]}|��qJWdS)zP
        Extract all children. If decompose is True, decompose instead.
        N)rMr.r]r�rQ)rr�r�rrrr��s

z	Tag.clearcCs0x"t|j�D]\}}||kr|SqWtd��dS)z�
        Find the index of a child by identity, not value. Avoids issues with
        tag.contents.index(element) getting the index of equal elements.
        zTag.index: element not in tagN)�	enumeraterMrO)rr�r�rVrrrrP�sz	Tag.indexcCs|j�||�S)z�Returns the value of the 'key' attribute for the tag, or
        the value given for 'default' if it doesn't have that
        attribute.)rgrF)r�keyr�rrrrF�szTag.getcCs
||jkS)N)rg)rr�rrrr��szTag.has_attrcCst|���S)N)r�__hash__)rrrrr��szTag.__hash__cCs
|j|S)zqtag[key] returns the value of the 'key' attribute for the tag,
        and throws an exception if it's not there.)rg)rr�rrr�__getitem__�szTag.__getitem__cCs
t|j�S)z0Iterating over a tag iterates over its contents.)�iterrM)rrrr�__iter__�szTag.__iter__cCs
t|j�S)z:The length of a tag is the length of its list of contents.)r_rM)rrrr�__len__�szTag.__len__cCs
||jkS)N)rM)r�xrrr�__contains__�szTag.__contains__cCsdS)z-A tag is non-None even if it has no contents.Tr)rrrr�__bool__�szTag.__bool__cCs||j|<dS)zKSetting tag[key] sets the value of the 'key' attribute for the
        tag.N)rg)rr�r�rrr�__setitem__�szTag.__setitem__cCs|j�|d�dS)z;Deleting tag[key] deletes all 'key' attributes for the tag.N)rg�pop)rr�rrr�__delitem__�szTag.__delitem__cOs|j||�S)z�Calling a tag like a function is the same as calling its
        find_all() method. Eg. tag('a') returns a list of all the A tags
        found within this tag.)�find_all)r�argsrirrr�__call__�szTag.__call__cCspt|�dkr>|�d�r>|dd�}t�d||f�|�|�S|�d�sZ|dksZ|�|�Std|j|f��dS)N�r]���z..%sTag is deprecated, use .find("%s") instead.�__rMz!'%s' object has no attribute '%s')r_r��warnings�warn�findr�r�r�)rrbr�rrrr�s

zTag.__getattr__cCs�||krdSt|d�rRt|d�rRt|d�rR|j|jksR|j|jksRt|�t|�krVdSx(t|j�D]\}}||j|krbdSqbWdS)zReturns true iff this tag has the same name, the same attributes,
        and the same contents (recursively) as the given tag.TrrgrMF)r`rrgr_r�rM)r�otherr�Zmy_childrrr�__eq__s


z
Tag.__eq__cCs
||kS)zZReturns true iff this tag is not identical to the other tag,
        as defined in __eq__.r)rr�rrr�__ne__%sz
Tag.__ne__�unicode-escapecCstr|��S|�|�SdS)zRenders this tag as a string.N)�PY3K�decoder)rrrrr�__repr__*szTag.__repr__cCs|��S)N)r�)rrrr�__unicode__5szTag.__unicode__cCstr|��S|��SdS)N)r�r�r)rrrr�__str__8szTag.__str__r;�xmlcharrefreplacecCs|�|||�}|�||�S)N)r�r)rr�indent_levelr?�errorsr�rrrrAsz
Tag.encodecCs|dk	o|j|jkS)z"Should this tag be pretty-printed?N)rr8)rr�rrr�_should_pretty_printIszTag._should_pretty_printcCs*t|�s|�|�}g}|jr�x�t|j���D]�\}}|dkrB|}nrt|t�sVt|t�rbd�|�}n0t|t	�svt	|�}nt|t
�r�|dk	r�|�|�}|�||�}t	|�dt
�|�}|�|�q,Wd}	d}
d}|jr�|jd}|jr�d}	nd||jf}
|�|�}d}
d}|dk	�r d|d}|�r4|}
|d}nd}|�|||�}|j�rT|}n�g}d}|�rpdd�|�}|dk	�r�|�|�|�d	||j||	f�|�r�|�d
�|�|�|�r�|�r�|dd
k�r�|�d
�|�r�|
�r�|�|
�|�|
�|dk	�r|
�r|j�r|�d
�d�|�}|S)a�Returns a Unicode representation of this tag and its contents.

        :param eventual_encoding: The tag is destined to be
           encoded into this encoding. This method is _not_
           responsible for performing that encoding. This information
           is passed in so that it can be substituted in if the
           document contains a <META> tag that mentions the document's
           encoding.
        Nr�r�r�r�/z</%s%s>r$z
<%s%s%s%s>�
rH)r<r=rg�sorted�itemsr.r�r�r�rrrrArZquoted_attribute_valuerXrr�rr��decode_contentsr�rK)rr��eventual_encodingr?rgr��valZdecodedrh�closeZcloseTagr�pretty_printZspaceZindent_spaceZindent_contentsrMr>Zattribute_stringrrrr�Qst


















z
Tag.decodecCs*|dkr|jd|d�S|j|d|d�SdS)NT)r?)r�r)rrr?rrr�prettify�szTag.prettifycCs�t|�s|�|�}|dk	}g}x�|D]�}d}t|t�rB|�|�}nt|t�r`|�|�|||��|rz|rz|jdksz|�	�}|r$|r�|jdks�|�d|d�|�|�|r$|jdks$|�d�q$Wd�
|�S)avRenders the contents of this tag as a Unicode string.

        :param indent_level: Each line of the rendering will be
           indented this many spaces.

        :param eventual_encoding: The tag is destined to be
           encoded into this encoding. This method is _not_
           responsible for performing that encoding. This information
           is passed in so that it can be substituted in if the
           document contains a <META> tag that mentions the document's
           encoding.

        :param formatter: The output formatter responsible for converting
           entities to Unicode characters.
        Nr-r�r$r�r�)r<r=r.r/r�r]rXr�rr�r�)rr�r�r?rr>�crhrrrr��s(




zTag.decode_contentscCs|�|||�}|�|�S)acRenders the contents of this tag as a bytestring.

        :param indent_level: Each line of the rendering will be
           indented this many spaces.

        :param eventual_encoding: The bytestring will be in this encoding.

        :param formatter: The output formatter responsible for converting
           entities to Unicode characters.
        )r�r)rr�rr?rMrrr�encode_contents�szTag.encode_contentsrcCs|sd}|j||d�S)N)r�r)r)rrZprettyPrintZindentLevelrrr�renderContents�szTag.renderContentsTcKs*d}|j||||df|�}|r&|d}|S)zLReturn only the first child of this Tag matching the given
        criteria.Nr$r)r�)rrrg�	recursiverhrirxryrrrr��s
zTag.findcKs&|j}|s|j}|j|||||f|�S)a�Extracts a list of Tag objects that match the given
        criteria.  You can specify the name of the Tag and any
        attributes you want the Tag to have.

        The value of a key-value pair in the 'attrs' map can be a
        string, a list of strings, a regular expression object, or a
        callable that takes a string and returns whether or not the
        string matches for some custom definition of 'matches'. The
        same is true of the tag name.)r��childrenrk)rrrgrrhrmrir�rrrr�szTag.find_allcCs
t|j�S)N)r�rM)rrrrrszTag.childrenccs@t|j�sdS|��j}|jd}x||k	r:|V|j}q$WdS)Nr)r_rMr[rJ)rZstopNode�currentrrrr�s



zTag.descendantsr��+r�z
"[^"]*:[^"]*"cCs|j|dd�}|r|dSdS)z9Perform a CSS selection operation on the current element.r$)rmrN)�select)r�selectorr�rrr�
select_one,szTag.select_onec%s�d|kr�g}xn|�d�D]`}|��}|dkr8td|���j||d�}x|D]}||krL|�|�qLW|rt|�|krPqW|St�|�}�g}	|d�jkr�td|d���jr�t	d|��x�t
|�D�]�\}
}g}tg�}
||
d�jk�r�jr�t	d	�q̈j�rt	d
|�d�d�d}�j�
|�}|dk	�r^|��\�}}}��|||�}�n�d|k�r�|�dd�\���fd
d�}|}�nvd|k�r�|�dd�\�}t|�d����fdd�}|}�n:d|k�r��j�|��s�|�dd�\�}�dk�rtd��t�
d|�}g}|dk�r&|}d}n|��\}}|dk�r�yt|�}Wntd��YnX|dk�rptd��Gdd�dt�}||�j}ntd��nl|dk�r�n`|dk�r�dd��nL|dk�r�d d��n8|d!k�r�d"d#�}|�n �j�
|��r�|�ntd$|����r*||
d����fd%d&�}|}nV|dk�r|�j�rX��rHd'}n�}t	d(|��j�rr�fd)d*�} | }nd+d�}n|}d,}!�x|	D�]}"�j�r�t	d-|"jt|"j�f�x�||"�D]�}t|t��sАq���r�|j�k�r�q�|dk	�ry||�}#Wntk
�rPYnX|dk�s&|#�rn�j�rFt	d.|jt|j�f�t|�|
k�r�|�|�|
�t|��n �j�r�t	d/|jt|j�f��q�W�q�W|}	q�W|�r�t|	�|k�r�|	d|�}	�j�r�t	d0�x"|	D]}$t	d1|$j|$jf��q�W|	S)2z9Perform a CSS selection operation on the current element.�,r�z"Invalid group selection syntax: %s)rmrHz-Final combinator "%s" is missing an argument.zRunning CSS selector "%s"r$z0  Token was consumed by the previous combinator.z Considering token "%s"N�#cs|�dd��kS)N�id)rF)rb)�tag_idrr�
id_matchesmszTag.select.<locals>.id_matches�.cs��|�dg��S)N�class)�issubsetrF)�	candidate)�classesrr�
classes_matchusz!Tag.select.<locals>.classes_matchrz0A pseudo-class must be prefixed with a tag name.z([a-zA-Z\d-]+)\(([a-zA-Z\d]+)\)znth-of-typezMOnly numeric values are currently supported for the nth-of-type pseudo-class.z2nth-of-type pseudo-class value must be at least 1.c@seZdZdd�Zdd�ZdS)zTag.select.<locals>.CountercSsd|_||_dS)Nr)�count�destination)rrrrrr��sz$Tag.select.<locals>.Counter.__init__cSs&|jd7_|j|jkrdSdSdS)Nr$TF)rr)rrbrrr�nth_child_of_type�sz-Tag.select.<locals>.Counter.nth_child_of_typeN)rrrr�rrrrr�Counter�srz?Only the following pseudo-classes are implemented: nth-of-type.r�r�cSs|jS)N)r)rbrrrr��r�zTag.select.<locals>.<lambda>r�cSs|jS)N)rp)rbrrrr��r�r
css|�d�VdS)NT)ro)rbrrr�next_tag_sibling�sz$Tag.select.<locals>.next_tag_siblingz)Unsupported or invalid CSS selector: "%s"c3sl�jr$td�|j|jf�td�x4|����D]$}�jrPtd|j|jf�|Vq2W�jrhtd�dS)Nz-    Calling select("%s") recursively on %s %sz(----------------------------------------z,(Recursive select picked up candidate %s %s))�
_select_debug�printrrgr)rbr�)�
next_token�recursive_candidate_generatorrrr�recursive_select�s
z$Tag.select.<locals>.recursive_selectz[any]z-   Default candidate generator, tag name="%s"c3s6x0|jD]&}t|t�sq�r(|j�ks(q|VqWdS)N)r�r.r]r)rbrV)r�rr�default_candidate_generator�s
z/Tag.select.<locals>.default_candidate_generatorcSs|jS)N)r�)rbrrrr��r�rz(    Running candidate generator on %s %sz     SUCCESS %s %sz     FAILURE %s %szFinal verdict:z %s %s) r�r�rOrrXr_�shlex�_selector_combinatorsrrr�r7r�r#�groupsr��quoted_colonr"r(�int�NotImplementedError�objectrr�r�reprrgr.r]r�r�add)%rrZ_candidate_generatorrm�contextZpartial_selectorZ
candidatesr�tokensZcurrent_contextrP�tokenZnew_contextZnew_context_idsZchecker�mr�r�r�r�klassrZpseudoZpseudo_attributesr�Zpseudo_typeZpseudo_valuerrr"Z_use_candidate_generator�checkr#rrbr�r�r)rr r!rrr�rr3s





















$
z
Tag.selectcCs|jS)N)r)rrrr�childGeneratorszTag.childGeneratorcCs|jS)N)r�)rrrr�recursiveChildGeneratorszTag.recursiveChildGeneratorcCst�d|�|�|�S)z�This was kind of misleading because has_key() (attributes)
        was different from __in__ (contents). has_key() is gone in
        Python 3, anyway.z2has_key is deprecated. Use has_attr("%s") instead.)r�r�r�)rr�rrr�has_keyszTag.has_key)	NNNNNNNNN)F)N)r�)Nr;)NN)Crrrrr�r
ZparserClassr�rr�Z
isSelfClosingrrr/r�r�Zstringsr�r�ZgetTextrhr�r�rPrFr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�rr�rrr�Z	findChildr�ZfindAllZfindChildrenrr�r%rr(r)r'r
rr3r4r5rrrrr]"s�
3




[
)	


^r]c@sReZdZdZdidfdd�Zdd�Zdd�Zdifd	d
�ZeZdd�Z	d
d�Z
dS)r�zMEncapsulates a number of ways of matching a markup element (tag or
    text).NcKs�|�|�|_t|t�s"||d<d}d|kr<|d|d<|d=|r\|rX|��}|�|�n|}i}x&t|���D]\}}|�|�||<qnW||_|�|�|_	dS)NrZclass_)
�_normalize_search_valuerr.r��copy�updater�r�rgrh)rrrgrhriZnormalized_attrsr�r�rrrr�#s"
zSoupStrainer.__init__cCs�t|t�s.t|�s.t|d�s.t|t�s.|dkr2|St|t�rF|�d�St|d�r�g}xF|D]>}t|d�r�t|t�s�t|t�s�|�|�qZ|�|�|��qZW|Stt|��S)Nr#�utf8r�)	r.rr<r`�bool�bytesr�rXr6)rr�Z	new_value�vrrrr6>s




z$SoupStrainer._normalize_search_valuecCs |jr|jSd|j|jfSdS)Nz%s|%s)rhrrg)rrrrr�\szSoupStrainer.__str__c
Cs d}d}t|t�r|}|}t|jtj�o2t|t�}|jrb|sb|rP|�||j�sb|s�|�||j�r�|rt|�||�}nrd}d}xht|j���D]V\}}	|s�t	|d�r�|}ni}x|D]\}
}|||
<q�W|�
|�}|�||	�s�d}Pq�W|r�|r�|}n|}|�r|j�r|�|j|j��sd}|S)NTrFF)
r.r]r�collections�Callable�_matchesr�rgr�r`rFrhr)
rZmarkup_nameZmarkup_attrsr��markupZcall_function_with_tag_datar#Zmarkup_attr_mapr�
match_against�kr<Z
attr_valuerrr�
search_tagbsB


 zSoupStrainer.search_tagcCs�d}t|d�rFt|ttf�sFx�|D]}t|t�r"|�|�r"|}Pq"Wnjt|t�rn|jrb|jsb|jr�|�	|�}nBt|t�s�t|t�r�|js�|js�|�
||j�r�|}ntd|j��|S)Nr�z&I don't know how to match against a %s)
r`r.r]rr/r"rhrrgrCr?�	Exceptionr�)rr@r�r�rrrr"�s"





zSoupStrainer.searchcCs�d}t|t�st|t�rPx|D]}|�||�rdSqW|�d�|�|�rLdSdS|dkr`|dk	St|tj�rt||�St|t�r�|j}|�	|�}|dkr�|St|t
�r�||kSt|d�r�|�|�St|d�r�||kSdS)NFTr�r#r�)
r.r�r�r?r�r=r>r]rr6rr`r")rr@rAr��itemrrrr?�s.






zSoupStrainer._matches)rrrrr�r6r�rCZ	searchTagr"r?rrrrr�s'r�cs"eZdZdZd�fdd�	Z�ZS)r�zTA ResultSet is just a list that keeps track of the SoupStrainer
    that created it.rcstt|��|�||_dS)N)�superr�r��source)rrGr�)r�rrr��szResultSet.__init__)r)rrrrr��
__classcell__rr)r�rr��sr�)"Z__license__r=r(r$�sysr�Z
bs4.dammitrr��version_infor�r)Z
whitespace_rer
rrrrr r+r*r:r/r�r�r�r�r�r�r�r]r�r�r�rrrr�<module>sL
%59
8

Youez - 2016 - github.com/yon3zu
LinuXploit