
    Mh                     F   d Z dZdZdZdZg dZddlmZ ddlZddl	Z	ej
        j        d	k     r ed
          ddlmZmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z& ddl'm(Z( ddl)m*Z*m+Z+ ddl,m-Z-m.Z.mZ/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6 ddl7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z> ddl?m@Z@mAZAmBZB ddlCmDZDmEZEmFZFmGZGmHZH  G d de%          ZIeIZJeIZK G d deI          ZLeMdk    r3ddlZ eIejN                  ZO ePeOQ                                           dS dS )af  Beautiful Soup Elixir and Tonic - "The Screen-Scraper's Friend".

http://www.crummy.com/software/BeautifulSoup/

Beautiful Soup uses a pluggable XML or HTML parser to parse a
(possibly invalid) document into a tree representation. Beautiful Soup
provides methods and Pythonic idioms that make it easy to navigate,
search, and modify the parse tree.

Beautiful Soup works with Python 3.7 and up. It works better if lxml
and/or html5lib is installed, but they are not required.

For more than you ever wanted to know about Beautiful Soup, see the
documentation: http://www.crummy.com/software/BeautifulSoup/bs4/doc/
z*Leonard Richardson (leonardr@segfault.org)z4.13.4z*Copyright (c) 2004-2025 Leonard RichardsonMIT)!AttributeResemblesVariableWarningBeautifulSoupCommentDeclarationProcessingInstruction	ResultSetCSSScript
StylesheetTagTemplateStringElementFilterUnicodeDammitCDataDoctypeFeatureNotFoundParserRejectedMarkupStopParsingr   GuessedAtParserWarningMarkupResemblesLocatorWarningUnusualUsageWarningXMLParsedAsHTMLWarning    )CounterN   zYou are trying to use a Python 3-specific version of Beautiful Soup under Python 2. This will not work. The final version of Beautiful Soup to support Python 2 was 4.9.3.   )builder_registryTreeBuilder)HTMLParserTreeBuilder)r   )r	   )_deprecated)r   r   DEFAULT_OUTPUT_ENCODINGr   r   NavigableStringPageElementr   PYTHON_SPECIFIC_ENCODINGSr   r
   r   r   r   )	Formatter)r   SoupStrainer)
Anycastr   DictIteratorListSequenceOptionalTypeUnion)	_Encoding
_Encodings_IncomingMarkup_InsertableElement_RawAttributeValue_RawAttributeValues
_RawMarkup)r   r   r   )r   r   r   r   r   c                   p    e Zd ZU dZdZeed<   ddgZee         ed<   dZ	eed<   e
ee         ee         f         ed	<   eed
<   eed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   eed<   	 	 	 	 	 	 	 dWdedeeeee         f                  d
eeeee         f                  dee         dee         dee         d	ee
ee         ee         f                  defdZdXd!Zd e
eef         fd"Zd#e
eef         d dfd$Ze ed%d&'          ded efd(                        Z eded efd)            Z!eded efd*            Z"dYd+Z#dYd,Z$	 	 	 	 	 	 dZd-ed.ee         d/ee         d0ee%         d1ee&         d2ee&         d3ee         d4e'd efd5Z(	 d[d6eee)                  d ee)         fd7Z*	 d[d8ed9eee)                  d e)fd:Z+d;e,d ee         fd<Z-d;e,d ee         fd=Z.d ee         fd>Z/d?ed dfd@Z0d[dAeee)                  d dfdBZ1	 	 d\dCedDee         dEee         d dfdFZ2dGed dfdHZ3	 d]d-ed/ee         dJed ee         fdKZ4	 	 	 d^d-ed.ee         d/ee         d0e%d1ee&         d2ee&         dLee
eef                  d ee         fdMZ5d[d-ed/ee         d dfdNZ6dOed dfdPZ7de8dQdfdRee&         dSedTee9ef         dUee:e                  ded ef fdVZ; xZ<S )_r   a  A data structure representing a parsed HTML or XML document.

    Most of the methods you'll call on a BeautifulSoup object are inherited from
    PageElement or Tag.

    Internally, this class defines the basic interface called by the
    tree builders when converting an HTML/XML document into a data
    structure. The interface abstracts away the differences between
    parsers. To write a new tree builder, you'll need to understand
    these methods as a whole.

    These methods will be called by the BeautifulSoup constructor:
      * reset()
      * feed(markup)

    The tree builder may call these methods from its feed() implementation:
      * handle_starttag(name, attrs) # See note about return value
      * handle_endtag(name)
      * handle_data(data) # Appends to the current data node
      * endData(containerClass) # Ends the current data node

    No matter how complicated the underlying parser is, you should be
    able to build a tree using 'start tag' events, 'end tag' events,
    'data' events, and "done with data" events.

    If you encounter an empty-element tag (aka a self-closing tag,
    like HTML's <br> tag), call handle_starttag and then
    handle_endtag.
    z
[document]ROOT_TAG_NAMEhtmlfastDEFAULT_BUILDER_FEATURESz 
	ASCII_SPACESelement_classesbuilderis_xml	known_xml
parse_onlymarkupcurrent_data
currentTagtagStackopen_tag_counterpreserve_whitespace_tag_stackstring_container_stack_most_recent_elementoriginal_encodingdeclared_html_encodingcontains_replacement_characters Nfeaturesfrom_encodingexclude_encodingskwargsc                 "
   dv rd= t          j        d           dv rd= t          j        d           dv rd= t          j        d           dv rd= t          j        d           d	v rd	= t          j        d
           dt          dt          dt          t                   ffd}	|p |	dd          }|&|j        rt          j        d| t          d           |p |	dd          }|r+t          |t                    rt          j        d           d}|pt                      | _	        |}
