Files
old-nlp/venv/lib/python3.7/site-packages/bs4/__pycache__/element.cpython-37.pyc

413 lines
41 KiB
Plaintext
Raw Normal View History

2019-10-20 13:16:49 +02:00
B
%<25>]7<><00>
@s<>dZyddlmZWn.ek
rBZzddlmZWddZ[XYnXddlZddlZddlZddlZy ddl Z Wn0ek
r<EFBFBD>ZzdZ e<08>
d<04>WddZ[XYnXddl m Z m Z mZdZejddkZe<06>d<08>Ze<06>d <09>Zd
d <0B>ZGd d <0A>d e<16>ZGdd<0F>de<16>ZGdd<11>de<18>ZGdd<13>de<18>ZGdd<15>de<1B>ZGdd<17>dee<1C>ZGdd<19>de<1D>ZGdd<1B>de<1E>ZGdd<1D>de<1E>Z Gdd<1F>de <20>Z!Gd d!<21>d!e<1E>Z"Gd"d#<23>d#e<1E>Z#Gd$d%<25>d%e<1E>Z$Gd&d'<27>d'e<1C>Z%Gd(d)<29>d)e<1B>Z&Gd*d+<2B>d+e'<27>Z(dS),<2C>MIT<49>)<01>CallableNzEThe soupsieve package is not installed. CSS selectors cannot be used.)<03> Formatter<65> HTMLFormatter<65> XMLFormatterzutf-8<>z\S+z\s+cs&t<00>fdd<02><08>}|j<01>fdd<02><08>}|S)z>Alias one attribute name to another for backward compatibilitycs
t|<00><00>S)N)<01>getattr)<01>self)<01>attr<74><00>7/tmp/pip-install-_x9nvcel/beautifulsoup4/bs4/element.py<70>alias%sz_alias.<locals>.aliascs
t|<00><00>S)N)<01>setattr)r )r
r r r )s)<02>property<74>setter)r
r r )r
r <00>_alias#src@seZdZddd<03>ZdS)<05>NamespacedAttributeNcCs^|sd}|dkrt<00>||<01>}n*|dkr4t<00>||<02>}nt<00>||d|<00>}||_||_||_|S)N<>:)<05>str<74>__new__<5F>prefix<69>name<6D> namespace)<05>clsrrr<00>objr r r r1szNamespacedAttribute.__new__)NN)<04>__name__<5F>
__module__<EFBFBD> __qualname__rr r r r r/src@seZdZdZdS)<03>%AttributeValueWithCharsetSubstitutionz=A stand-in object for a character encoding specified in HTML.N)rrr<00>__doc__r r r r rCsrc@s eZdZdZdd<03>Zdd<05>ZdS)<07>CharsetMetaAttributeValuez<65>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<00>||<01>}||_|S)N)rr<00>original_value)rr!rr r r rMs z!CharsetMetaAttributeValue.__new__cCs|S)Nr )r <00>encodingr r r <00>encodeRsz CharsetMetaAttributeValue.encodeN)rrrrrr#r r r r r Fsr c@s.eZdZdZe<04>dej<06>Zdd<04>Zdd<06>Z dS)<08>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<00>|<01>}|dkr t<02>t|<01>St<02>||<01>}||_|S)N)<05>
CHARSET_RE<EFBFBD>searchrrr!)rr!<00>matchrr r r ras    z!ContentMetaAttributeValue.__new__cs<00>fdd<02>}|j<00>||j<02>S)Ncs|<00>d<01><01>S)N<>)<01>group)r')r"r r <00>rewritelsz1ContentMetaAttributeValue.encode.<locals>.rewrite)r%<00>subr!)r r"r*r )r"r r#ks z ContentMetaAttributeValue.encodeN)
rrrr<00>re<72>compile<6C>Mr%rr#r r r r r$Vs
r$c@seZdZdZdRdd<04>Zdd<06>Zdd<08>Zed d
<EFBFBD><00>Ze d <0B>Z
e d <0C>Z d d<0E>Z e Z dd<10>ZeZeZdd<12>Zdd<14>ZdSdd<17>ZeZdd<19>Zdd<1B>Zdd<1D>Zdd<1F>Zd d!<21>Zdidfd"d#<23>ZeZdiddfd$d%<25>ZeZdidfd&d'<27>ZeZdiddfd(d)<29>Z e Z!e Z"didfd*d+<2B>Z#e#Z$diddfd,d-<2D>Z%e%Z&e%Z'didfd.d/<2F>Z(e(Z)diddfd0d1<64>Z*e*Z+e*Z,difd2d3<64>Z-e-Z.didfd4d5<64>Z/e/Z0e/Z1ed6d7<64><00>Z2ed8d9<64><00>Z3d:d;<3B>Z4d<d=<3D>Z5ed>d?<3F><00>Z6ed@dA<64><00>Z7edBdC<64><00>Z8edDdE<64><00>Z9edFdG<64><00>Z:dHdI<64>Z;dJdK<64>Z<dLdM<64>Z=dNdO<64>Z>dPdQ<64>Z?dS)T<> PageElementzeContains the navigational information for some part of the page
(either a tag or a piece of text)NcCs<>||_||_|dk r||j_||_|jdk r4||j_||_|jdk rL||j_|dkrr|jdk rr|jjrr|jjd}||_|dk r<>||j_dS)zNSets up the initial relations between this element and
other elements.N<><4E><EFBFBD><EFBFBD><EFBFBD>)<06>parent<6E>previous_element<6E> next_element<6E> next_sibling<6E>previous_sibling<6E>contents)r r1r2r3r5r4r r r <00>setupus 

 zPageElement.setupcCs.|dkr |St|t<01>s |<00>|<02>}|<02>|<01>}|S)z2Format the given string using the given formatter.N)<04>
