
    Ti>                       S r  SSKJr  SSKrSSKrSSKr SSK	r	SSKJrJrJr  Sr\R                   S   S:  r\R$                  " S5      r\R$                  " S	5      rS
 r\" / SQ5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\\5      r " S S\5      r  " S S\ 5      r! " S S\ 5      r" " S S\"5      r# " S  S!\ 5      r$ " S" S#\ 5      r% " S$ S%\ 5      r& " S& S'\5      r' " S( S)\5      r( " S* S+\5      r) " S, S-\5      r* " S. S/\5      r+ " S0 S1\,5      r-g! \ a  rSSKJr   SrCGNESrCff = f! \ a  rSr	\R                  " S5         SrCGN\SrCff = f)2MIT    )CallableNzEThe soupsieve package is not installed. CSS selectors cannot be used.)	FormatterHTMLFormatterXMLFormatterzutf-8   z\S+z\s+c                 P   ^  [         U 4S j5       nUR                  U 4S j5       nU$ )z>Alias one attribute name to another for backward compatibilityc                    > [        U T5      $ Ngetattrselfattrs    ]/var/www/html/backend/Backoffice_Marketplace/venv/lib/python3.13/site-packages/bs4/element.pyalias_alias.<locals>.alias$       tT""    c                    > [        U T5      $ r   )setattrr   s    r   r   r   (   r   r   )propertysetter)r   r   s   ` r   _aliasr   "   s2    # # \\# #Lr   )idnambcsoempalmospunycoderaw_unicode_escape	undefinedunicode_escapezraw-unicode-escapeunicode-escapezstring-escapestring_escapec                   "    \ rS rSrSrSS jrSrg)NamespacedAttributeK   z~A namespaced string (e.g. 'xml:lang') that remembers the namespace
('xml') and the name ('lang') that were used to create it.
Nc                     U(       d  S nUc  [         R                  X5      nO4Uc  [         R                  X5      nO[         R                  XS-   U-   5      nXl        X$l        X4l        U$ )N:)str__new__prefixname	namespace)clsr,   r-   r.   objs        r   r+   NamespacedAttribute.__new__P   s]     D<++c*C^++c(C++cC<$#67C
!
r    NN)__name__
__module____qualname____firstlineno____doc__r+   __static_attributes__r2   r   r   r&   r&   K   s    r   r&   c                       \ rS rSrSrSrg)%AttributeValueWithCharsetSubstitutionb   z=A stand-in object for a character encoding specified in HTML.r2   Nr4   r5   r6   r7   r8   r9   r2   r   r   r;   r;   b   s    Gr   r;   c                   $    \ rS rSrSrS rS rSrg)CharsetMetaAttributeValuee   zA 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.
c                 <    [         R                  X5      nXl        U$ r   )r*   r+   original_value)r/   rB   r0   s      r   r+   !CharsetMetaAttributeValue.__new__l   s    kk#.+
r   c                     U[         ;   a  gU$ )z}When an HTML document is being encoded to a given encoding, the
value of a meta tag's 'charset' is the name of the encoding.
 )PYTHON_SPECIFIC_ENCODINGSr   encodings     r   encode CharsetMetaAttributeValue.encodeq   s     00r   r2   N)r4   r5   r6   r7   r8   r+   rI   r9   r2   r   r   r?   r?   e   s    