|}t          |t                    r|}d}nm|kt          |t                    r|g}|t          |          dk    r| j        }t          j        | }|%t          dd                    |          z            |}| |d3i }|
s||j        k    s t          |t                    r	||j        v s|r|j        rd}nd}d}	 t)          j        d          }n# t,          $ r Y nw xY w|r|j        }|j        }nt(          j        }d}|                    d          }|r3|                                }|                    d          r
|dd          }|rAt          |||j        |!          }t          j        t:          j        |z  t:          d"           nrt          j        d#           || _        |j        | _        | j        | _         t                      | _!        || _"        tG          |d$          r|$                                }nt          |tJ          t          f          s#tG          |d%          stM          d&|d'          t          |          d(k    rdt          |tJ                    rd)|vrd*|vst          |t                    r2d+|vr.d,|vr*| '                    |          s| (                    |           tS          tT          |          }g }d-}| j        +                    |||.          D ]\  | _,        | _-        | _.        | _/        | 0                                 | j        1                    |            	 | 2                                 d/} n,# tf          $ r}|4                    |           Y d}~d}~ww xY w|s1d0 |D             }tg          d1d2                    |          z             d| _,        d| j        _5        dS )4a	  Constructor.

        :param markup: A string or a file-like object representing
         markup to be parsed.

        :param features: Desirable features of the parser to be
         used. This may be the name of a specific parser ("lxml",
         "lxml-xml", "html.parser", or "html5lib") or it may be the
         type of markup to be used ("html", "html5", "xml"). It's
         recommended that you name a specific parser, so that
         Beautiful Soup gives you the same results across platforms
         and virtual environments.

        :param builder: A TreeBuilder subclass to instantiate (or
         instance to use) instead of looking one up based on
         `features`. You only need to use this if you've implemented a
         custom TreeBuilder.

        :param parse_only: A SoupStrainer. Only parts of the document
         matching the SoupStrainer will be considered. This is useful
         when parsing part of a document that would otherwise be too
         large to fit into memory.

        :param from_encoding: A string indicating the encoding of the
         document to be parsed. Pass this in if Beautiful Soup is
         guessing wrongly about the document's encoding.

        :param exclude_encodings: A list of strings indicating
         encodings known to be wrong. Pass this in if you don't know
         the document's encoding but you know Beautiful Soup's guess is
         wrong.

        :param element_classes: A dictionary mapping BeautifulSoup
         classes like Tag and NavigableString, to other classes you'd
         like to be instantiated instead as the parse tree is
         built. This is useful for subclassing Tag or NavigableString
         to modify default behavior.

        :param kwargs: For backwards compatibility purposes, the
         constructor accepts certain keyword arguments used in
         Beautiful Soup 3. None of these arguments do anything in
         Beautiful Soup 4; they will result in a warning and then be
         ignored.

         Apart from this, any keyword arguments passed into the
         BeautifulSoup constructor are propagated to the TreeBuilder
         constructor. This makes it possible to configure a
         TreeBuilder by passing in arguments, not just by saying which
         one to use.
        convertEntitieszBS4 does not respect the convertEntities argument to the BeautifulSoup constructor. Entities are always converted to Unicode characters.markupMassagezBS4 does not respect the markupMassage argument to the BeautifulSoup constructor. The tree builder is responsible for any necessary markup massage.smartQuotesTozBS4 does not respect the smartQuotesTo argument to the BeautifulSoup constructor. Smart quotes are always converted to Unicode characters.selfClosingTagszBeautiful Soup 4 does not respect the selfClosingTags argument to the BeautifulSoup constructor. The tree builder is responsible for understanding self-closing tags.isHTMLzBeautiful Soup 4 does not respect the isHTML argument to the BeautifulSoup constructor. Suggest you use features='lxml' for HTML and features='lxml-xml' for XML.old_namenew_namereturnc                     | v r8t          j        d| d|dt          d                               |           S d S )NzThe "z<" argument to the BeautifulSoup constructor was renamed to "z" in Beautiful Soup 4.0.0r   