isinstancer<00>formatter_for_name<6D>
substitute)r <00>s<> formatter<65>outputr r r <00> format_string<6E>s 


zPageElement.format_stringcCs>t|t<01>r|S|jrt}nt}t|tj<06>r4||d<01>S|j|S)adLook up or create a Formatter for the given identifier,
if necessary.
:param formatter: Can be a Formatter object (used as-is), a
function (used as the entity substitution hook for an
XMLFormatter or HTMLFormatter), or a string (used to look up
an XMLFormatter or HTMLFormatter in the appropriate registry.
)Zentity_substitution)r8r<00>_is_xmlrr<00> collectionsrZREGISTRY)r r<<00>cr r r r9<00>s
 
zPageElement.formatter_for_namecCs.|jdk r|jS|jdkr&t|dd<03>S|jjS)aIs this element part of an XML tree or an HTML tree?
This is used in formatter_for_name, when deciding whether an
XMLFormatter or HTMLFormatter is more appropriate. It can be
inefficient, but it should be called very rarely.
N<>is_xmlF)<04> known_xmlr1rr?)r r r r r?<00>s


 zPageElement._is_xmlr4r5cCsZ|jdkrtd<01><01>||krdS||jkr0td<02><01>|j}|j<00>|<00>}|<00><03>|<02>||<01>|S)Nz^Cannot replace one element with another when the element to be replaced is not part of a tree.z%Cannot replace a Tag with its parent.)r1<00>
ValueError<EFBFBD>index<65>extract<63>insert)r <00> replace_withZ
old_parent<EFBFBD>my_indexr r r rH<00>s

  zPageElement.replace_withcCsX|j}|jdkrtd<01><01>|j<00>|<00>}|<00><03>x&t|jdd<00><00>D]}|<01>||<03>q@W|S)NzSCannot replace an element with its contents when thatelement is not part of a tree.)r1rDrErF<00>reversedr6rG)r Z my_parentrI<00>childr r r <00>unwrap<61>s
 zPageElement.unwrapcCs|<00>|<01>}|<01>|<02>|S)N)rH<00>append)r Z wrap_inside<64>mer r r <00>wrap<61>s

zPageElement.wrapcCs<>|jdk r|jj|j<00>|<00>=|<00><03>}|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)r1r6rE<00>_last_descendantr3r2r5r4)r <00>
last_childr3r r r rF<00>s(



 

 
 zPageElement.extractTcCsP|r|jdk r|jj}n$|}xt|t<03>r:|jr:|jd}qW|sL||krLd}|S)z8Finds the last element beneath this object to be parsed.Nr0)r4r2r8<00>Tagr6)r Zis_initializedZ accept_selfrQr r r rPs
 zPageElement._last_descendantc Cs<>|dkrtd<01><01>||kr td<02><01>t|t<02>r<t|t<03>s<t|<02>}ddlm}t||<03>r~x&t|j<07>D]}|<00>||<04>|d7}q^WdSt |t
|j<07><01>}t |d<06>r<>|j dk r<>|j |kr<>|<00> |<02>}||kr<>|d8}|<02><0E>||_ d}|dkr<>d|_||_n(|j|d}||_||j_|<06>d<07>|_|jdk <09>r*||j_|<02>d<07>}|t
|j<07>k<05>r<>d|_|}d} x2| dk<08>r<>|dk <09>r<>|j} |j }| dk <09>rTP<00>qTW| dk <09>r<>| |_nd|_n*|j|}
|
|_|jdk <09>r<>||j_|
|_|jdk <09>r<>||j_|j<07>||<02>dS)NzCannot insert None into a tag.z Cannot insert a tag into itself.r)<01> BeautifulSoupr(r1F)rDr8r<00>NavigableStringZbs4rS<00>listr6rG<00>min<69>len<65>hasattrr1rErFr5r2r4rPr3) r <00>position<6F> new_childrSZsubchildZ current_indexZprevious_childZnew_childs_last_elementr1Zparents_next_siblingZ
next_childr r r rGsh

 
  

  



  zPageElement.insertcCs|<00>t|j<02>|<01>dS)z2Appends the given tag to the contents of this tag.N)rGrWr6)r <00>tagr r r rM]szPageElement.appendcCsx|D]}|<00>|<02>qWdS)z3Appends the given tags to the contents of this tag.N)rM)r <00>tagsr[r r r <00>extendas
zPageElement.extendcsn<00>j}|dkrtd<02><01>t<02>fdd<04>|D<00><01>r4td<05><01>x4|D],}t|t<04>rP|<03><05>|<02><06><00>}|<02>||<03>q:WdS)z<>Makes the given element(s) the immediate predecessor of this one.
The elements will have the same parent, and the given elements
will be immediately before this one.
Nz2Element has no parent, so 'before' has no meaning.c3s|]}|<01>kVqdS)Nr )<02>.0<EFBFBD>x)r r r <00> <genexpr>psz,PageElement.insert_before.<locals>.<genexpr>z&Can't insert an element before itself.)r1rD<00>anyr8r/rFrErG)r <00>argsr1Z predecessorrEr )r r <00> insert_beforefs