r   r?   c                   ^    \ rS rSrSr\R                  " S\R                  5      rS r	S r
Srg)ContentMetaAttributeValuez   zA 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=)([^;]*)c                     U R                   R                  U5      nUc  [        R                  [        U5      $ [        R                  X5      nXl        U$ r   )
CHARSET_REsearchr*   r+   rB   )r/   rB   matchr0   s       r   r+   !ContentMetaAttributeValue.__new__   sE    %%n5=;;sN33kk#.+
r   c                 p   ^ T[         ;   a  gU4S jnU R                  R                  X R                  5      $ )NrE   c                 ,   > U R                  S5      T-   $ )N   )group)rQ   rH   s    r   rewrite1ContentMetaAttributeValue.encode.<locals>.rewrite   s    ;;q>H,,r   )rF   rO   subrB   )r   rH   rW   s    ` r   rI    ContentMetaAttributeValue.encode   s/    00	-""7,?,?@@r   r2   N)r4   r5   r6   r7   r8   recompileMrO   r+   rI   r9   r2   r   r   rL   rL   z   s)     8"$$?JAr   rL   c                   >   \ rS rSrSr  S.S jrS rS r\S 5       r	\
" S5      r\
" S	5      rS
 r\rS r\r\rS rS/S jrS0S jr\rS rS rS rS rS rS0 S4S jr\rS0 SS4S jr\rS0 S4S jr\r S0 SS4S jr!\!r"\!r#S0 S4S jr$\$r%S0 SS4S jr&\&r'\&r(S0 S4S jr)\)r*S0 SS4S jr+\+r,\+r-S0 4S jr.\.r/S0 S4S jr0\0r1\0r2\S 5       r3\S 5       r4S  r5S! r6\S" 5       r7\S# 5       r8\S$ 5       r9\S% 5       r:\S& 5       r;\S' 5       r<S( r=S) r>S* r?S+ r@S, rAS-rBg)1PageElement   zContains the navigational information for some part of the page:
that is, its current location in the parse tree.

NavigableString, Tag, etc. are all subclasses of PageElement.
Nc                    Xl         X l        Ub  X R                  l        X0l        U R                  b  X R                  l        XPl        U R                  b  X R                  l        UcA  U R                   b4  U R                   R
                  (       a  U R                   R
                  S   nX@l        Ub  X R                  l        gg)a  Sets up the initial relations between this element and
other elements.

:param parent: The parent of this element.

:param previous_element: The element parsed immediately before
    this one.

:param next_element: The element parsed immediately before
    this one.

:param previous_sibling: The most recently encountered element
    on the same level of the parse tree as this one.

:param previous_sibling: The next element to be encountered
    on the same level of the parse tree as this one.
N)parentprevious_elementnext_elementnext_siblingprevious_siblingcontents)r   rc   rd   re   rg   rf   s         r   setupPageElement.setup   s    &  0'15!!.((15.((15.$'DKK,@,@#{{33B7 0'15!!. (r   c                 ~    Uc  U$ [        U[        5      (       d  U R                  U5      nUR                  U5      nU$ )zFormat the given string using the given formatter.

:param s: A string.
:param formatter: A Formatter object, or a string naming one of the standard formatters.
)
isinstancer   formatter_for_name
substitute)r   s	formatteroutputs       r   format_stringPageElement.format_string   sA     H)Y////	:I%%a(r   c                     [        U[        5      (       a  U$ U R                  (       a  [        nO[        n[        U[
        5      (       a  U" US9$ UR                  U   $ )aD  Look 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.
)entity_substitution)rl   r   _is_xmlr   r   r   REGISTRY)r   rp   cs      r   rm   PageElement.formatter_for_name   sO     i++<<AAi**33zz)$$r   c                     U R                   b  U R                   $ U R                  c  [        U SS5      $ U R                  R                  $ )zIs 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.
is_xmlF)	known_xmlrc   r   rv   r   s    r   rv   PageElement._is_xml   sG     >>% >>!
 ;; 4511{{"""r   rf   rg   c                     U R                   c  [        S5      eXL a  gXR                   L a  [        S5      eU R                   nU R                   R                  U 5      nU R                  US9  UR	                  X15        U $ )zReplace this PageElement with another one, keeping the rest of the
tree the same.

:param replace_with: A PageElement.
:return: `self`, no longer part of the tree.
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._self_index)rc   
ValueErrorindexextractinsert)r   replace_with
old_parentmy_indexs       r   r   PageElement.replace_with  s     ;;@A A ;;&DEE[[
;;$$T**(1r   c                    U R                   nU R                   c  [        S5      eU R                   R                  U 5      nU R                  US9  [	        U R
                  SS 5       H  nUR                  X#5        M     U $ )zZReplace this PageElement with its contents.

:return: `self`, no longer part of the tree.
NzSCannot replace an element with its contents when thatelement is not part of a tree.r   )rc   r   r   r   reversedrh   r   )r   	my_parentr   childs       r   unwrapPageElement.unwrap  sx    
 KK	;;12 2 ;;$$T**dmmA./EX- 0r   c                 J    U R                  U5      nUR                  U5        U$ )zWrap this PageElement inside another one.

:param wrap_inside: A PageElement.
:return: `wrap_inside`, occupying the position in the tree that used
   to be occupied by `self`, and with `self` inside it.
)r   append)r   wrap_insidemes      r   wrapPageElement.wrap*  s(     {+2r   c                    U R                   b5  Uc  U R                   R                  U 5      nU R                   R                  U	 U R                  5       nUR                  nU R
                  b  U R
                  ULa  X0R
                  l        Ub  X0R
                  La  U R
                  Ul        SU l        SUl        SU l         U R                  b4  U R                  U R                  La  U R                  U R                  l        U R                  b4  U R                  U R                  La  U R                  U R                  l        S=U l        U l        U $ )zDestructively rips this element out of the tree.

:param _self_index: The location of this element in its parent's
   .contents, if known. Passing this in allows for a performance
   optimization.

:return: `self`, no longer part of the tree.
N)rc   r   rh   _last_descendantre   rd   rg   rf   )r   r   
last_childre   s       r   r   PageElement.extract5  s.    ;;"""kk//5$$[1
 **,
!..!!-!!51=!!.#<Q<Q(Q,0,A,AL) $"&
!!-%%T->->>151B1BD!!.)!!)>)>>151F1FD.488 1r   c                 4   U(       a$  U R                   b  U R                   R                  nO_U n[        U[        5      (       aH  UR                  (       a7  UR                  S   n[        U[        5      (       a  UR                  (       a  M7  U(       d  X0L a  SnU$ )zFinds the last element beneath this object to be parsed.

:param is_initialized: Has `setup` been called on this PageElement
    yet?
:param accept_self: Is `self` an acceptable answer to the question?
Nrb   )rf   rd   rl   Tagrh   )r   is_initializedaccept_selfr   s       r   r   PageElement._last_descendant[  sz     d//;**;;JJZ--*2E2E'004
 Z--*2E2E2Ez1Jr   c                    Uc  [        S5      eX L a  [        S5      e[        U[        5      (       a   [        U[        5      (       d  [        U5      nSSKJn  [        X#5      (       a3  [        UR                  5       H  nU R                  X5        US-  nM     g[        U[        U R                  5      5      n[        US5      (       aG  UR                  b:  UR                  U L a  U R                  U5      nXQ:  a  US-  nUR                  5         Xl        SnUS:X  a  SUl        Xl        O>U R                  US-
     nXbl        X"R                  l        UR%                  S5      Ul        UR                   b  X"R                   l        UR%                  S5      nU[        U R                  5      :  aG  SUl        U nSn	U	c'  Ub$  UR"                  n	UR                  nU	b  OU	c  Ub  M$  U	b  Xl        O@SUl        O8U R                  U   n
Xl        UR"                  b  X"R"                  l        Xl        UR&                  b  XwR&                  l        U R                  R                  X5        g)	zInsert a new PageElement in the list of this PageElement's children.

This works the same way as `list.insert`.

:param position: The numeric position that should be occupied
   in `self.children` by the new PageElement. 
:param new_child: A PageElement.
NzCannot insert None into a tag.z Cannot insert a tag into itself.r   )BeautifulSouprU   rc   F)r   rl   r*   NavigableStringbs4r   listrh   r   minlenhasattrrc   r   r   rg   rd   rf   r   re   )r   position	new_childr   subchildcurrent_indexprevious_childnew_childs_last_elementrc   parents_next_sibling
next_childs              r   r   PageElement.insertn  sB    =>>?@@y#&&y/::'	2I%i// !!3!34H/A 5 xT]]!349h''I,<,<,H 4' $

9 5 +
 MHq=)-I&)-&!]]8a<8N)7&6?&&3)7)H)H)OI&%%16?&&3"+"<"<U"Cs4==))%)I"F#' &.63E'-':':$'3 '.63E $/7K4 8<'4x0J%/"%%1:C&&73=0"//;D[00AX1r   c                 N    U R                  [        U R                  5      U5        g)zWAppends the given PageElement to the contents of this one.

:param tag: A PageElement.
N)r   r   rh   )r   tags     r   r   PageElement.append  s    
 	C&,r   c                     [        U[        5      (       a  [        UR                  5      nU H  nU R	                  U5        M     g)z]Appends the given PageElements to this one's contents.

:param tags: A list of PageElements.
N)rl   r   r   rh   r   )r   tagsr   s      r   extendPageElement.extend  s7    
 dC   &DCKK r   c                 $  ^  T R                   nUc  [        S5      e[        U 4S jU 5       5      (       a  [        S5      eU HJ  n[        U[        5      (       a  UR                  5         UR                  T 5      nUR                  XC5        ML     g)zMakes the given element(s) the immediate predecessor of this one.

All the elements will have the same parent, and the given elements
will be immediately before this one.

:param args: One or more PageElements.
Nz2Element has no parent, so 'before' has no meaning.c              3   *   >#    U  H  oTL v   M
     g 7fr   r2   .0xr   s     r   	<genexpr>,PageElement.insert_before.<locals>.<genexpr>       '$QDy$   z&Can't insert an element before itself.rc   r   anyrl   r_   r   r   r   )r   argsrc   predecessorr   s   `    r   insert_beforePageElement.insert_before  s     >DF F'$''' !IJJK +{33##%LL&EMM%-  r   c                 @  ^  T R                   nUc  [        S5      e[        U 4S jU 5       5      (       a  [        S5      eSnU HV  n[        U[        5      (       a  UR                  5         UR                  T 5      nUR                  US-   U-   U5        US-  nMX     g)zMakes 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.

:param args: One or more PageElements.
Nz1Element has no parent, so 'after' has no meaning.c              3   *   >#    U  H  oTL v   M
     g 7fr   r2   r   s     r   r   +PageElement.insert_after.<locals>.<genexpr>  r   r   z%Can't insert an element after itself.r   rU   r   )r   r   rc   offset	successorr   s   `     r   insert_afterPageElement.insert_after  s     >CE E'$'''DEEI )[11!!#LL&EMM%'&.)4aKF r   c                 @    U R                   " U R                  XU40 UD6$ )a  Find the first PageElement that matches the given criteria and
appears later in the document than this PageElement.

All find_* methods take a common set of arguments. See the online
documentation for detailed explanations.

:param name: A filter on tag name.
:param attrs: A dictionary of filters on attribute values.
:param text: A filter for a NavigableString with specific text.
:kwargs: A dictionary of filters on attribute values.
:return: A PageElement.
:rtype: bs4.element.Tag | bs4.element.NavigableString
)	_find_onefind_all_nextr   r-   attrstextkwargss        r   	find_nextPageElement.find_next  s"     ~~d00$tNvNNr   c                 @    U R                   " XX4U R                  40 UD6$ )a  Find all PageElements that match the given criteria and appear
later in the document than this PageElement.

All find_* methods take a common set of arguments. See the online
documentation for detailed explanations.

:param name: A filter on tag name.
:param attrs: A dictionary of filters on attribute values.
:param text: A filter for a NavigableString with specific text.
:param limit: Stop looking after finding this many results.
:kwargs: A dictionary of filters on attribute values.
:return: A ResultSet containing PageElements.
)	_find_allnext_elementsr   r-   r   r   limitr   s         r   r   PageElement.find_all_next  s)     ~~d48J8J '%' 	'r   c                 @    U R                   " U R                  XU40 UD6$ )a  Find the closest sibling to this PageElement that matches the
given criteria and appears later in the document.

All find_* methods take a common set of arguments. See the
online documentation for detailed explanations.

:param name: A filter on tag name.
:param attrs: A dictionary of filters on attribute values.
:param text: A filter for a NavigableString with specific text.
:kwargs: A dictionary of filters on attribute values.
:return: A PageElement.
:rtype: bs4.element.Tag | bs4.element.NavigableString
)r   find_next_siblingsr   s        r   find_next_siblingPageElement.find_next_sibling(  s)     ~~d55tD '%' 	'r   c                 @    U R                   " XX4U R                  40 UD6$ )a'  Find all siblings of this PageElement that match the given criteria
and appear later in the document.

All find_* methods take a common set of arguments. See the online
documentation for detailed explanations.

:param name: A filter on tag name.
:param attrs: A dictionary of filters on attribute values.
:param text: A filter for a NavigableString with specific text.
:param limit: Stop looking after finding this many results.
:kwargs: A dictionary of filters on attribute values.
:return: A ResultSet of PageElements.
:rtype: bs4.element.ResultSet
)r   next_siblingsr   s         r   r   PageElement.find_next_siblings:  s*      ~~d4"00<4:< 	<r   c                 @    U R                   " U R                  XU40 UD6$ )a  Look backwards in the document from this PageElement and find the
first PageElement that matches the given criteria.

All find_* methods take a common set of arguments. See the online
documentation for detailed explanations.

:param name: A filter on tag name.
:param attrs: A dictionary of filters on attribute values.
:param text: A filter for a NavigableString with specific text.
:kwargs: A dictionary of filters on attribute values.
:return: A PageElement.
:rtype: bs4.element.Tag | bs4.element.NavigableString
)r   find_all_previousr   s        r   find_previousPageElement.find_previousO  s-     ~~""DA9?A 	Ar   c                 @    U R                   " XX4U R                  40 UD6$ )a/  Look backwards in the document from this PageElement and find all
PageElements that match the given criteria.

All find_* methods take a common set of arguments. See the online
documentation for detailed explanations.

:param name: A filter on tag name.
:param attrs: A dictionary of filters on attribute values.
:param text: A filter for a NavigableString with specific text.
:param limit: Stop looking after finding this many results.
:kwargs: A dictionary of filters on attribute values.
:return: A ResultSet of PageElements.
:rtype: bs4.element.ResultSet
)r   previous_elementsr   s         r   r   PageElement.find_all_previousa  s)      ~~d48N8N %#% 	%r   c                 @    U R                   " U R                  XU40 UD6$ )a  Returns the closest sibling to this PageElement that matches the
given criteria and appears earlier in the document.

All find_* methods take a common set of arguments. See the online
documentation for detailed explanations.

:param name: A filter on tag name.
:param attrs: A dictionary of filters on attribute values.
:param text: A filter for a NavigableString with specific text.
:kwargs: A dictionary of filters on attribute values.
:return: A PageElement.
:rtype: bs4.element.Tag | bs4.element.NavigableString
)r   find_previous_siblingsr   s        r   find_previous_sibling!PageElement.find_previous_siblingv  s)     ~~d994 '%' 	'r   c                 @    U R                   " XX4U R                  40 UD6$ )a,  Returns all siblings to this PageElement that match the
given criteria and appear earlier in the document.

All find_* methods take a common set of arguments. See the online
documentation for detailed explanations.

:param name: A filter on tag name.
:param attrs: A dictionary of filters on attribute values.
:param text: A filter for a NavigableString with specific text.
:param limit: Stop looking after finding this many results.
:kwargs: A dictionary of filters on attribute values.
:return: A ResultSet of PageElements.
:rtype: bs4.element.ResultSet
)r   previous_siblingsr   s         r   r   "PageElement.find_previous_siblings  s-      ~~d4"44@8>@ 	@r   c                 J    SnU R                   " XS40 UD6nU(       a  US   nU$ )a  Find the closest parent of this PageElement that matches the given
criteria.

All find_* methods take a common set of arguments. See the online
documentation for detailed explanations.

:param name: A filter on tag name.
:param attrs: A dictionary of filters on attribute values.
:kwargs: A dictionary of filters on attribute values.

:return: A PageElement.
:rtype: bs4.element.Tag | bs4.element.NavigableString
NrU   r   )find_parents)r   r-   r   r   rls         r   find_parentPageElement.find_parent  s1      d177!Ar   c                 @    U R                   " XSX0R                  40 UD6$ )a  Find all parents of this PageElement that match the given criteria.

All find_* methods take a common set of arguments. See the online
documentation for detailed explanations.

:param name: A filter on tag name.
:param attrs: A dictionary of filters on attribute values.
:param limit: Stop looking after finding this many results.
:kwargs: A dictionary of filters on attribute values.

:return: A PageElement.
:rtype: bs4.element.Tag | bs4.element.NavigableString
N)r   parents)r   r-   r   r   r   s        r   r   PageElement.find_parents  s'     ~~d4 '%' 	'r   c                     U R                   $ )zThe PageElement, if any, that was parsed just after this one.

:return: A PageElement.
:rtype: bs4.element.Tag | bs4.element.NavigableString
re   r}   s    r   nextPageElement.next  s        r   c                     U R                   $ )zThe PageElement, if any, that was parsed just before this one.

:return: A PageElement.
:rtype: bs4.element.Tag | bs4.element.NavigableString
rd   r}   s    r   previousPageElement.previous  s     $$$r   c                 8    S nU" X#US40 UD6nU(       a  US   nU$ )NrU   r   r2   )r   methodr-   r   r   r   r   r   s           r   r   PageElement._find_one  s+    4a262!Ar   c                 ~  ^^^ Uc  SU;   a  US   nUS	 [        T[        5      (       a  TnO[        TX#40 UD6nUc  U(       d  U(       d  U(       dy  TSL d  Tc  S U 5       n[        Xx5      $ [        T[        5      (       aH  TR	                  S5      S:X  a  TR                  SS5      u  mmOSmTmUUU4S jU 5       n[        Xx5      $ [        U5      n	  [        U5      n
U
(       aB  UR                  U
5      nU(       a*  U	R                  U5        U(       a  [        U	5      U:  a   U	$ MW  ! [         a     U	$ f = f)z8Iterates over a generator looking for things that match.NstringTc              3   T   #    U  H  n[        U[        5      (       d  M  Uv   M      g 7fr   )rl   r   )r   elements     r   r   (PageElement._find_all.<locals>.<genexpr>  s!      7g'5 "'s   (	(r)   rU   c              3      >#    U  HS  n[        U[        5      (       a  UR                  T:X  d'  UR                  T:X  d  M:  Tb  UR                  T:X  d  MO  Uv   MU     g 7fr   )rl   r   r-   r,   )r   r  
local_namer-   r,   s     r   r   r	    sT      g'55%lld2%llj8 " $*>W^^v5M "'s   9A A	A)rl   SoupStrainer	ResultSetr*   countsplitr   StopIterationrP   r   r   )r   r-   r   r   r   	generatorr   strainerresultresultsifoundr  r,   s    `          @@r   r   PageElement._find_all  sA    <H.(#Dx dL))H#D%@@H<eFt|t|7 7 22D#&&::c?a' *.C);&FJ!F!%J  !22H%O  *NN5)W!6  !  s   D. .
D<;D<c              #   V   #    U R                   nUb  Uv   UR                   nUb  M  gg7f)zWAll PageElements that were parsed after this one.

:yield: A sequence of PageElements.
Nr   r   r  s     r   r   PageElement.next_elements  s,      mGA m   #))c              #   V   #    U R                   nUb  Uv   UR                   nUb  M  gg7f)zkAll PageElements that are siblings of this one but were parsed
later.

:yield: A sequence of PageElements.
N)rf   r  s     r   r   PageElement.next_siblings#  s,      mGA mr  c              #   V   #    U R                   nUb  Uv   UR                   nUb  M  gg7f)zXAll PageElements that were parsed before this one.

:yield: A sequence of PageElements.
Nr   r  s     r   r   PageElement.previous_elements/  s.      !!mG""A mr  c              #   V   #    U R                   nUb  Uv   UR                   nUb  M  gg7f)zmAll PageElements that are siblings of this one but were parsed
earlier.

:yield: A sequence of PageElements.
N)rg   r  s     r   r   PageElement.previous_siblings:  s.      !!mG""A mr  c              #   V   #    U R                   nUb  Uv   UR                   nUb  M  gg7f)z\All PageElements that are parents of this PageElement.

:yield: A sequence of PageElements.
N)rc   r  s     r   r   PageElement.parentsF  s*      KKmGA mr  c                 .    [        U SS5      =(       d    S$ )z?Check whether a PageElement has been decomposed.

:rtype: bool
_decomposedFr   r}   s    r   
decomposedPageElement.decomposedQ  s     t]E2;e;r   c                     U R                   $ r   )r   r}   s    r   nextGeneratorPageElement.nextGenerator[      !!!r   c                     U R                   $ r   )r   r}   s    r   nextSiblingGenerator PageElement.nextSiblingGenerator^  r+  r   c                     U R                   $ r   )r   r}   s    r   previousGeneratorPageElement.previousGeneratora      %%%r   c                     U R                   $ r   )r   r}   s    r   previousSiblingGenerator$PageElement.previousSiblingGeneratord  r2  r   c                     U R                   $ r   )r   r}   s    r   parentGeneratorPageElement.parentGeneratorg  s    ||r   )re   rf   rc   rd   rg   )NNNNNr   )TT)Cr4   r5   r6   r7   r8   ri   rr   rm   r   rv   r   nextSiblingpreviousSiblingr   replaceWithr   replace_with_childrenreplaceWithChildrenr   r   r   _lastRecursiveChildr   r   r   r   r   r   findNextr   findAllNextr   findNextSiblingr   findNextSiblingsfetchNextSiblingsr   findPreviousr   findAllPreviousfetchPreviousr   findPreviousSiblingr   findPreviousSiblingsfetchPreviousSiblingsr   
findParentr   findParentsfetchParentsr   r   r   r   r   r   r   r   r   r&  r)  r-  r0  r4  r7  r9   r2   r   r   r_   r_      sC    FJ26'6R%( # #, (K/0O( K # 	$L" +P2d-.,4 "$ O H!%Rd$ '"  K%)$ '  (O&*"4t <$ **!%Rd A  !L%)$d %$ (O%M)-Rd '  0*.bt%)@$ 22#2 * J $Bd '  KL! ! % %2l   	 	 # # 	# 	#   < <""&&r   r_   c                   z    \ rS rSrSrSrSrSrS rS r	S r
S rSS	 jr\S
 5       r\R                  S 5       rSrg)r   ik  zA Python Unicode string that is part of a parse tree.

When Beautiful Soup parses the markup <b>penguin</b>, it will
create a NavigableString for the string "penguin".
rE   Nc                     [        U[        5      (       a  [        R                  X5      nO[        R                  X[        5      nUR	                  5         U$ )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.
)rl   r*   r+   DEFAULT_OUTPUT_ENCODINGri   )r/   valueus      r   r+   NavigableString.__new__z  s>     eS!!C'AC(?@A		r   c                 $    [        U 5      " U 5      $ )zxA copy of a NavigableString has the same contents and class
as the original, but it is not connected to the parse tree.
)typer}   s    r   __copy__NavigableString.__copy__  s     Dz$r   c                     [        U 5      4$ r   )r*   r}   s    r   __getnewargs__NavigableString.__getnewargs__  s    D	|r   c                 b    US:X  a  U $ [        SU R                  R                  < SU< S35      e)ztext.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  '' object has no attribute ')AttributeError	__class__r4   r   s     r   __getattr__NavigableString.__getattr__  s2     8K NN++T34 4r   c                 \    U R                  X5      nU R                  U-   U R                  -   $ )zRun the string through the provided formatter.

:param formatter: A Formatter object, or a string naming one of the standard formatters.
rr   PREFIXSUFFIX)r   rp   rq   s      r   output_readyNavigableString.output_ready  s,    
 ##D4{{V#dkk11r   c                     g)zSince a NavigableString is not a Tag, it has no .name.

This property is implemented so that code like this doesn't crash
when run on a mixture of Tag and NavigableString objects:
    [x.name for x in tag.children]
Nr2   r}   s    r   r-   NavigableString.name  s     r   c                     [        S5      e)z1Prevent NavigableString.name from ever being set.z)A NavigableString cannot be given a name.r]  )r   r-   s     r   r-   rh    s     HIIr   r2   )minimal)r4   r5   r6   r7   r8   rc  rd  r|   r+   rU  rX  r_  re  r   r-   r   r9   r2   r   r   r   r   k  sa     FF
 I 	42   
[[J Jr   r   c                   *    \ rS rSrSrSrSrSS jrSrg)PreformattedStringi  zA NavigableString not subject to the normal formatting rules.

This is an abstract class used for special kinds of strings such
as comments (the Comment class) and CDATA blocks (the CData
class).
rE   Nc                 b    Ub  U R                  X5      nU R                  U -   U R                  -   $ )a  Make this string ready for output by adding any subclass-specific
    prefix or suffix.

:param formatter: A Formatter object, or a string naming one
    of the standard formatters. The string will be passed into the
    Formatter, but only to trigger any side effects: the return
    value is ignored.

:return: The string, with any subclass-specific prefix and
   suffix added on.
rb  )r   rp   ignores      r   re  PreformattedString.output_ready  s2      ''8F{{T!DKK//r   r2   r   )	r4   r5   r6   r7   r8   rc  rd  re  r9   r2   r   r   rm  rm    s     FF0r   rm  c                        \ rS rSrSrSrSrSrg)CDatai  zA CDATA block.z	<![CDATA[z]]>r2   Nr4   r5   r6   r7   r8   rc  rd  r9   r2   r   r   rr  rr    s    FFr   rr  c                        \ rS rSrSrSrSrSrg)ProcessingInstructioni  zA SGML processing instruction.<?>r2   Nrs  r2   r   r   ru  ru    s    (FFr   ru  c                        \ rS rSrSrSrSrSrg)XMLProcessingInstructioni  zAn XML processing instruction.rv  ?>r2   Nrs  r2   r   r   ry  ry    s    (FFr   ry  c                        \ rS rSrSrSrSrSrg)Commenti  zAn HTML or XML comment.z<!--z-->r2   Nrs  r2   r   r   r|  r|    s    !FFr   r|  c                        \ rS rSrSrSrSrSrg)Declarationi  zAn XML declaration.rv  rz  r2   Nrs  r2   r   r   r~  r~    s    FFr   r~  c                   0    \ rS rSrSr\S 5       rSrSrSr	g)Doctypei  zA document type declaration.c                 r    U=(       d    SnUb  USU-  -  nUb  USU-  -  nOUb  USU-  -  n[        U5      $ )a  Generate an appropriate document type declaration for a given
public ID and system ID.

:param name: The name of the document's root element, e.g. 'html'.
:param pub_id: The Formal Public Identifier for this document type,
    e.g. '-//W3C//DTD XHTML 1.1//EN'
:param system_id: The system identifier for this document type,
    e.g. 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'

:return: A Doctype.
rE   z PUBLIC "%s"z "%s"z SYSTEM "%s")r  )r/   r-   pub_id	system_idrP  s        r   for_name_and_idsDoctype.for_name_and_ids  sW     
^f,,E$9,,"^i//Eu~r   z
<!DOCTYPE z>
r2   N)
r4   r5   r6   r7   r8   classmethodr  rc  rd  r9   r2   r   r   r  r    s#    & , FFr   r  c                       \ rS rSrSrSrg)
Stylesheeti	  z}A NavigableString representing an stylesheet (probably
CSS).

Used to distinguish embedded stylesheets from textual content.
r2   Nr=   r2   r   r   r  r  	      
 	r   r  c                       \ rS rSrSrSrg)Scripti  zA NavigableString representing an executable script (probably
Javascript).

Used to distinguish executable code from textual content.
r2   Nr=   r2   r   r   r  r    r  r   r  c                       \ rS rSrSrSrg)TemplateStringi  zA NavigableString representing a string found inside an HTML
template embedded in a larger document.

Used to distinguish such strings from the main body of the document.
r2   Nr=   r2   r   r   r  r    r  r   r  c                   h   \ rS rSrSr     S:S jr\" S5      rS r\	S 5       r
\
r\	S 5       r\R                  S	 5       rS
\\44S jr\	" \5      r\	S 5       rSS
\\44S jr\r\	" \5      rS rS;S jrS rS rS<S jrS<S jrS rS rS rS rS r S r!S r"S r#S r$S r%S r&S  r'S! r(S=S" jr)S# r*S$ r+\,(       a  \*=r+r)\-SS%S&4S' jr.S\-S%4S( jr/S) r0S>S* jr1S\-S%4S+ jr2S\-S%4S, jr3\-S
S-4S. jr4S0 S/S4S0 jr5\5r6S0 S/SS4S1 jr7\7r8\7r9\	S2 5       r:\	S3 5       r;S<S4 jr<S?S5 jr=S6 r>S7 r?S8 r@S9rAg)@r   i$  zRepresents an HTML or XML tag that is part of a parse tree, along
with its attributes and contents.

When Beautiful Soup parses the markup <b>penguin</b>, it will
create a Tag object representing the <b> tag.
Nc                    Uc  SU l         OUR                  U l         Uc  [        S5      eX0l        X@l        XPl        U(       a  UR                  (       a  U
c  Ub  Xl        Xl        Uc  0 nOOU(       a=  Ub.  UR                  (       a  UR                  U R                  U5      nO[        U5      nO[        U5      nU(       a  UR                  U l        OXl        X`l        / U l        U R!                  Xx5        SU l        Uc  Xl        Xl	        Xl        gUR)                  U 5        UR%                  U5      U l        UR                  U l	        UR&                  U l        g)aI  Basic constructor.

:param parser: A BeautifulSoup object.
:param builder: A TreeBuilder.
:param name: The name of the tag.
:param namespace: The URI of this Tag's XML namespace, if any.
:param prefix: The prefix for this Tag's XML namespace, if any.
:param attrs: A dictionary of this Tag's attribute values.
:param parent: The PageElement to use as this Tag's parent.
:param previous: The PageElement that was parsed immediately before
    this tag.
:param is_xml: If True, this is an XML tag. Otherwise, this is an
    HTML tag.
:param sourceline: The line number where this tag was found in its
    source document.
:param sourcepos: The character position within `sourceline` where this
    tag was found.
:param can_be_empty_element: If True, this tag should be
    represented as <tag/>. If False, this tag should be represented
    as <tag></tag>.
:param cdata_list_attributes: A list of attributes whose values should
    be treated as CDATA if they ever show up on this tag.
:param preserve_whitespace_tags: A list of tag names whose contents
    should have their whitespace preserved.
Nz%No value provided for new tag's name.F)parser_classr^  r   r-   r.   r,   store_line_numbers
sourceline	sourceposcdata_list_attributes$_replace_cdata_list_attribute_valuesdictr{   r|   r   rh   ri   hiddencan_be_empty_elementpreserve_whitespace_tagsset_up_substitutions)r   parserbuilderr-   r.   r,   r   rc   r   r{   r  r  r  r  r  s                  r   __init__Tag.__init__,  s;   > > $D !' 0 0D<DEE	"G66'9+@(O&N=E"w'D'DDDIIu& UKE $^^DN#N


6$? )=%)>&,D) ((. )0(D(DT(JD% *1)F)FD& -4,L,LD)r   r  c                    [        U 5      " SU R                  U R                  U R                  U R                  U R
                  U R                  U R                  U R                  U R                  U R                  U R                  S9nS H  n[        X[        X5      5        M     U R                   H"  nUR                  UR!                  5       5        M$     U$ )zpA 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)r{   r  r  r  r  r  )r  r  )rT  r  r-   r.   r,   r   rv   r  r  r  r  r  r   r   rh   r   rU  )r   cloner   r   s       r   rU  Tag.__copy__  s     T
$,,		4>>KKDLL$..!%!:!:"&"<"<%)%B%B
 7DE!45 7]]ELL)* #r   c                 X    [        U R                  5      S:H  =(       a    U R                  $ )a  Is 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   rh   r  r}   s    r   is_empty_elementTag.is_empty_element  s#     4==!Q&D4+D+DDr   c                     [        U R                  5      S:w  a  gU R                  S   n[        U[        5      (       a  U$ UR                  $ )a  Convenience property to get the single string within this
PageElement.

TODO It might make sense to have NavigableString.string return
itself.

:return: If this element has a single string child, return
 value is that string. If this element has one child tag,
 return value is the 'string' attribute of the child tag,
 recursively. If this element is itself a string, has no
 children, or has more than one child, return value is None.
rU   Nr   )r   rh   rl   r   r  )r   r   s     r   r  
Tag.string  sB     t}}"a e_--L||r   c                 d    U R                  5         U R                  UR                  U5      5        g)z2Replace this PageElement's contents with `string`.N)clearr   r^  r   r  s     r   r  r    s$     	

F$$V,-r   Fc              #      #    U R                    H[  nUc  [        U[        5      (       a  Ub  [        U5      U;  a  M/  U(       a!  UR	                  5       n[        U5      S:X  a  MW  Uv   M]     g7f)a  Yield all strings of certain classes, possibly stripping them.

:param strip: If True, all strings will be stripped before being
    yielded.

:types: A tuple of NavigableString subclasses. Any strings of
    a subclass not found in this list will be ignored. By
    default, this means only NavigableString and CData objects
    will be considered. So no comments, processing instructions,
    etc.

:yield: A sequence of strings.
Nr   )descendantsrl   r   rT  stripr   )r   r  types
descendants       r   _all_stringsTag._all_strings  sc      **Jz*o'N'N"tJ'7u'D'--/
z?a' +s   A-A/c              #   D   #    U R                  S5       H  nUv   M	     g7f)zbYield all strings in the document, stripping them first.

:yield: A sequence of stripped strings.
TN)r  r  s     r   stripped_stringsTag.stripped_strings  s!      ''-FL .s    rE   c                 h    UR                  U R                  X#S9 Vs/ s H  oDPM     sn5      $ s  snf )a  Get all child strings, concatenated using the given separator.

:param separator: Strings will be concatenated using this separator.

:param strip: If True, strings will be stripped before being
    concatenated.

:types: A tuple of NavigableString subclasses. Any strings of
    a subclass not found in this list will be ignored. By
    default, this means only NavigableString and CData objects
    will be considered. So no comments, processing instructions,
    stylesheets, etc.

:return: A string.
)r  )joinr  )r   	separatorr  r  ro   s        r   get_textTag.get_text  sH    " ~~$*;*; +< +( ) +(Qq +( ) * 	* )s   /c                     U R                  5         U nUb<  UR                  nUR                  R                  5         / Ul        SUl        UnUb  M;  gg)a^  Recursively destroys this PageElement and its children.

This element will be removed from the tree and wiped out; so
will everything beneath it.

The behavior of a decomposed PageElement is undefined and you
should never use one for anything, but if you need to _check_
whether an element has been decomposed, you can use the
`decomposed` property.
NT)r   re   __dict__r  rh   r%  )r   r  ns      r   	decomposeTag.decompose  sJ     	mAJJAJ AMA mr   c                     U(       aN  U R                   SS  H:  n[        U[        5      (       a  UR                  5         M*  UR	                  5         M<     gU R                   SS  H  nUR	                  5         M     g)zWipe out all children of this PageElement by calling extract()
   on them.

:param decompose: If this is True, decompose() (a more
    destructive method) will be called instead of extract().
N)rh   rl   r   r  r   )r   r  r  s      r   r  	Tag.clear  s\     ==+gs++%%'OO%	 ,  ==+! ,r   c                    / n[        U R                  5       H  u  p#[        U[        5      (       a  UR	                  5         U[        U R                  5      S-
  :X  a  MH  U R                  US-      n[        U[        5      (       d  Mq  [        U[        5      (       d  M  [        U[        5      (       a  M  [        U[        5      (       a  M  UR                  U5        M     [        U5       HR  nU R                  U   nU R                  US-      nUR                  5         [        X4-   5      nUR                  U5        MT     g)zSmooth 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.
rU   N)	enumeraterh   rl   r   smoothr   r   rm  r   r   r   r   )r   markedr  abr  s         r   r  
Tag.smooth-  s     dmm,DA!S!!
C&q(( ac"A1o..q/22"1&899"1&899a  -& &!Aa Aac"AIIK$ANN1 "r   c                 d    [        U R                  5       H  u  p#X1L d  M  Us  $    [        S5      e)zFind the index of a child by identity, not value.

Avoids issues with tag.contents.index(element) getting the
index of equal elements.

:param element: Look for this PageElement in `self.contents`.
zTag.index: element not in tag)r  rh   r   )r   r  r  r   s       r   r   	Tag.indexS  s2     "$--0HA 1 899r   c                 8    U R                   R                  X5      $ )zyReturns the value of the 'key' attribute for the tag, or
the value given for 'default' if it doesn't have that
attribute.)r   get)r   keydefaults      r   r  Tag.get`  s     zz~~c++r   c                 X    U R                  X5      n[        U[        5      (       d  U/nU$ )zThe same as get(), but always returns a list.

:param key: The attribute to look for.
:param default: Use this value if the attribute is not present
    on this PageElement.
:return: A list of values, probably containing only a single
    value.
)r  rl   r   )r   r  r  rP  s       r   get_attribute_listTag.get_attribute_listf  s+     &%&&GEr   c                     XR                   ;   $ )z<Does this PageElement have an attribute with the given name?r   r   r  s     r   has_attrTag.has_attrt  s    jj  r   c                 4    [        U 5      R                  5       $ r   )r*   __hash__r}   s    r   r  Tag.__hash__x  s    4y!!##r   c                      U R                   U   $ )zitag[key] returns the value of the 'key' attribute for the Tag,
and throws an exception if it's not there.r  r  s     r   __getitem__Tag.__getitem__{  s     zz#r   c                 ,    [        U R                  5      $ )z0Iterating over a Tag iterates over its contents.iterrh   r}   s    r   __iter__Tag.__iter__  s    DMM""r   c                 ,    [        U R                  5      $ )z:The length of a Tag is the length of its list of contents.)r   rh   r}   s    r   __len__Tag.__len__  s    4==!!r   c                     XR                   ;   $ r   )rh   )r   r   s     r   __contains__Tag.__contains__  s    MM!!r   c                     g)z-A tag is non-None even if it has no contents.Tr2   r}   s    r   __bool__Tag.__bool__  s    r   c                      X R                   U'   g)zCSetting tag[key] sets the value of the 'key' attribute for the
tag.Nr  )r   r  rP  s      r   __setitem__Tag.__setitem__  s      

3r   c                 <    U R                   R                  US5        g)z;Deleting tag[key] deletes all 'key' attributes for the tag.N)r   popr  s     r   __delitem__Tag.__delitem__  s    

sD!r   c                 &    U R                   " U0 UD6$ )zCalling 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   r   r   s      r   __call__Tag.__call__  s     }}d-f--r   c                 N   [        U5      S:  aL  UR                  S5      (       a6  USS n[        R                  " S[	        US9-  5        U R                  U5      $ UR                  S5      (       d  US:X  d  U R                  U5      $ [        S	U R                  < S
U< S	35      e)zACalling tag.subtag is the same as calling tag.find(name="subtag")   r   Nz.%(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-   __rh   r[  r\  )	r   endswithwarningswarnr  find
startswithr]  r^  )r   r   tag_names      r   r_  Tag.__getattr__  s     s8a<CLL//3BxHMM _  bf!b 
 99X&&%%cZ.?99S>!37>>3GI 	Ir   c                 r   XL a  g[        US5      (       an  [        US5      (       a]  [        US5      (       aL  U R                  UR                  :w  d2  U R                  UR                  :w  d  [        U 5      [        U5      :w  a  g[	        U R
                  5       H  u  p#X1R
                  U   :w  d  M    g   g)zqReturns true iff this Tag has the same name, the same attributes,
and the same contents (recursively) as `other`.Tr-   r   rh   F)r   r-   r   r   r  rh   )r   otherr  my_childs       r   __eq__
Tag.__eq__  s     =v&&w''z**II#JJ%++%IU#$T]]3KA>>!,, 4 r   c                     X:X  + $ )zLReturns true iff this Tag is not identical to `other`,
as defined in __eq__.r2   )r   r  s     r   __ne__
Tag.__ne__  s       r   c                 Z    [         (       a  U R                  5       $ U R                  U5      $ )zRenders this PageElement as a string.

:param encoding: The encoding to use (Python 2 only).
:return: Under Python 2, a bytestring; under Python 3,
    a Unicode string.
PY3KdecoderI   rG   s     r   __repr__Tag.__repr__  s&     4;;= 
 ;;x((r   c                 "    U R                  5       $ )z-Renders this PageElement as a Unicode string.)r  r}   s    r   __unicode__Tag.__unicode__  s    {{}r   c                 X    [         (       a  U R                  5       $ U R                  5       $ )zRenders this PageElement as a generic string.

:return: Under Python 2, a UTF-8 bytestring; under Python 3,
    a Unicode string.        
r
  r}   s    r   __str__Tag.__str__  s!     4;;= ;;= r   rk  xmlcharrefreplacec                 H    U R                  X!U5      nUR                  X5      $ )a;  Render a bytestring representation of this PageElement and its
contents.

:param encoding: The destination encoding.
:param indent_level: Each line of the rendering will be
    indented this many spaces. Used internally in
    recursive calls while pretty-printing.
:param formatter: A Formatter object, or a string naming one of
    the standard formatters.
:param errors: An error handling strategy such as
    'xmlcharrefreplace'. This value is passed along into
    encode() and its value should be one of the constants
    defined by Python.
:return: A bytestring.

r  rI   )r   rH   indent_levelrp   errorsrQ  s         r   rI   
Tag.encode  s#    * KK	:xx))r   c                    [        U[        5      (       d  U R                  U5      nUR                  U 5      n/ nU H  u  pgUc  UnO[        U[        5      (       d  [        U[
        5      (       a  SR                  U5      nOJ[        U[        5      (       d  [        U5      nO)[        U[        5      (       a  Ub  UR                  U5      nUR                  U5      n	[        U5      S-   UR                  U	5      -   nUR                  U5        M     Sn
SnSnU R                  (       a  U R                  S-   nU R                  (       a  UR                  =(       d    Sn
OSU< U R                   < S3nU R#                  U5      nSnSnUb  SUS-
  -  nU(       a  UnUS-   nOSnU R%                  UX#5      nU R&                  (       a  UnU$ / nSnU(       a  SSR                  U5      -   nUb  UR                  U5        UR                  S	U< U R                   < U< U
< S35        U(       a  UR                  S
5        UR                  U5        U(       a!  U(       a  US   S
:w  a  UR                  S
5        U(       a  U(       a  UR                  U5        UR                  U5        Ub)  U(       a"  U R(                  (       a  UR                  S
5        SR                  U5      nU$ )aj  Render a Unicode representation of this PageElement and its
contents.

:param indent_level: Each line of the rendering will be
     indented this many spaces. Used internally in
     recursive calls while pretty-printing.
: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: A Formatter object, or a string naming one of
    the standard formatters.
N =rE   r)   z</rw  rU   <
rb   )rl   r   rm   
attributesr   tupler  r*   r;   rI   attribute_valuequoted_attribute_valuer   r,   r  void_element_close_prefixr-   _should_pretty_printdecode_contentsr  rf   )r   r  eventual_encodingrp   r   r   r  valdecodedr   closecloseTagr,   pretty_printspaceindent_spaceindent_contentsrh   ro   attribute_strings                       r   r  
Tag.decode   s   , )Y////	:I))$/
"HC{c4((JsE,B,B((3-C#C--c(C"3(MNN-9**%67C 005HsN66t<=  LL!% #& ;;[[3&F  77=2E ! %+DII6H00>#<!#34L E*Q.O"O''.
 ;;A4 1 A!#&%#8 ' &HHDII'7@ AHHXXb\T-AHHX'H9J9J 
Ar   c                 z    USL=(       a1    U R                   (       + =(       d    U R                  U R                   ;  $ )zpShould this tag be pretty-printed?

Most of them should, but some (such as <pre> in HTML
documents) should not.
N)r  r-   )r   r  s     r   r%  Tag._should_pretty_printe  s:     $ 111 B99D$A$AA		
r   c                 J    Uc  U R                  SUS9$ U R                  USUS9$ )aG  Pretty-print this PageElement as a string.

:param encoding: The eventual encoding of the string. If this is None,
    a Unicode string will be returned.
:param formatter: A Formatter object, or a string naming one of
    the standard formatters.
:return: A Unicode string (if encoding==None) or a bytestring 
    (otherwise).
T)rp   r  )r   rH   rp   s      r   prettifyTag.prettifys  s2     ;;ty;99;;x;CCr   c                    [        U[        5      (       d  U R                  U5      nUSLn/ nU  GH  nSn[        U[        5      (       a  UR	                  U5      nO6[        U[
        5      (       a!  UR                  UR                  XU5      5        U R                  =(       a    U R                  U R                  ;   nU(       a  U(       a  U(       d  UR                  5       nU(       d  M  U(       a  U(       d  UR                  SUS-
  -  5        UR                  U5        U(       d  M  U(       a  GM  UR                  S5        GM     SR                  U5      $ )aY  Renders the contents of this tag as a Unicode string.

:param indent_level: Each line of the rendering will be
   indented this many spaces. Used internally in
   recursive calls while pretty-printing.

: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  rU   r  rE   )rl   r   rm   r   re  r   r   r  r  r-   r  r  )	r   r  r'  rp   r,  ro   rx   r   preserve_whitespaces	            r   r&  Tag.decode_contents  s   * )Y////	:I$D0AD!_--~~i0As##,"+- . --\$))t?\?\2\   -@zz|t(;HHSL1$456<(;(;HHTN# $ wwqzr   c                 H    U R                  XU5      nUR                  U5      $ )a  Renders the contents of this PageElement as a bytestring.

:param indent_level: Each line of the rendering will be
   indented this many spaces. Used internally in
   recursive calls while pretty-printing.

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

:param formatter: A Formatter object, or a string naming one of
    the standard Formatters.

:return: A bytestring.
)r&  rI   )r   r  rH   rp   rh   s        r   encode_contentsTag.encode_contents  s%      ''	Jx((r   r   c                 2    U(       d  SnU R                  X1S9$ )z(Deprecated method for BS3 compatibility.N)r  rH   )r;  )r   rH   prettyPrintindentLevels       r   renderContentsTag.renderContents  s'     K##$ $ 9 	9r   Tc                 L    SnU R                   " XX4S40 UD6nU(       a  US   nU$ )a  Look in the children of this PageElement and find the first
PageElement that matches the given criteria.

All find_* methods take a common set of arguments. See the online
documentation for detailed explanations.

:param name: A filter on tag name.
:param attrs: A dictionary of filters on attribute values.
:param recursive: If this is True, find() will perform a
    recursive search of this PageElement's children. Otherwise,
    only the direct children will be considered.
:param limit: Stop looking after finding this many results.
:kwargs: A dictionary of filters on attribute values.
:return: A PageElement.
:rtype: bs4.element.Tag | bs4.element.NavigableString
NrU   r   r  )r   r-   r   	recursiver   r   r   r   s           r   r  Tag.find  s1    $ MM$yDVD!Ar   c                 j    U R                   nU(       d  U R                  nU R                  " XXEU40 UD6$ )a  Look in the children of this PageElement and find all
PageElements that match the given criteria.

All find_* methods take a common set of arguments. See the online
documentation for detailed explanations.

:param name: A filter on tag name.
:param attrs: A dictionary of filters on attribute values.
:param recursive: If this is True, find_all() will perform a
    recursive search of this PageElement's children. Otherwise,
    only the direct children will be considered.
:param limit: Stop looking after finding this many results.
:kwargs: A dictionary of filters on attribute values.
:return: A ResultSet of PageElements.
:rtype: bs4.element.ResultSet
)r  childrenr   )r   r-   r   rC  r   r   r   r  s           r   r  Tag.find_all  s3    $ $$	I~~d4	LVLLr   c                 ,    [        U R                  5      $ )z[Iterate over all direct children of this PageElement.

:yield: A sequence of PageElements.
r  r}   s    r   rF  Tag.children  s     DMM""r   c              #      #    [        U R                  5      (       d  gU R                  5       R                  nU R                  S   nX!La  Uv   UR                  nX!La  M  gg7f)zpIterate over all children of this PageElement in a
breadth-first sequence.

:yield: A sequence of PageElements.
Nr   )r   rh   r   re   )r   stopNodecurrents      r   r  Tag.descendants
  sY      4==!!((*77--"%M**G %s   AA#!A#c                 D    U R                   " XS40 UD6nU(       a  US   $ g)a  Perform a CSS selection operation on the current element.

:param selector: 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 kwargs: Keyword arguments to be passed into SoupSieve's 
   soupsieve.select() method.

:return: A Tag.
:rtype: bs4.element.Tag
rU   r   N)select)r   selector
namespacesr   rP  s        r   
select_oneTag.select_one  s(      H!>v>8Or   c                     Uc  U R                   nUc  Sn[        c  [        S5      e[        R                  " XX#40 UD6n[	        SU5      $ )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: Keyword arguments to be passed into SoupSieve's 
   soupsieve.select() method.

:return: A ResultSet of Tags.
:rtype: bs4.element.ResultSet
Nr   zLCannot execute CSS selectors because the soupsieve package is not installed.)_namespaces	soupsieveNotImplementedErrorrO  r  )r   rP  rQ  r   r   r  s         r   rO  
Tag.select/  s]    ( ))J=E%^  ""8:OO w''r   c                     U R                   $ zDeprecated generator.)rF  r}   s    r   childGeneratorTag.childGeneratorT  s    }}r   c                     U R                   $ rZ  )r  r}   s    r   recursiveChildGeneratorTag.recursiveChildGeneratorX  s    r   c                 V    [         R                  " SU-  5        U R                  U5      $ )zDeprecated method. 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  s     r   has_keyTag.has_key\  s*     	J 	}}S!!r   )r   r  r  rh   r  r|   r-   r.   r  r,   r  r  r  )NNNNNNNNNNNNNN)Fr   )r#   )Nrk  r3   )Br4   r5   r6   r7   r8   r  r   parserClassrU  r   r  isSelfClosingr  r   r   rr  r  stringsr  r  getTextr   r  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r_  r  r  r  r  r  r  rO  rI   r  r%  r5  r&  r;  r@  r  	findChildr  findAllfindChildrenrF  r  rR  rO  r[  r^  ra  r9   r2   r   r   r   r   $  s!    HL@D9=BF*.	^M@ (K$ E E %M ( ]]. .
 "'.F 4 |$G  "$5'/*& GHD(""$L:,!$
#"" 
".I$"!
) 	! (((5 I)*0 #'!8"cJ
D ,0)@!*,^  *A)( '>#(a9 B$T . I dM, GL # # + +*"(J "r   r   c                   V    \ rS rSrSrS0 S4S jrS rS rS0 4S jr\r	S r
SS	 jrS
rg)r  ig  a  Encapsulates a number of ways of matching a markup element (tag or
string).

This is primarily used to underpin the find_* methods, but you can
create one yourself and pass it in as `parse_only` to the
`BeautifulSoup` constructor, to parse a subset of a large
document.
Nc                    U R                  U5      U l        [        U[        5      (       d  X$S'   SnSU;   a  US   US'   US	 U(       a+  U(       a"  UR	                  5       nUR                  U5        OUn0 n[        UR                  5       5       H  u  pgU R                  U5      XV'   M     XPl        U R                  U5      U l	        g)aq  Constructor.

The SoupStrainer constructor takes the same arguments passed
into the find_* methods. See the online documentation for
detailed explanations.

:param name: A filter on tag name.
:param attrs: A dictionary of filters on attribute values.
:param text: A filter for a NavigableString with specific text.
:kwargs: A dictionary of filters on attribute values.
classNclass_)
_normalize_search_valuer-   rl   r  copyupdater   itemsr   r   )r   r-   r   r   r   normalized_attrsr  rP  s           r   r  SoupStrainer.__init__q  s     006	%&& $7OEv %X.F7Ox 

V$u{{}-JC$($@$@$G! . &
006	r   c                 8   [        U[        5      (       d>  [        U[        5      (       d)  [        US5      (       d  [        U[        5      (       d  Uc  U$ [        U[
        5      (       a  UR                  S5      $ [        US5      (       a{  / nU Hq  n[        US5      (       a=  [        U[
        5      (       d(  [        U[        5      (       d  UR                  U5        MQ  UR                  U R                  U5      5        Ms     U$ [        [        U5      5      $ )NrQ   utf8r  )	rl   r*   r   r   boolbytesr  r   rn  )r   rP  	new_valuevs       r   rn  $SoupStrainer._normalize_search_value  s     uc""j&A&AWUT[E\E\%&&%-L eU##<<'' 5*%%IAz**:a3G3G&q#.. $$Q'$$T%A%A!%DE  
 3u:r   c                 v    U R                   (       a  U R                   $ U R                  < SU R                  < 3$ )z5A human-readable representation of this SoupStrainer.|)r   r-   r   r}   s    r   r  SoupStrainer.__str__  s&    9999"ii44r   c                    SnSn[        U[        5      (       a  UnUn[        U R                  [        5      (       a3  U(       a,  UR                  (       d  U R                  UR                  :w  a  g[        U R                  [
        5      =(       a    [        U[        5      (       + nU R                  (       aU  U(       dN  U(       a   U R                  X@R                  5      (       d'  U(       d  U R                  XR                  5      (       a  U(       a  U R                  X5      nOSnSn[        U R                  R                  5       5       H\  u  pU(       d%  [        US5      (       a  UnO0 nU H	  u  pXU
'   M     UR                  U5      nU R                  X5      (       a  MZ  Sn  O   U(       a  U(       a  UnOUnU(       a>  U R                  (       a-  U R                  UR                  U R                  5      (       d  SnU$ )a~  Check whether a Tag with the given name and attributes would
match this SoupStrainer.

Used prospectively to decide whether to even bother creating a Tag
object.

:param markup_name: A tag name as found in some markup.
:param markup_attrs: A dictionary of attributes as found in some markup.

:return: True if the prospective tag would match this SoupStrainer;
    False otherwise.
NFTr  )rl   r   r-   r*   r,   r   _matchesr   r   rq  r   r  r   r  )r   markup_namemarkup_attrsr  markupcall_function_with_tag_datarQ   markup_attr_mapr   match_againstkry  
attr_values                r   
search_tagSoupStrainer.search_tag  s}    k3'' F!Ldii%% fmm		V[[0H tyy(+ 1{C00 	$ *4==;;t}}[))DD*		+<"&+/

0@0@0B+C'D*"<77.:O.0O(456 2 )5!0!4!4T!:J==CC % ,D "E'ETYYt}}U\\499'M'MEr   c                    Sn[        US5      (       aY  [        U[        [        45      (       d>  U H5  n[        U[        5      (       d  M  U R                  U5      (       d  M2  Un  U$     U$ [        U[        5      (       aF  U R                  (       a"  U R                  (       d  U R                  (       a  U R                  U5      nU$ [        U[        5      (       d  [        U[        5      (       aF  U R                  (       d3  U R                  (       d"  U R                  XR                  5      (       a  UnU$ [        SUR                  -  5      e)zFind all items in `markup` that match this SoupStrainer.

Used by the core _find_all() method, which is ultimately
called by all find_* methods.

:param markup: A PageElement or a list of them.
Nr  z&I don't know how to match against a %s)r   rl   r   r*   r   rP   r   r-   r   r  r  	Exceptionr^  )r   r  r  r  s       r   rP   SoupStrainer.search  s     6:&&z&3*/M/M!g77;;w//#E % "$  $$99		TZZ/  00FC((99TZZDMM&))4T4T  86;K;KKM Mr   c                 "   Sn[        U[        5      (       d  [        U[        5      (       aI  U H  nU R                  XR5      (       d  M    g   U R                  SR	                  U5      U5      (       a  ggUSL a  US L$ [        U[
        5      (       a  U" U5      $ Un[        U[        5      (       a  UR                  nU R                  U5      nUc  U(       + $ [        US5      (       a  [        U[        5      (       dk  U(       d
  [        5       nU HS  nUR                  (       a  UnO[        U5      nXs;   a  M)  UR                  U5        U R                  XeU5      (       d  MS    g   gSnU(       d  [        U[        5      (       a  X:H  nU(       d"  [        US5      (       a  UR                  U5      $ U(       dR  [        U[        5      (       a=  UR                   (       a,  U R                  UR                   S-   UR                  -   U5      $ U$ )NFTr  r  rP   r)   )rl   r   r!  r  r  r   r   r-   rn  r   r*   setr  idaddrP   r,   )	r   r  r  already_triedr  itemoriginal_markupr  rQ   s	            r   r  SoupStrainer._matches  s   fd##z&%'@'@ ==55  }}SXXf-}==D %%mX.. (( !fc""[[F --f5>$$$M:..}c22 ! #%==CT(C'!%%c*}}_MJJ# &  M377+E99 ''//?C00&&==&&,/C/CC]  r   )r   r-   r   r   )r4   r5   r6   r7   r8   r  rn  r  r  	searchTagrP   r  r9   r2   r   r   r  r  g  s@     ! $7L<5 &* :z IBPr   r  c                   6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )r  io  zPA ResultSet is just a list that keeps track of the SoupStrainer
that created it.c                 8   > [         [        U ]  U5        Xl        g)zTConstructor.

:param source: A SoupStrainer.
:param result: A list of PageElements.
N)superr  r  source)r   r  r  r^  s      r   r  ResultSet.__init__r  s     	i'/r   c                     [        SU-  5      e)z7Raise a helpful exception to explain a common code fix.zResultSet object has no attribute '%s'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?rj  r  s     r   r_  ResultSet.__getattr__{  s"     p  sv  v
 	
r   )r  )r2   )	r4   r5   r6   r7   r8   r  r_  r9   __classcell__)r^  s   @r   r  r  o  s    
 
r   r  ).__license__collections.abcr   ImportErrorecollectionsr[   sysr  rV  r  bs4.formatterr   r   r   rO  version_infor  r\   nonwhitespace_rewhitespace_rer   r  rF   r*   r&   r;   r?   rL   objectr_   r   rm  rr  ru  ry  r|  r~  r  r  r  r  r   r  r   r  r2   r   r   <module>r     s  %( 
 
   " a::f%  

6"	2   !   # .HC H E *A E A:Q& QhGJc; GJT0 06 
. 4 
  $   :	 		_ 		_ 	@"+ @"FE6 EP
 
SC  %$$%  IMMO s.   D= E =EEEE<E77E<