stacklevel)warningswarnDeprecationWarningpop)rX   rY   rQ   s     L/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/bs4/__init__.pydeprecated_argumentz3BeautifulSoup.__init__.<locals>.deprecated_argument7  s^    6!!  xx+ '     zz(+++4    parseOnlyTheserA   Nz8The given value for parse_only will exclude everything: r   r\   fromEncodingrO   zlYou provided Unicode markup but also provided a value for from_encoding. Your from_encoding will be ignored.r   zjCouldn't find a tree builder with the features you requested: %s. Do you need to install a parser library?,XMLHTMLr   __file__)z.pycz.pyo)filenameline_numberparsermarkup_type   zKeyword arguments to the BeautifulSoup constructor will be ignored. These would normally be passed into the TreeBuilder constructor, but a TreeBuilder instance was passed in as `builder`.read__len__z'Incoming markup is of an invalid type: z?. Markup must be a string, a bytestring, or an open filehandle.      <   
<
F)rP   Tc                 ,    g | ]}t          |          S  )str).0es     rb   
<listcomp>z*BeautifulSoup.__init__.<locals>.<listcomp>  s    ;;;1A;;;rd   zThe markup you provided was rejected by the parser. Trying a different parser or a different encoding may help.

Original exception(s) from parser:
 z
 ry   )6r^   r_   rz   r-   r'   excludes_everythingUserWarning