zPageElement.insert_beforecs<><00>j}|dkrtd<02><01>t<02>fdd<04>|D<00><01>r4td<05><01>d}xD|D]<}t|t<04>rT|<04><05>|<02><06><00>}|<02>|d||<04>|d7}q>WdS)z<>Makes the given element(s) the immediate successor of this one.
The elements will have the same parent, and the given elements
will be immediately after this one.
Nz1Element has no parent, so 'after' has no meaning.c3s|]}|<01>kVqdS)Nr )r^r_)r r r r`<00>sz+PageElement.insert_after.<locals>.<genexpr>z%Can't insert an element after itself.rr()r1rDrar8r/rFrErG)r rbr1<00>offset<65> successorrEr )r r <00> insert_afterzs


zPageElement.insert_aftercKs|j|j|||f|<04>S)zjReturns the first item that matches the given criteria and
appears after this Tag in the document.)<02> _find_one<6E> find_all_next)r r<00>attrs<72>text<78>kwargsr r r <00> find_next<78>szPageElement.find_nextcKs|j|||||jf|<05>S)zbReturns all items that match the given criteria and appear
after this Tag in the document.)<02> _find_all<6C> next_elements)r rrirj<00>limitrkr r r rh<00>szPageElement.find_all_nextcKs|j|j|||f|<04>S)z{Returns the closest sibling to this Tag that matches the
given criteria and appears after this Tag in the document.)rg<00>find_next_siblings)r rrirjrkr r r <00>find_next_sibling<6E>szPageElement.find_next_siblingcKs|j|||||jf|<05>S)zqReturns the siblings of this Tag that match the given
criteria and appear after this Tag in the document.)rm<00> next_siblings)r rrirjrorkr r r rp<00>s zPageElement.find_next_siblingscKs|j|j|||f|<04>S)zkReturns the first item that matches the given criteria and
appears before this Tag in the document.)rg<00>find_all_previous)r rrirjrkr r r <00> find_previous<75>szPageElement.find_previouscKs|j|||||jf|<05>S)zcReturns all items that match the given criteria and appear
before this Tag in the document.)rm<00>previous_elements)r rrirjrorkr r r rs<00>szPageElement.find_all_previouscKs|j|j|||f|<04>S)z|Returns the closest sibling to this Tag that matches the
given criteria and appears before this Tag in the document.)rg<00>find_previous_siblings)r rrirjrkr r r <00>find_previous_sibling<6E>sz!PageElement.find_previous_siblingcKs|j|||||jf|<05>S)zrReturns the siblings of this Tag that match the given
criteria and appear before this Tag in the document.)rm<00>previous_siblings)r rrirjrorkr r r rv<00>s z"PageElement.find_previous_siblingscKs&d}|j||df|<03>}|r"|d}|S)zOReturns the closest parent of this Tag that matches the given
criteria.Nr(r)<01> find_parents)r rrirk<00>r<>lr r r <00> find_parent<6E>s
zPageElement.find_parentcKs|j||d||jf|<04>S)zFReturns the parents of this Tag that match the given
criteria.N)rm<00>parents)r rrirorkr r r ry<00>szPageElement.find_parentscCs|jS)N)r3)r r r r <00>next<78>szPageElement.nextcCs|jS)N)r2)r r r r <00>previous<75>szPageElement.previouscKs&d}||||df|<05>}|r"|d}|S)Nr(rr )r <00>methodrrirjrkrzr{r r r rg<00>s
zPageElement._find_onec  s0|dkrd|kr|d}|d=t<00>t<01>r.<2E>}nt<01>||f|<06>}|dkr<>|s<>|s<>|dksb<73>dkrzdd<05>|D<00>}t||<08>St<00>t<03><01>d<06>dkr<><72><01>dd<07>\<02><02>nd<01><02><01><00><00><01>fdd<05>|D<00>}t||<08>St|<07>} xVy t|<05>}
Wntk
r<EFBFBD>PYnX|
r<EFBFBD>|<07>|
<EFBFBD>} | r<>| <09> | <0B>|r<>t
| <09>|kr<>Pq<>W| S) z8Iterates over a generator looking for things that match.N<>stringTcss|]}t|t<01>r|VqdS)N)r8rR)r^<00>elementr r r r`sz(PageElement._find_all.<locals>.<genexpr>rr(c3sB|]:}t|t<01>r|j<02>ks6|j<02>kr<02>dks6|j<03>kr|VqdS)N)r8rRrr)r^r<>)<03>
local_namerrr r r`s



) r8<00> SoupStrainer<65> ResultSetr<00>count<6E>splitr~<00> StopIterationr&rMrW) r rrirjro<00> generatorrkZstrainer<65>result<6C>results<74>i<>foundr )r<>rrr rm<00>s<



 

zPageElement._find_allccs$|j}x|dk r|V|j}qWdS)N)r3)r r<>r r r rn,s
zPageElement.next_elementsccs$|j}x|dk r|V|j}qWdS)N)r4)r r<>r r r rr3s
zPageElement.next_siblingsccs$|j}x|dk r|V|j}qWdS)N)r2)r r<>r r r ru:s
zPageElement.previous_elementsccs$|j}x|dk r|V|j}qWdS)N)r5)r r<>r r r rxAs
zPageElement.previous_siblingsccs$|j}x|dk r|V|j}qWdS)N)r1)r r<>r r r r}Hs
zPageElement.parentscCs|jS)N)rn)r r r r <00> nextGeneratorQszPageElement.nextGeneratorcCs|jS)N)rr)r r r r <00>nextSiblingGeneratorTsz PageElement.nextSiblingGeneratorcCs|jS)N)ru)r r r r <00>previousGeneratorWszPageElement.previousGeneratorcCs|jS)N)rx)r r r r <00>previousSiblingGeneratorZsz$PageElement.previousSiblingGeneratorcCs|jS)N)r})r r r r <00>parentGenerator]szPageElement.parentGenerator)NNNNN)TT)@rrrrr7r>r9rr?rZ nextSiblingZpreviousSiblingrH<00> replaceWithrLZreplace_with_childrenZreplaceWithChildrenrOrFrPZ_lastRecursiveChildrGrMr]rcrfrlZfindNextrhZ findAllNextrqZfindNextSiblingrpZfindNextSiblingsZfetchNextSiblingsrtZ findPreviousrsZfindAllPreviousZ fetchPreviousrwZfindPreviousSiblingrvZfindPreviousSiblingsZfetchPreviousSiblingsr|Z
findParentryZ findParentsZ fetchParentsr~rrgrmrnrrrurxr}r<>r<>r<>r<>r<>r r r r r/qsz
   
J 
  6     r/c@s\eZdZdZdZdZdd<04>Zdd<06>Zdd<08>Zd d
<EFBFBD>Z dd d <0A>Z
e dd<0F><00>Z e j dd<0F><00>Z dS)rT<00>NcCs2t|t<01>rt<01>||<01>}nt<01>||t<03>}|<02><04>|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.
)r8rr<00>DEFAULT_OUTPUT_ENCODINGr7)r<00>value<75>ur r r rks

zNavigableString.__new__cCs t|<00>|<00>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.
)<01>type)r r r r <00>__copy__zszNavigableString.__copy__cCs
t|<00>fS)N)r)r r r r <00>__getnewargs__<5F>szNavigableString.__getnewargs__cCs$|dkr |Std|jj|f<00><01>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.r<>z!'%s' object has no attribute '%s'N)<03>AttributeError<6F> __class__r)r r
r r r <00> __getattr__<5F>s
zNavigableString.__getattr__<5F>minimalcCs|<00>||<01>}|j||jS)z.Run the string through the provided formatter.)r><00>PREFIX<49>SUFFIX)r r<r=r r r <00> output_ready<64>s zNavigableString.output_readycCsdS)Nr )r r r r r<00>szNavigableString.namecCs td<01><01>dS)Nz)A NavigableString cannot be given a name.)r<>)r rr r r r<00>s)r<>)rrrr<>r<>rCrr<>r<>r<>r<>rrrr r r r rTas
 rTc@seZdZdZddd<04>ZdS)<06>PreformattedStringz<67>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.
NcCs$|dk r|<00>||<01>}|j||jS)zwCData strings are passed into the formatter, purely
for any side effects. The return value is ignored.
N)r>r<>r<>)r r<<00>ignorer r r r<><00>s zPreformattedString.output_ready)N)rrrrr<>r r r r r<><00>sr<>c@seZdZdZdZdS)<04>CDataz <![CDATA[z]]>N)rrrr<>r<>r r r r r<><00>sr<>c@seZdZdZdZdZdS)<05>ProcessingInstructionzA SGML processing instruction.z<?<3F>>N)rrrrr<>r<>r r r r r<><00>sr<>c@seZdZdZdZdZdS)<05>XMLProcessingInstructionzAn XML processing instruction.z<?z?>N)rrrrr<>r<>r r r r r<><00>sr<>c@seZdZdZdZdS)<04>Commentz<!--z-->N)rrrr<>r<>r r r r r<><00>sr<>c@seZdZdZdZdS)<04> Declarationz<?z?>N)rrrr<>r<>r r r r r<><00>sr<>c@s eZdZedd<02><00>ZdZdZdS)<06>DoctypecCsN|pd}|dk r2|d|7}|dk rF|d|7}n|dk rF|d|7}t|<04>S)Nr<4E>z PUBLIC "%s"z "%s"z SYSTEM "%s")r<>)rrZpub_id<69> system_idr<64>r r r <00>for_name_and_ids<64>s  zDoctype.for_name_and_idsz
<!DOCTYPE z>
N)rrr<00> classmethodr<64>r<>r<>r r r r r<><00>s r<>c@s:eZdZdZdfdd<04>Zed<05>Zdd<07>Zedd <09><00>Z e Z
ed
d <0B><00>Z e j d d <0B><00>Z d e effdd<0F>Zee<0F>Zedd<11><00>Zdd e effdd<14>ZeZee<12>Zdd<16>Zdgdd<18>Zdd<1A>Zdd<1C>Zdhdd<1E>Zdidd <20>Zd!d"<22>Zd#d$<24>Zd%d&<26>Zd'd(<28>Zd)d*<2A>Zd+d,<2C>Z d-d.<2E>Z!d/d0<64>Z"d1d2<64>Z#d3d4<64>Z$d5d6<64>Z%d7d8<64>Z&d9d:<3A>Z'djd<d=<3D>Z(d>d?<3F>Z)d@dA<64>Z*e+<2B>r\e)Z*Z(e,ddBdCfdDdE<64>Z-de,dBfdFdG<64>Z.dHdI<64>Z/dkdJdK<64>Z0de,dBfdLdM<64>Z1de,dBfdNdO<64>Z2e,d dPfdQdR<64>Z3didSdfdTdU<64>Z4e4Z5didSddfdVdW<64>Z6e6Z7e6Z8edXdY<64><00>Z9edZd[<5B><00>Z:dld\d]<5D>Z;dmd^d_<64>Z<d`da<64>Z=dbdc<64>Z>ddde<64>Z?dS)nrRz=Represents a found HTML tag with its attributes and contents.NcCs|dkrd|_n|j|_|dkr(td<02><01>||_||_||_|rD|jr`|
dk sT| dk r`|
|_| |_|dkrni}n4|r<>|dk r<>|j r<>|<02>
|j|<06>}q<>t |<06>}nt |<06>}|r<>|j |_ n| |_ ||_g|_|<00>||<08>d|_|dkr<>| |_| |_ ||_n&|<02>|<00>|<02>|<03>|_|j |_ |j|_dS)zBasic constructor.Nz%No value provided for new tag's name.F)<15> parser_classr<73>rDrrrZstore_line_numbers<72>
sourceline<EFBFBD> sourcepos<6F>cdata_list_attributesZ$_replace_cdata_list_attribute_values<65>dictrBrCrir6r7<00>hidden<65>can_be_empty_element<6E>preserve_whitespace_tagsZset_up_substitutions)r <00>parser<65>builderrrrrir1rrBr<>r<>r<>r<>r<>r r r <00>__init__<5F>sF
 

 