isinstancedictr=   typelenr;   r   lookupr   joinNAMEALTERNATE_NAMESr?   sys	_getframe
ValueError	f_globalsf_lineno__dict__getlowerendswithr   MESSAGEr>   r@   _namespacesrA   hasattrrq   bytes	TypeError_markup_is_url_markup_resembles_filenamer(   r6   prepare_markuprB   rJ   rK   rL   resetinitialize_soup_feedr   appendsoup)selfrB   rN   r>   rA   rO   rP   r=   rQ   rc   original_builderoriginal_featuresbuilder_classpossible_builder_classro   callerglobalsrm   rl   fnlvalues
rejectionssuccessr|   other_exceptionss           `                rb   __init__zBeautifulSoup.__init__   s   z &&()M)   f$$'M4   f$$'M)   &&()M7   vx M  
	# 
	 
	# 
	 
	 
	 
	 
	 
	  V#6#67G#V#V
! - [z[[     & 
)<)<O*
 *
  	!Z44 	!M~   !M.8$&&
 #$ gt$$ 	3#MGG_(C(( &$:3x==A#5#58%5%<h%G"%-%Nhhx(()  
 3M
 ?#m--f--G$2 &55"#4c:: 6 .1HHH  I > )"'KK"(K
  ]1--FF!   D $$.G"(/KK!lG"#K";;z22 1"..**C||$455 1#+CRC=  "!)$/&|$/	  F M.6?.#$      R   n66$66"" 	8[[]]FFFUCL11 	8'&):T:T 	8 D&  D  D  D   [[C&&  +/v+=+=%vBUBU63'' CV,/v,=,=$fBTBT &&v.. 8//777 j&))
 \((M5F ) 
 
	 	 
K"'0 JJLLLL((...

'   !!!$$$  	;;
;;;& k**-../    s*   	H 
H+*H+R
S'SSrZ   c                 \     t          |           dd| j                  }| j        |_        |S )zCreate a new BeautifulSoup object with the same TreeBuilder,
        but not associated with any markup.

        This is the first step of the deepcopy process.
        rM   N)r   r>   rJ   )r   clones     rb   	copy_selfzBeautifulSoup.copy_self  s1     T

2tT\22 #'"8rd   c                     t          | j                  }d|v r+|d         #| j        j        st	          | j                  |d<   g |d<   |                                 |d<   d|v r|d= |S )Nr>   contentsrB   rI   )r   r   r>   	picklabler   decode)r   ds     rb   __getstate__zBeautifulSoup.__getstate__  su    >>a	l6t|?U6--AiL*kkmm(
 "Q&&()rd   statec                    || _         t          | j        t                    r|                                 | _        n| j        st	                      | _        | | j        _        |                                  |                                  d S N)r   r   r>   r   r   r   r   r   )r   r   s     rb   __setstate__zBeautifulSoup.__setstate__	  so    dlD)) 	3<<>>DLL 	3 122DL 



rd   z)nothing (private method, will be removed)z4.13.0)replaced_byversionc                 b    t          |t                    r|                    dd          }n|}|S )a  Ensure `markup` is Unicode so it's safe to send into warnings.warn.

        warnings.warn had this problem back in 2010 but fortunately
        not anymore. This has not been used for a long time; I just
        noticed that fact while working on 4.13.0.
        zutf-8replace)r   r   r   )clsrB   decodeds      rb   _decode_markupzBeautifulSoup._decode_markup  s5     fe$$ 	mmGY77GGGrd   c                 Z   d}t          t                    r t          fddD                       odv}n7t          t                    r t          fddD                       odv}ndS |sdS t	          j        t          j        t          d	          z  t          d
           dS )zError-handling method to raise a warning if incoming markup looks
        like a URL.

        :param markup: A string of markup.
        :return: Whether or not the markup resembled a URL
            closely enough to justify issuing a warning.
        Fc              3   B   K   | ]}                     |          V  d S r   
startswithr{   prefixrB   s     rb   	<genexpr>z/BeautifulSoup._markup_is_url.<locals>.<genexpr>3  s1      RR&F%%f--RRRRRRrd   )s   http:s   https:    c              3   B   K   | ]}                     |          V  d S r   r   r   s     rb   r   z/BeautifulSoup._markup_is_url.<locals>.<genexpr>8  s1      PP&F%%f--PPPPPPrd   )zhttp:zhttps: URLwhatr   r\   T)	r   r   anyrz   r^   r_   r   URL_MESSAGEr   )r   rB   problems    ` rb   r   zBeautifulSoup._markup_is_url'  s     fe$$ 	RRRR<QRRRRR '& G $$ 	PPPP<OPPPPP &v% G
 5 	5)5%8H8H8HH)	
 	
 	
 	

 trd   c                    t          |t                    r|                    d          }n|}d}|                                g d}t	          fd|D                       rd}|sdS |D ]	}|dv r dS 
d|v rdS d|v rdS |                    d	          rdS |                    d	          }|d
vrdS t          j        t          j
        t          d          z  t          d           dS )a  Error-handling method to issue a warning if incoming markup
        resembles a filename.

        :param markup: A string of markup.
        :return: Whether or not the markup resembled a filename
            closely enough to justify issuing a warning.
        utf8F)s   .htmls   .htms   .xmls   .xhtmls   .txtc              3   B   K   | ]}                     |          V  d S r   )r   )r{   extr   s     rb   r   z;BeautifulSoup._markup_resembles_filename.<locals>.<genexpr>^  s/      99su~~c""999999rd   Ts   ?*#&;>$|s   //s        :)rk   r   rl   r   r   r\   )r   rz   encoder   r   r   rfindr^   r_   r   FILENAME_MESSAGEr   )r   rB   markup_bfilelike
extensionsbytecolon_ir   s          @rb   r   z(BeautifulSoup._markup_resembles_filenameG  sM    fc"" 	}}V,,HHH   EEE
9999j99999 	H 	5  	 	D{""uu # H5H5 t$$ 	5..&&'!!5 	):Tz=R=R=RR)	
 	
 	
 	

 trd   c                 P   | j                                          | j        | j                             | j                   |                                  | j        G| j        j        | j        k    r6|                                  | j        | j        j        | j        k    0dS dS dS dS )zInternal method that parses previously set markup, creating a large
        number of Tag and NavigableString objects.
        N)	r>   r   rB   feedendDatarD   namer8   popTagr   s    rb   r   zBeautifulSoup._feed  s    
 	;"Ldk***O'DO,@DDV,V,VKKMMM O'DO,@DDV,V,V,V,V'''',V,Vrd   c                 ,   t          j        | | | j        | j                   d| _        | j                                         g | _        d| _        g | _        t                      | _
        g | _        g | _        d| _        |                     |            dS )zWReset this object to a state as though it had never parsed any
        markup.
        TN)r   r   r>   r8   hiddenr   rC   rD   rE   r   rF   rG   rH   rI   pushTagr   s    rb   r   zBeautifulSoup.reset  s     	T4t/ABBB '		-/*&(#$(!Trd   r   	namespacensprefixattrs
sourceline	sourceposstringkwattrsc           
      $    | j         j        di |}	||	                    |           | j                            t
          t
                    }
t          t          t
                   |
          }
 |
d| j         ||||	||          }|||_        |S )aD  Create a new Tag associated with this BeautifulSoup object.

        :param name: The name of the new Tag.
        :param namespace: The URI of the new Tag's XML namespace, if any.
        :param prefix: The prefix for the new Tag's XML namespace, if any.
        :param attrs: A dictionary of this Tag's attribute values; can
            be used instead of ``kwattrs`` for attributes like 'class'
            that are reserved words in Python.
        :param sourceline: The line number where this tag was
            (purportedly) found in its source document.
        :param sourcepos: The character position within ``sourceline`` where this
            tag was (purportedly) found.
        :param string: String content for the new Tag, if any.
        :param kwattrs: Keyword arguments for the new Tag's attribute values.

        N)r   r   ry   )	r>   attribute_dict_classupdater=   r   r   r(   r.   r   )r   r   r   r   r   r   r   r   r   attr_container	tag_classtags               rb   new_tagzBeautifulSoup.new_tag  s    6 ;:EEWEE!!%((((,,S#66	 cI..	iL!	
 	
 	
 CJ
rd   
base_classc                 
   |pt           }t          t          t                    | j                            ||                    }| j        r9|t           u r0| j        j                            | j        d         j        |          }|S )zFind the class that should be instantiated to hold a given kind of
        string.

        This may be a built-in Beautiful Soup class or a custom class passed
        in to the BeautifulSoup constructor.
        rk   )	r"   r(   r.   r=   r   rH   r>   string_containersr   )r   r   	containers      rb   string_containerzBeautifulSoup.string_container  s     1/	 !4#7#;#;Iy#Q#Q
 
	 & 	9+G+G6::+B/4i I rd   ssubclassc                 B    |                      |          } ||          S )a  Create a new `NavigableString` associated with this `BeautifulSoup`
        object.

        :param s: The string content of the `NavigableString`
        :param subclass: The subclass of `NavigableString`, if any, to
               use. If a document is being processed, an appropriate
               subclass for the current location in the document will
               be determined automatically.
        )r   )r   r   r   r   s       rb   
new_stringzBeautifulSoup.new_string  s%     ))(33	y||rd   argsc                      t          d          )This method is part of the PageElement API, but `BeautifulSoup` doesn't implement
        it because there is nothing before or after it in the parse tree.
        z4BeautifulSoup objects don't support insert_before().NotImplementedErrorr   r   s     rb   insert_beforezBeautifulSoup.insert_before  s     "B
 
 	