z Tag.__init__r<5F>cCs|t|<00>d|j|j|j|j|j|j|j|j|j |j
|j d<02> }xdD]}t ||t ||<02><02>q@Wx|jD]}|<01>|<03><10><00>qbW|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)rBr<>r<>r<>r<>r<>)r<>r<>)r<>r<>rrrrir?r<>r<>r<>r<>r<>rrr6rMr<>)r <00>cloner
rKr r r r<>&s 

 z Tag.__copy__cCst|j<01>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)rWr6r<>)r r r r <00>is_empty_element8szTag.is_empty_elementcCs0t|j<01>dkrdS|jd}t|t<03>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)rWr6r8rTr<>)r rKr r r r<>Js


z
Tag.stringcCs|<00><00>|<00>|<01>|<01><01>dS)N)<03>clearrMr<>)r r<>r r r r<>[sFccs\xV|jD]L}|dkrt|t<02>r|dk r4t|<03>|kr4q|rN|<03><04>}t|<03>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)<06> descendantsr8rTr<><00>striprW)r r<><00>typesZ
descendantr r r <00> _all_strings`s  zTag._all_stringsccsx|<00>d<01>D]
}|Vq WdS)NT)r<>)r r<>r r r <00>stripped_stringstszTag.stripped_stringsr<73>cCs|<01>dd<02>|j||d<03>D<00><01>S)zP
Get all child strings, concatenated using the given separator.
cSsg|]}|<01>qSr r )r^r;r r r <00>
<listcomp>~sz Tag.get_text.<locals>.<listcomp>)r<>)<02>joinr<6E>)r <00> separatorr<72>r<>r r r <00>get_textysz Tag.get_textcCs8|<00><00>|}x&|dk r2|j}|j<02><03>g|_|}qWdS)z/Recursively destroys the contents of this tree.N)rFr3<00>__dict__r<5F>r6)r r<>r~r r r <00> decompose<73>s

z Tag.decomposecCs^|r:xT|jdd<01>D] }t|t<02>r,|<02><03>q|<02><04>qWn x|jdd<01>D] }|<02><04>qJWdS)zP
Extract all children. If decompose is True, decompose instead.
N)r6r8rRr<>rF)r r<>r<>r r r r<><00>s

z Tag.clearcCs<>g}x|t|j<01>D]n\}}t|t<03>r*|<03><04>|t|j<01>dkr>q|j|d}t|t<06>rt|t<06>rt|t<07>st|t<07>s|<01>|<02>qWxFt |<01>D]:}|j|}|j|d}|<04>
<EFBFBD>t||<00>}|<03> |<05>q<>WdS)z<>Smooth out this element's children by consolidating consecutive strings.
This makes pretty-printed output look more natural following a
lot of operations that modified the tree.
r(N) <0C> enumerater6r8rR<00>smoothrWrTr<>rMrJrFrH)r Zmarkedr<64><00>a<>b<>nr r r r<><00>s$






 z
Tag.smoothcCs0x"t|j<01>D]\}}||kr |Sq Wtd<01><01>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)r<>r6rD)r r<>r<>rKr r r rE<00>sz Tag.indexcCs|j<00>||<02>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.)ri<00>get)r <00>key<65>defaultr r r r<><00>szTag.getcCs |<00>||<02>}t|t<02>s|g}|S)z-The same as get(), but always returns a list.)r<>r8rU)r r<>r<>r<>r r r <00>get_attribute_list<73>s 
zTag.get_attribute_listcCs
||jkS)N)ri)r r<>r r r <00>has_attr<74>sz Tag.has_attrcCs t|<00><01><01>S)N)r<00>__hash__)r r r r r<><00>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.)ri)r r<>r r r <00> __getitem__<5F>szTag.__getitem__cCs
t|j<01>S)z0Iterating over a tag iterates over its contents.)<02>iterr6)r r r r <00>__iter__<5F>sz Tag.__iter__cCs
t|j<01>S)z:The length of a tag is the length of its list of contents.)rWr6)r r r r <00>__len__<5F>sz Tag.__len__cCs
||jkS)N)r6)r r_r r r <00> __contains__<5F>szTag.__contains__cCsdS)z-A tag is non-None even if it has no contents.Tr )r r r r <00>__bool__<5F>sz Tag.__bool__cCs||j|<dS)zKSetting tag[key] sets the value of the 'key' attribute for the
tag.N)ri)r r<>r<>r r r <00> __setitem__<5F>szTag.__setitem__cCs|j<00>|d<01>dS)z;Deleting tag[key] deletes all 'key' attributes for the tag.N)ri<00>pop)r r<>r r r <00> __delitem__<5F>szTag.__delitem__cOs |j||<02>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.)<01>find_all)r rbrkr r r <00>__call__<5F>sz Tag.__call__cCsrt|<01>dkr@|<01>d<02>r@|dd<03>}t<02>dt|d<05><00>|<00>|<02>S|<01>d<06>s\|dks\|<00>|<01>Std|j|f<00><01>dS) N<>rR<00><><EFBFBD><EFBFBD><EFBFBD>z<EFBFBD>.%(name)sTag is deprecated, use .find("%(name)s") instead. If you really were looking for a tag called %(name)sTag, use .find("%(name)sTag"))r<00>__r6z!'%s' object has no attribute '%s') rW<00>endswith<74>warnings<67>warnr<6E><00>find<6E>
startswithr<EFBFBD>r<>)r r[Ztag_namer r r r<>s  

zTag.__getattr__cCs<>||kr dSt|d<02>rRt|d<03>rRt|d<04>rR|j|jksR|j|jksRt|<00>t|<01>krVdSx(t|j<05>D]\}}||j|krbdSqbWdS)zReturns true iff this tag has the same name, the same attributes,
and the same contents (recursively) as the given tag.Trrir6F)rXrrirWr<>r6)r <00>otherr<72>Zmy_childr r r <00>__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 )r r<>r r r <00>__ne__"sz
Tag.__ne__<5F>unicode-escapecCstr |<00><01>S|<00>|<01>SdS)zRenders this tag as a string.N)<03>PY3K<33>decoder#)r r"r r r <00>__repr__'sz Tag.__repr__cCs|<00><00>S)N)r<>)r r r r <00> __unicode__2szTag.__unicode__cCstr |<00><01>S|<00><02>SdS)N)r<>r<>r#)r r r r <00>__str__5sz Tag.__str__r<5F><00>xmlcharrefreplacecCs|<00>|||<03>}|<05>||<04>S)N)r<>r#)r r"<00> indent_levelr<<00>errorsr<73>r r r r#>sz
Tag.encodecCs*t|t<01>s|<00>|<03>}|<03>|<00>}g}x<>|D]<5D>\}}|dkr>|}npt|t<04>sRt|t<05>r^d<02>|<07>}n0t|t<07>srt|<07>}nt|t<08>r<>|dk r<>|<07> |<02>}|<03>
|<07>} t|<06>d|<03> | <09>}|<05> |<08>q(Wd}
d} d} |j r<>|j d} |jr<>|jp<>d}
nd| |jf} |<00>|<01>} d}d}|dk <09>r d|d}| <0A>r4|}|d}nd}|<00>|||<03>}|j<13>rT|}n<>g}d}|<05>rpdd<02>|<05>}|dk <09>r<>|<12> |<0F>|<12> d| |j||
f<00>| <0A>r<>|<12> d <09>|<12> |<11>| <0A>r<>|<11>r<>|d
d k<03>r<>|<12> d <09>| <0A>r<>| <0B>r<>|<12> |<0E>|<12> | <0B>|dk <09>r| <0B>r|j<14>r|<12> d <09>d<04>|<12>}|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.
N<> <20>=r<>rz</%s%s>r(z
<%s%s%s%s><3E>
r0)r8rr9<00>
attributesrU<00>tupler<65>rrr#Zattribute_valueZquoted_attribute_valuerMrr<>Zvoid_element_close_prefixr<00>_should_pretty_print<6E>decode_contentsr<73>r4)r r<><00>eventual_encodingr<r<>rir<><00>val<61>decodedrj<00>close<73>closeTagr<00> pretty_print<6E>spaceZ indent_spaceZindent_contentsr6r;Zattribute_stringr r r r<>Fst


 





 

 






 



z
Tag.decodecCs|dk o|j p|j|jkS)z"Should this tag be pretty-printed?N)r<>r)r r<>r r r r<><00>szTag._should_pretty_printcCs*|dkr|jd|d<02>S|j|d|d<02>SdS)NT)r<)r<>r#)r r"r<r r r <00>prettify<66>sz Tag.prettifyc Cs<>t|t<01>s|<00>|<03>}|dk }g}x<>|D]<5D>}d}t|t<03>rD|<06>|<03>}nt|t<05>rb|<05>|<06>|||<03><03>|jor|j |jk}|r<>|r<>|s<>|<07>
<EFBFBD>}|r&|r<>|s<>|<05>d|d<00>|<05>|<07>|r&|s&|<05>d<04>q&Wd<05> |<05>S)atRenders 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. decode_contents() 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: A Formatter object, or a string naming one of
the standard Formatters.
Nr<4E>r(r<>r<>) r8rr9rTr<>rRrMr<>r<>rr<>r<>) r r<>r<>r<r<>r;rArjZpreserve_whitespacer r r r<><00>s*



 
  
zTag.decode_contentscCs|<00>|||<03>}|<04>|<02>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#)r r<>r"r<r6r r r <00>encode_contents<74>szTag.encode_contentsrcCs|sd}|j||d<01>S)N)r<>r")r)r r"Z prettyPrintZ indentLevelr r r <00>renderContents<74>szTag.renderContentsTcKs*d}|j||||df|<05>}|r&|d}|S)zLReturn only the first child of this Tag matching the given
criteria.Nr(r)r<>)r rri<00> recursiverjrkrzr{r r r r<><00>s
zTag.findcKs&|j}|s|j}|j|||||f|<06>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<><00>childrenrm)r rrirrjrorkr<>r r r r<>s z Tag.find_allcCs
t|j<01>S)N)r<>r6)r r r r rsz Tag.childrenccs@t|j<01>sdS|<00><02>j}|jd}x||k r:|V|j}q$WdS)Nr)rWr6rPr3)r ZstopNode<64>currentr r r r<>!s



zTag.descendantscKs"|j||df|<03>}|r|dSdS)z9Perform a CSS selection operation on the current element.r(rN)<01>select)r <00>selector<6F>
namespacesrkr<>r r r <00>
select_one,szTag.select_onecKs>|dkr|j}|dkrd}tdkr*td<03><01>tj||||f|<04>S)a:Perform a CSS selection operation on the current element.
This uses the SoupSieve library.
:param selector: A string containing a CSS selector.
:param namespaces: A dictionary mapping namespace prefixes
used in the CSS selector to namespace URIs. By default,
Beautiful Soup will use the prefixes it encountered while
parsing the document.
:param limit: After finding this number of results, stop looking.
:param kwargs: Any extra arguments you'd like to pass in to
soupsieve.select().
NrzLCannot execute CSS selectors because the soupsieve package is not installed.)<04> _namespaces<65> soupsieve<76>NotImplementedErrorr)r rrrorkr r r r3sz
Tag.selectcCs|jS)N)r)r r r r <00>childGeneratorQszTag.childGeneratorcCs|jS)N)r<>)r r r r <00>recursiveChildGeneratorTszTag.recursiveChildGeneratorcCst<00>d|<00>|<00>|<01>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<>)r r<>r r r <00>has_keyWsz Tag.has_key)NNNNNNNNNNNNNN)F)N)N)r<>)Nr<4E>)N)NN)@rrrrr<>rZ parserClassr<73>rr<>Z isSelfClosingr<67>rrTr<>r<><00>stringsr<73>r<>ZgetTextrjr<>r<>r<>rEr<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r#r<>r<>r<>r<>rrr<>Z findChildr<64>ZfindAllZ findChildrenrr<>rrr r rr r r r rR<00>s<>
E   
%


  ]
 ,    

rRc@sTeZdZdZdidfdd<04>Zdd<06>Zdd<08>Zdifd d
<EFBFBD>ZeZd d <0C>Z dd d<0E>Z
dS)r<>zMEncapsulates a number of ways of matching a markup element (tag or
text).NcKs<>|<00>|<01>|_t|t<03>s"||d<d}d|kr<|d|d<|d=|r\|rX|<02><04>}|<02>|<04>n|}i}x&t|<02><07><00>D]\}}|<00>|<07>||<qnW||_|<00>|<03>|_ dS)N<>class<73>class_)
<EFBFBD>_normalize_search_valuerr8r<><00>copy<70>updaterU<00>itemsrirj)r rrirjrkZnormalized_attrsr<73>r<>r r r r<>ds" 
  zSoupStrainer.__init__cCs<>t|t<01>s0t|t<02>s0t|d<01>s0t|t<04>s0|dkr4|St|t<05>rH|<01>d<02>St|d<03>r<>g}xF|D]>}t|d<03>r<>t|t<05>s<>t|t<01>s<>|<02>|<03>q\|<02>|<00>|<03><01>q\W|Stt|<01><01>S)Nr'<00>utf8r<38>) r8rrrX<00>bool<6F>bytesr<73>rMr)r r<>Z new_value<75>vr r r rs




 z$SoupStrainer._normalize_search_valuecCs |jr |jSd|j|jfSdS)Nz%s|%s)rjrri)r r r r r<><00>szSoupStrainer.__str__c Csd}d}t|t<01>r|}|}t|jt<03>o0t|t<01> }|jr`|s`|rN|<00>||j<02>s`|s<>|<00>||j<02>r<>|rr|<00>||<02>}nrd}d}xht|j<06><07><00>D]V\}} |s<>t|d<02>r<>|}ni}x|D]\}
} | ||
<q<>W|<07> |<08>} |<00>| | <09>s<>d}Pq<>W|r<>|r<>|}n|}|<03>r|j
<EFBFBD>r|<00>|j |j
<EFBFBD><02>sd}|S)NTr<54>F) r8rRrr<00>_matchesrUrirrXr<>rjr<>) r Z markup_nameZ markup_attrsr<73><00>markupZcall_function_with_tag_datar'Zmarkup_attr_mapr
<00> match_against<73>kr<00>
attr_valuer r r <00>
search_tag<EFBFBD>sB
  
 
  zSoupStrainer.search_tagcCs<>d}t|d<01>rFt|ttf<02>sFx<46>|D]}t|t<04>r"|<00>|<03>r"|}Pq"Wnjt|t<02>rn|jrb|jsb|jr<>|<00> |<01>}nBt|t<04>s<>t|t<03>r<>|js<>|js<>|<00>