rd   c                      t          d          )r   z3BeautifulSoup objects don't support insert_after().r   r  s     rb   insert_afterzBeautifulSoup.insert_after  s     ""WXXXrd   c                    | j         sdS | j                                         }|j        | j        v r| j        |j        xx         dz  cc<   | j        r*|| j        d         k    r| j                                         | j        r*|| j        d         k    r| j                                         | j         r| j         d         | _        | j        S )zZInternal method called by _popToTag when a tag is closed.

        :meta private:
        Nr   rk   )rE   ra   r   rF   rG   rH   rD   r   r   s     rb   r   zBeautifulSoup.popTag  s    
 } 	4m!!8t,,,!#(+++q0+++.	5t9"===.22444& 	.3$2Mb2Q+Q+Q'++---= 	0"mB/DOrd   r   c                    | j         | j         j                            |           | j                            |           | j        d         | _         |j        | j        k    r| j        |j        xx         dz  cc<   |j        | j        j        v r| j	                            |           |j        | j        j
        v r| j                            |           dS dS )z`Internal method called by handle_starttag when a tag is opened.

        :meta private:
        Nrk   r   )rD   r   r   rE   r   r8   rF   r>   preserve_whitespace_tagsrG   r   rH   r  s     rb   r   zBeautifulSoup.pushTag)  s     ?&O$++C000S!!!-+8t)))!#(+++q0+++8t|<<<.55c:::8t|555'..s33333 65rd   containerClassc                    | j         rd                    | j                   }| j        sd}|D ]}|| j        vrd} n|r	d|v rd}nd}g | _         | j        r4t          | j                  dk    r| j                            |          sdS |                     |          } ||          }| 	                    |           dS dS )zMethod called by the TreeBuilder when the end of a data segment
        occurs.

        :param containerClass: The class to use when incorporating the
        data segment into the parse tree.

        :meta private:
        rM   TFrw   r   r   N)
rC   r   rG   r<   rA   r   rE   allow_string_creationr   object_was_parsed)r   r	  rC   
strippableios         rb   r   zBeautifulSoup.endData:  s     	&774#455L 5 
+!
%  A 111%*
 2  +|++'+'* !#D &&!++>>|LL , !22>BBN|,,A""1%%%%%=	& 	&rd   r  parentmost_recent_elementc                 b   || j         }|J ||}n| j        }dx}x}}t          |t                    r|j        }|j        }|j        }||j        }|j        du}|                    |||||           || _        |j	        
                    |           |r|                     |           dS dS )zuMethod called by the TreeBuilder to integrate an object into the
        parse tree.

        :meta private:
        N)rD   rI   r   r   next_elementnext_siblingprevious_siblingprevious_elementsetupr   r   _linkage_fixer)	r   r  r  r  r  r  r  r  fixs	            rb   r  zBeautifulSoup.object_was_parsedc  s     >_F!!!*2#89===',a 	6>L>L 1'#$#5 !-	(,8H,WWW$%!q!!!  	('''''	( 	(rd   elc                    |j         d         }|j         d         }|}||u r0|j        )||_        |j        }|||urd|_        ||_        d|_        d|_        t          |t                    r/|j         r(t          t          |
                    d                    }d|_        d|_        |}	 |dS |j        |j        |_        ||j        _        dS |j        }-)z,Make sure linkage of this fragment is sound.r   rk   NF)r   r  r  r  r  r  r   r   r(   r#   _last_descendant)r   r  firstchild
descendantprev_eltargets          rb   r  zBeautifulSoup._linkage_fixer  s    AB"'
E>>bi3#BO,G"wb'8'8'+$%'E"%)E" " eS!! 	Jen 	J k5+A+A%+H+HIIJ
 #'
"&
 "	#~$0*0*=
'7<#4]F	#rd   TinclusivePopc                 P   || j         k    rdS d}t          | j                  }t          |dz
  dd          D ]m}| j                            |          s nP| j        |         }||j        k    r#||j        k    r|r|                                 } n|                                 }n|S )a  Pops the tag stack up to and including the most recent
        instance of the given tag.

        If there are no open tags with the given name, nothing will be
        popped.

        :param name: Pop up to the most recent tag with this name.
        :param nsprefix: The namespace prefix that goes with `name`.
        :param inclusivePop: It this is false, pops the tag stack up
          to but *not* including the most recent instqance of the
          given tag.

        :meta private:
        Nr   r   rk   )	r8   r   rE   rangerF   r   r   r   r   )r   r   r   r"  most_recently_popped
stack_sizer  ts           rb   	_popToTagzBeautifulSoup._popToTag  s    $ 4%%%4#''
zA~q"-- 	1 	1A(,,T22 a Aqv~~(ah"6"6 9+/;;==(#';;==  ##rd   
namespacesc                    |                                   | j        r6t          | j                  dk    r| j                            |||          sdS | j                            t          t                    }t          t          t                   |          } || | j
        ||||| j        | j        |||          }	|	|	S | j        |	| j        _        |	| _        |                     |	           |	S )a  Called by the tree builder when a new tag is encountered.

        :param name: Name of the tag.
        :param nsprefix: Namespace prefix for the tag.
        :param attrs: A dictionary of attribute values. Note that
           attribute values are expected to be simple strings; processing
           of multi-valued attributes such as "class" comes later.
        :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 namespaces: A dictionary of all namespace prefix mappings
            currently in scope in the document.

        If this method returns None, the tag was rejected by an active
        `ElementFilter`. You should proceed as if the tag had not occurred
        in the document. For instance, if this was a self-closing tag,
        don't call handle_endtag.

        :meta private:
        r   N)r   r   r)  )r   rA   r   rE   allow_tag_creationr=   r   r   r(   r.   r>   rD   rI   r  r   )
r   r   r   r   r   r   r   r)  r   r   s
             rb   handle_starttagzBeautifulSoup.handle_starttag  s    @ 	 O	DM""a''O66xuMM ( 4(,,S#66	 cI..	iLO%!!
 
 
 ;J$058D%2$'!S
rd   c                 Z    |                                   |                     ||           dS )zCalled by the tree builder when an ending tag is encountered.

        :param name: Name of the tag.
        :param nsprefix: Namespace prefix for the tag.

        :meta private:
        N)r   r(  )r   r   r   s      rb   handle_endtagzBeautifulSoup.handle_endtag  s+     	tX&&&&&rd   datac                 :    | j                             |           dS )zpCalled by the tree builder when a chunk of textual data is
        encountered.

        :meta private:
        N)rC   r   )r   r/  s     rb   handle_datazBeautifulSoup.handle_data)  s!     	  &&&&&rd   minimalindent_leveleventual_encoding	formatteriteratorc                    | j         rd}|}|t          v rd}|d|z  }d|z  }nd}d}	t          |t                    r|du rd}n|du rd}d| d	}	n/|                    d
d          }
|rJ |
|
du rd}n|
du rd}d| d	}	|	rt          j        |	t          d           n
|du s|
du rd}|t          t          |           
                    ||||          z   S )aM  Returns a string representation of the parse tree
            as a full HTML or XML document.

        :param indent_level: Each line of the rendering will be
           indented this many levels. (The ``formatter`` decides what a
           'level' means, in terms of spaces or other characters
           output.) This is used internally in recursive calls while
           pretty-printing.
        :param eventual_encoding: The encoding of the final document.
            If this is None, the document will be a Unicode string.
        :param formatter: Either a `Formatter` object, or a string naming one of
            the standard formatters.
        :param iterator: The iterator to use when navigating over the
            parse tree. This is only used by `Tag.decode_contents` and
            you probably won't need to use it.
        rM   Nz encoding="%s"z<?xml version="1.0"%s?>
Tr   FzAs of 4.13.0, the first argument to BeautifulSoup.decode has been changed from bool to int, to match Tag.decode. Pass in a value of z	 instead.pretty_printzAs of 4.13.0, the pretty_print argument to BeautifulSoup.decode has been removed, to match Tag.decode. Pass in a value of indent_level=rp   r\   )r?   r$   r   boolra   r^   r_   r`   superr   r   )r   r3  r4  r5  r6  rQ   encoding_partdeclared_encodingr   warningr8  	__class__s              rb   r   zBeautifulSoup.decode1  s   0 ; 	M/@ $=== %)! , 03D D0=@FFF "&lD)) 	|t## &&# u  ^j  u  u  uGG!::nd;;L'4''#$LL!U**#'L |  eq  |  |  | 	 M'#5!DDDDDU""le&;&;LmT2299+Y
 
 
 	