||j<06>r<>|}nt d|j <00><01>|S)Nr<4E>z&I don't know how to match against a %s) rXr8rRrrTr&rjrrirr<00> Exceptionr<6E>)r rr<>r<>r r r r&<00>s"



 

 zSoupStrainer.searchc Cs~d}t|t<01>st|t<02>rPx|D]}|<00>||<02>rdSqW|<00>d<03>|<01>|<02>rLdSdS|dkr`|dk St|t<05>rr||<01>S|}t|t<06>r<>|j}|<00>|<01>}|dkr<>| St |d<04><02>rt|t
<EFBFBD><02>s|s<>t <0B>}xL|D]@}|j r<>|}nt |<05>}||kr<>q<EFBFBD>q<EFBFBD>|<03>|<07>|<00>|||<03>r<>dSq<>WdSd}|<08>s,t|t
<EFBFBD><02>r,||k}|<08>sHt |d<05><02>rH|<02>|<01>S|<08>szt|t<06><02>rz|j<10>rz|<00>|jd|j|<02>S|S)NFTr<54>r<>r&r)r8rUr<>rr<>rrRrrrXr<00>setr<74><00>id<69>addr&r) r rrZ already_triedr<64><00>itemZoriginal_markupr<70>r'r r r r<00>sV
 


  


 zSoupStrainer._matches)N) rrrrr<>rr<>rZ searchTagr&rr r r r r<>`s'r<>cs*eZdZdZd<07>fdd<04> Zdd<06>Z<05>ZS)r<>zTA ResultSet is just a list that keeps track of the SoupStrainer
that created it.r cstt|<00><02>|<02>||_dS)N)<04>superr<72>r<><00>source)r r&r<>)r<>r r r<><szResultSet.__init__cCstd|<00><01>dS)Nz<4E>ResultSet object has no attribute '%s'. You're probably treating a list of items like a single item. Did you call find_all() when you meant to call find()?)r<>)r r<>r r r r<>@szResultSet.__getattr__)r )rrrrr<>r<><00> __classcell__r r )r<>r r<>9sr<>))<29> __license__<5F>collections.abcr<00> ImportError<6F>er@r,<00>sysr<73>r
r<>Z bs4.formatterrrrr<><00> version_infor<6F>r-Znonwhitespace_reZ whitespace_rerrrrr r$<00>objectr/rTr<>r<>r<>r<>r<>r<>r<>rRr<>rUr<>r r r r <00><module>sZ 

 s:Z