rd   )rM   NNNNNN)rZ   r   )rZ   N)NNNNNNr   )NN)NT)NNN)=__name__
__module____qualname____doc__r8   rz   __annotations__r;   r,   r<   r)   r.   r#   r   r9  r-   r&   r6   r+   r   CounterTyper0   r2   r/   r1   r'   r   r   r   r   classmethodr    r   r   r   r   r   r5   intr4   r   r"   r   r   r3   r  r  r   r   r   r  r  r(  r,  r.  r1  r!   r%   r*   r   __classcell__r>  s   @rb   r   r      s         B &M3%%% 06v.>hsm>>> /L#... ${+T+->>????LLL~&&&& Z    s)3i!#&&&&#'9,,, I%%%";////  	****
 %Y//// &*))) #%8<CG-1-126PTY! Y!Y! 5hsm!345Y! %T+-> >?@	Y!
 \*Y!  	*Y! $J/Y! "$tK'8${:K'K"LMY! Y! Y! Y! Y!v   d38n     $sCx. T     [?  J 3     [ J 4    [> @
 @t @ @ @ [@D       & $("&/3$(#' $0 00 C=0 3-	0
 +,0 SM0 C=0 0 &0 
0 0 0 0f =A "4#89	o	   4 CG  (o)> ?	   
#5 
${:K 
 
 
 
Y"4 Yk9J Y Y Y Y    .43 44 4 4 4 4"'& '&htO/D&E '&QU '& '& '& '&X !%59	%( %(%( %( &k2	%(
 
%( %( %( %(N*# *# *# *# *# *#Z OS#$ #$#$#+C=#$GK#$	##$ #$ #$ #$V %)#'/3@ @@ C=@ 3-	@
 #@ SM@ C=@ T#s(^,@ 
#@ @ @ @D
' 
'# 
'# 
'$ 
' 
' 
' 
'' ' ' ' ' ' '+'>+448F
 F
smF
 %F
 C(	F

 8K01F
 F
 
F
 F
 F
 F
 F
 F
 F
 F
 F
 F
rd   r   c                   ,     e Zd ZdZdedef fdZ xZS )BeautifulStoneSoupz&Deprecated interface to an XML parser.r   rQ   c                     d|d<   t          j        dt          d            t          t          |           j        |i | d S )NxmlrN   zThe BeautifulStoneSoup class was deprecated in version 4.0.0. Instead of using it, pass features="xml" into the BeautifulSoup constructor.rp   r\   )r^   r_   r`   r:  rJ  r   )r   r   rQ   r>  s      rb   r   zBeautifulStoneSoup.__init__  s]    "zJ		
 	
 	
 	
 	1 $''0$A&AAAAArd   )r?  r@  rA  rB  r'   r   rG  rH  s   @rb   rJ  rJ    s]        00Bc BS B B B B B B B B B Brd   rJ  __main__)RrB  
__author____version____copyright____license____all__collectionsr   r   r^   version_infomajorImportErrorr>   r   r   builder._htmlparserr   dammitr   cssr	   _deprecationr    elementr   r   r!   r   r   r"   r#   r   r$   r   r
   r   r   r   r5  r%   filterr   r&   typingr'   r(   rD  r)   r*   r+   r,   r-   r.   r/   bs4._typingr0   r1   r2   r3   r4   r5   r6   bs4.exceptionsr   r   r   bs4._warningsr   r   r   r   r   r   _s_souprJ  r?  stdinr   printprettifyry   rd   rb   <module>rf     s     :
<  <        



  A
+ 	u          7 6 6 6 6 6 ! ! ! ! ! !                                            !                                                                  
             r
 r
 r
 r
 r
C r
 r
 r
l B B B B B B B B zJJJ=##D	E4==??	 rd   