
    (phy                    X   % S SK Jr  SrS SKJr  S SKrS SKJr  S SKJ	r	J
r
JrJrJrJrJrJrJrJrJr  S SKrS SKrS SKJrJrJrJrJrJrJrJrJrJ r   S SK!J"r"  S S	K#J$r$J%r%  S S
K&J'r'  \(       a  S SK(J)r)  S SKJ*r*J+r+  S SK#J,r,J-r-J.r.J/r/J0r0  / SQr1Sr2Sr3Sr4Sr5Sr6Sr7/ SQr1 " S S\85      r9\9" 5       r:S\;S'    " S S\85      r< " S S\<5      r= " S S\<5      r> " S S \85      r?S&S! jr@S"S#KAJBrB  \@" \B5         S"S$KAJCrC  \@" \C5         S"S%KAJErE  \@" \E5        g! \D a     Nf = f! \D a     gf = f)'    )annotationsMIT)defaultdictN)
ModuleType)AnycastDictIterableListOptionalPatternSetTupleTypeTYPE_CHECKING)
AttributeDictAttributeValueListCharsetMetaAttributeValueContentMetaAttributeValueRubyParenthesisStringRubyTextString
StylesheetScriptTemplateStringnonwhitespace_re)ParserRejectedMarkup)_AttributeValues_RawAttributeValue)XMLParsedAsHTMLWarning)BeautifulSoup)NavigableStringTag)_AttributeValue	_Encoding
_Encodings_RawOrProcessedAttributeValues
_RawMarkup)HTMLTreeBuilderSAXTreeBuilderTreeBuilderTreeBuilderRegistryfast
permissivestrictxmlhtmlhtml5)r+   r*   r(   DetectsXMLParsedAsHTMLr   c                  L    \ rS rSr% SrS\S'   S\S'   SS jrSS jrSS	 jrS
r	g)r+   V   zQA way of looking up TreeBuilder subclasses by their name or by desired
features.
z"Dict[str, List[Type[TreeBuilder]]]builders_for_featurezList[Type[TreeBuilder]]buildersc                :    [        [        5      U l        / U l        g N)r   listr5   r6   selfs    G/var/www/html/venv/lib/python3.13/site-packages/bs4/builder/__init__.py__init__TreeBuilderRegistry.__init__^   s    $/$5!    c                    UR                    H"  nU R                  U   R                  SU5        M$     U R                  R                  SU5        g)zRegister a treebuilder based on its advertised features.

:param treebuilder_class: A subclass of `TreeBuilder`. its
   `TreeBuilder.features` attribute should list its features.
r   N)featuresr5   insertr6   )r;   treebuilder_classfeatures      r<   registerTreeBuilderRegistry.registerb   sE     )11G%%g.55a9JK 2Q 12r?   c                   [        U R                  5      S:X  a  g[        U5      S:X  a  U R                  S   $ [        U5      nUR                  5         SnSn[        U5      S:  aw  UR	                  5       nU R
                  R                  U/ 5      n[        U5      S:  a+  Uc  Un[        U5      nOUR                  [        U5      5      n[        U5      S:  a  Mw  Ub  Uc  gU H  nXt;   d  M
  Us  $    g)a:  Look up a TreeBuilder subclass with the desired features.

:param features: A list of features to look for. If none are
    provided, the most recently registered TreeBuilder subclass
    will be used.
:return: A TreeBuilder subclass, or None if there's no
    registered subclass with all the requested features.
r   N)	lenr6   r9   reversepopr5   getsetintersection)r;   rA   feature_list
candidatescandidate_setrD   we_have_the_feature	candidates           r<   lookupTreeBuilderRegistry.lookupl   s     t}}"x=A ==## H~
,!#"&&(G"&";";"?"?"L&'!+%!4J$'
OM %2$>$>sCV?W$XM ,!#  J$6#I)   $ r?   )r6   r5   NreturnNone)rC   ztype[TreeBuilder]rV   rW   )rA   strrV   zOptional[Type[TreeBuilder]])
__name__
__module____qualname____firstlineno____doc____annotations__r=   rE   rS   __static_attributes__ r?   r<   r+   r+   V   s$     =<%%3+r?   r+   builder_registryc                     \ rS rSr% Sr\" 5       rS\S'   \\\\\\\	4             S+S jjr
SrS\S'   / rS\S'   / rS\S'   SrS\S'   SrS\S'   S\S'   SrS\S'   S\S'   S\S'   S
\S	'   S\S'   \" \5      rS\S'   \" 5       rS\S'   0 rS\S'   SrS\S '   SrS\S!'   S,S" jrS-S# jrS.S$ jrS/S% jr   S0         S1S& jjrS2S' jrS3S( jr      S4S) jrS*r g)5r*      aZ  Turn a textual document into a Beautiful Soup object tree.

This is an abstract superclass which smooths out the behavior of
different parser libraries into a single, unified interface.

:param multi_valued_attributes: If this is set to None, the
 TreeBuilder will not turn any values for attributes like
 'class' into lists. Setting this to a dictionary will
 customize this behavior; look at :py:attr:`bs4.builder.HTMLTreeBuilder.DEFAULT_CDATA_LIST_ATTRIBUTES`
 for an example.

 Internally, these are called "CDATA list attributes", but that
 probably doesn't make sense to an end-user, so the argument name
 is ``multi_valued_attributes``.

:param preserve_whitespace_tags: A set of tags to treat
 the way <pre> tags are treated in HTML. Tags in this set
 are immune from pretty-printing; their contents will always be
 output as-is.

:param string_containers: A dictionary mapping tag names to
 the classes that should be instantiated to contain the textual
 contents of those tags. The default is to use NavigableString
 for every tag, no matter what the name. You can override the
 default by changing :py:attr:`DEFAULT_STRING_CONTAINERS`.

:param store_line_numbers: If the parser keeps track of the line
 numbers and positions of the original markup, that information
 will, by default, be stored in each corresponding
 :py:class:`bs4.element.Tag` object. You can turn this off by
 passing store_line_numbers=False; then Tag.sourcepos and
 Tag.sourceline will always be None. If the parser you're using
 doesn't keep track of this information, then store_line_numbers
 is irrelevant.

:param attribute_dict_class: The value of a multi-valued attribute
  (such as HTML's 'class') willl be stored in an instance of this
  class.  The default is Beautiful Soup's built-in
  `AttributeValueList`, which is a normal Python list, and you
  will probably never need to change it.
r   USE_DEFAULTDict[str, Set[str]]preserve_whitespace_tagsSet[str]boolstring_containers Dict[str, Type[NavigableString]]empty_element_tagsc                z   S U l         XR                  L a  U R                  nXl        X R                  L a  U R                  nX l        XPR                  L a  U R                  U l        OXPl        X0R                  :X  a  U R                  nX0l	        X@R                  :X  a  U R                  nX@l        X`l        Xpl        g r8   )souprd   DEFAULT_CDATA_LIST_ATTRIBUTEScdata_list_attributes DEFAULT_PRESERVE_WHITESPACE_TAGSrf   DEFAULT_EMPTY_ELEMENT_TAGSrk   TRACKS_LINE_NUMBERSstore_line_numbersDEFAULT_STRING_CONTAINERSri   attribute_dict_classattribute_value_list_class)r;   multi_valued_attributesrf   rs   ri   rk   ru   rv   s           r<   r=   TreeBuilder.__init__   s     	"&6&66&*&H&H#%<"#'7'77'+'L'L$(@%!1!11&*&E&ED#&8# !1!11!%!9!9"4 0 00 $ > >!2$8!*D'r?   z[Unknown tree builder]rX   NAMEzIterable[str]ALTERNATE_NAMESrA   Fis_xml	picklablezOptional[BeautifulSoup]rm   NzOptional[Set[str]]ro   tracks_line_numbersrn   rp   ,Dict[str, Type[bs4.element.NavigableString]]rt   rq   rr   c                    Xl         g)zThe BeautifulSoup object has been initialized and is now
being associated with the TreeBuilder.

:param soup: A BeautifulSoup object.
N)rm   )r;   rm   s     r<   initialize_soupTreeBuilder.initialize_soup  s	     	r?   c                    g)ziDo any work necessary to reset the underlying parser
for a new document.

By default, this does nothing.
Nr`   r:   s    r<   resetTreeBuilder.reset  s     	r?   c                :    U R                   c  gXR                   ;   $ )aw  Might a tag with this name be an empty-element tag?

The final markup may or may not actually present this tag as
self-closing.

For instance: an HTMLBuilder does not consider a <p> tag to be
an empty-element tag (it's not in
HTMLBuilder.empty_element_tags). This means an empty <p> tag
will be presented as "<p></p>", not "<p/>" or "<p>".

The default implementation has no opinion about which tags are
empty-element tags, so a tag will be presented as an
empty-element tag if and only if it has no children.
"<foo></foo>" will become "<foo/>", and "<foo>bar</foo>" will
be left alone.

:param tag_name: The name of a markup tag.
T)rk   )r;   tag_names     r<   can_be_empty_element TreeBuilder.can_be_empty_element"  s"    & ""*2222r?   c                    [        5       e)z1Run incoming markup through some parsing process.NotImplementedErrorr;   markups     r<   feedTreeBuilder.feed9  s    !##r?   c              #     #    USSS4v   g7f)a  Run any preliminary steps necessary to make incoming markup
acceptable to the parser.

:param markup: The markup that's about to be parsed.
:param user_specified_encoding: The user asked to try this encoding
   to convert the markup into a Unicode string.
:param document_declared_encoding: The markup itself claims to be
    in this encoding. NOTE: This argument is not used by the
    calling code and can probably be removed.
:param exclude_encodings: The user asked *not* to try any of
    these encodings.

:yield: A series of 4-tuples: (markup, encoding, declared encoding,
    has undergone character replacement)

    Each 4-tuple represents a strategy that the parser can try
    to convert the document to Unicode and parse it. Each
    strategy will be tried in turn.

 By default, the only strategy is to parse the markup
 as-is. See `LXMLTreeBuilderForXML` and
 `HTMLParserTreeBuilder` for implementations that take into
 account the quirks of particular parsers.

:meta private:

NFr`   )r;   r   user_specified_encodingdocument_declared_encodingexclude_encodingss        r<   prepare_markupTreeBuilder.prepare_markup=  s     D dD%''s   
c                    U$ )a  Wrap an HTML fragment to make it look like a document.

Different parsers do this differently. For instance, lxml
introduces an empty <head> tag, and html5lib
doesn't. Abstracting this away lets us write simple tests
which run HTML fragments through the parser and compare the
results against other HTML fragments.

This method should not be used outside of unit tests.

:param fragment: A fragment of HTML.
:return: A full HTML document.
:meta private:
r`   )r;   fragments     r<   test_fragment_to_document%TreeBuilder.test_fragment_to_documenta  s	     r?   c                    g)zSet up any substitutions that will need to be performed on
a `Tag` when it's output as a string.

By default, this does nothing. See `HTMLTreeBuilder` for a
case where this is used.

:return: Whether or not a substitution was performed.
:meta private:
Fr`   )r;   tags     r<   set_up_substitutions TreeBuilder.set_up_substitutionsr  s     r?   c                   [        [        U5      nU(       a  U R                  (       d  U$ U R                  R                  S[	        5       5      nU R                  R                  UR                  5       S5      n[        UR                  5       5       H]  nXd;   d  U(       d  M  Xe;   d  M  X6   n[        U[        5      (       a&  U R                  [        R                  " U5      5      nOUnXU'   M_     U$ )a  When an attribute value is associated with a tag that can
have multiple values for that attribute, convert the string
value to a list of strings.

Basically, replaces class="foo bar" with class=["foo", "bar"]

NOTE: This method modifies its input in place.

:param tag_name: The name of a tag.
:param attrs: A dictionary containing the tag's attributes.
   Any appropriate attribute values will be modified in place.
:return: The modified dictionary that was originally passed in.
*N)r   r   ro   rK   rL   lowerr9   keys
isinstancer   rv   r   findall)	r;   r   attrsmodified_attrs	universaltag_specificattroriginal_valuemodified_values	            r<   $_replace_cdata_list_attribute_values0TreeBuilder._replace_cdata_list_attribute_values~  s    ( .6T%?%?!! #88<<S#%H	1155hnn6FM,,./D \\d6J 3A2Fn.@AA
 &*%D%D(00@&N &4N'5t$1 02 r?   )ru   rv   ro   rk   rf   rm   rs   ri   )rw   re   rf   rg   rs   rh   ri   rj   rk   rg   ru   zType[AttributeDict]rv   zType[AttributeValueList])rm   r    rV   rW   rU   )r   rX   rV   rh   r   r'   rV   rW   )NNN)
r   r'   r   Optional[_Encoding]r   r   r   zOptional[_Encodings]rV   zKIterable[Tuple[_RawMarkup, Optional[_Encoding], Optional[_Encoding], bool]])r   rX   rV   rX   r   r"   rV   rh   )r   rX   r   r&   rV   r   )!rY   rZ   r[   r\   r]   objectrd   r^   r   r   r=   ry   rz   rA   r{   r|   rk   r   rL   rn   rp   rt   rq   rr   r   r   r   r   r   r   r   r   r_   r`   r?   r<   r*   r*      s   (T xK 8C-8#.>I'24A?QE!4E #+E !	E
 <E %E 2E %=EB )D#(%'O]' Hm FDIt
!! .2*1..&&77 :ES9I!#6I 25$h6 OQKP 6: 29 !&%3.$ 8<:>26"("( "5"( %8	"(
 0"( 
U"(H"
66$B6	6r?   r*   c                     ^  \ rS rSrSrSU 4S jjrSS jrSS jrSS jrSS jr	        SS jr
SS	 jrSS
 jrSS jrSS jrSS jrSS jrSrU =r$ )r)   i  a  A Beautiful Soup treebuilder that listens for SAX events.

This is not currently used for anything, and it will be removed
soon. It was a good idea, but it wasn't properly integrated into the
rest of Beautiful Soup, so there have been long stretches where it
hasn't worked properly.
c                b   > [         R                  " S[        SS9  [        [        U ]  " U0 UD6  g )NzThe SAXTreeBuilder class was deprecated in 4.13.0 and will be removed soon thereafter. It is completely untested and probably doesn't work; do not use it.   
stacklevel)warningswarnDeprecationWarningsuperr)   r=   )r;   argskwargs	__class__s      r<   r=   SAXTreeBuilder.__init__  s1     i	

 	nd,d=f=r?   c                    [        5       er8   r   r   s     r<   r   SAXTreeBuilder.feed  s    !##r?   c                    g r8   r`   r:   s    r<   closeSAXTreeBuilder.close      r?   c                    [        S [        UR                  5       5       5       5      nU R                  c   eU R                  R	                  US S U5        g )Nc              3  4   #    U  H  u  pUS    U4v   M     g7f)   Nr`   ).0keyvalues      r<   	<genexpr>.SAXTreeBuilder.startElement.<locals>.<genexpr>  s     T@S*#s1vuo@Ss   )r   r9   itemsrm   handle_starttag)r;   namer   s      r<   startElementSAXTreeBuilder.startElement  sE    TU[[]@STTyy$$$		!!$dE:r?   c                X    U R                   c   eU R                   R                  U5        g r8   )rm   handle_endtagr;   r   s     r<   
endElementSAXTreeBuilder.endElement  s$    yy$$$		%r?   c                &    U R                  X#5        g r8   )r   )r;   nsTuplenodeNamer   s       r<   startElementNSSAXTreeBuilder.startElementNS  s     	(*r?   c                &    U R                  U5        g r8   )r   )r;   r   r   s      r<   endElementNSSAXTreeBuilder.endElementNS  s    !r?   c                    g r8   r`   )r;   prefix	nodeValues      r<   startPrefixMapping!SAXTreeBuilder.startPrefixMapping  s    r?   c                    g r8   r`   )r;   r   s     r<   endPrefixMappingSAXTreeBuilder.endPrefixMapping  s     	r?   c                X    U R                   c   eU R                   R                  U5        g r8   )rm   handle_data)r;   contents     r<   
charactersSAXTreeBuilder.characters  s$    yy$$$		g&r?   c                    g r8   r`   r:   s    r<   startDocumentSAXTreeBuilder.startDocument  r   r?   c                    g r8   r`   r:   s    r<   endDocumentSAXTreeBuilder.endDocument  r   r?   r`   )r   r   r   r   rV   rW   r   rU   )r   rX   r   Dict[str, str]rV   rW   r   rX   rV   rW   )r   Tuple[str, str]r   rX   r   r   rV   rW   )r   r   r   rX   rV   rW   )r   rX   r   rX   rV   rW   )r   rX   rV   rW   )r   rX   rV   rW   )rY   rZ   r[   r\   r]   r=   r   r   r   r   r   r   r   r   r   r   r   r_   __classcell__)r   s   @r<   r)   r)     si    >$;&
+&+25+>L+	+"

' r?   r)   c                      \ rS rSr% Sr\" / SQ5      rS\S'   \" / SQ5      rS\S'   \	\
\\\S.rS	\S
'   1 SkSS1SS1S1S1S1S1S1S1S1S1S.rS\S'   \" SS/5      rS\S'   SS jrSrg)r(   i  zhThis TreeBuilder knows facts about HTML, such as which tags are treated
specially by the HTML standard.
)areabasebrcolembedhrimginputkeygenlinkmenuitemmetaparamsourcetrackwbrbasefontbgsoundcommandframeimageisindexnextidspacerrg   rq   )#addressarticleaside
blockquotecanvasdddivdldtfieldset
figcaptionfigurefooterformh1h2h3h4h5h6headerr   limainnavnoscriptoloutputppresectiontabletfootulvideoDEFAULT_BLOCK_ELEMENTS)rtrpstylescripttemplater~   rt   >   classdropzone	accesskeyrelrevheaderszaccept-charsetarchivesizessandboxfor)r   ar   tdthr  r   r   iconiframer(  re   rn   r*  textareazset[str]rp   c                d   UR                   S:w  a  g[        [        [           UR	                  S5      5      n[        [        [           UR	                  S5      5      nUR                  S5      nSnUb  [        U5      US'   SnU$ Ub'  [        S U 5       5      (       a  [        U5      US'   SnU$ )aZ  Replace the declared encoding in a <meta> tag with a placeholder,
to be substituted when the tag is output to a string.

An HTML document may come in to Beautiful Soup as one
encoding, but exit in a different encoding, and the <meta> tag
needs to be changed to reflect this.

:return: Whether or not a substitution was performed.

:meta private:
r  Fr   charsetz
http-equivTc              3  F   #    U  H  oR                  5       S :H  v   M     g7f)zcontent-typeN)r   )r   xs     r<   r   7HTMLTreeBuilder.set_up_substitutions.<locals>.<genexpr>  s      )
1;AGGI's   !)	r   r   r   rX   rK   get_attribute_listr   anyr   )r;   r   r   rG  
http_equivsubstituteds         r<   r   $HTMLTreeBuilder.set_up_substitutions|  s     88v "&hsmSWWY5G!H!%hsmSWWY5G!H
 !$ 6 6| D
  7w?C	NK   S )
1;)
 &
 &

 7w?C	NKr?   r`   Nr   )rY   rZ   r[   r\   r]   rL   rq   r^   r0  r   r   r   r   r   rt   rn   rp   r   r_   r`   r?   r<   r(   r(     s     ,/	
, F (+$	
&(H &r #"OK   0U^kk!"+	+':!#6 " 25eZ5H1I$hI4r?   r(   c                  ,   \ rS rSr% Sr\R                  " S\R                  5      rS\	S'   \R                  " S\R                  5      r
S\	S'   S	rS
\	S'   SrS\	S'   S\	S'   S\	S'   \ S     SS jj5       r\SSS jj5       rSS jrSS jrSS jrSrg) r2   i  a  A mixin class for any class (a TreeBuilder, or some class used by a
TreeBuilder) that's in a position to detect whether an XML
document is being incorrectly parsed as HTML, and issue an
appropriate warning.

This requires being able to observe an incoming processing
instruction that might be an XML declaration, and also able to
observe tags as they're opened. If you can't do that for a given
`TreeBuilder`, there's a less reliable implementation based on
examining the raw markup.
z
<[^ +]htmlzPattern[str]LOOKS_LIKE_HTMLs
   <[^ +]htmlzPattern[bytes]LOOKS_LIKE_HTML_Bz<?xmlrX   
XML_PREFIXs   <?xmlbytesXML_PREFIX_BzOptional[str]_first_processing_instruction_root_tag_namec                   Uc  gUSS n[        U[        5      (       aE  UnUR                  U R                  5      =(       a     U R                  R                  U5      (       + nODUnUR                  U R                  5      =(       a     U R                  R                  U5      (       + nU(       a  U R                  US-   S9  gg)ai  Perform a check on some markup to see if it looks like XML
that's not XHTML. If so, issue a warning.

This is much less reliable than doing the check while parsing,
but some of the tree builders can't do that.

:param stacklevel: The stacklevel of the code calling this         function.

:return: True if the markup looks like non-XHTML XML, False
 otherwise.
NFi  r   r   T)	r   rT  
startswithrU  rR  searchrS  rQ  _warn)clsr   r   markup_blooks_like_xmlmarkup_ss         r<   warn_if_markup_looks_like_xml4DetectsXMLParsedAsHTML.warn_if_markup_looks_like_xml  s      >fe$$$H%00   ;++226::  #H%00 9))0088  IIaI0r?   c                T    [         R                  " [        R                  [        US9  g)z/Issue a warning about XML being parsed as HTML.r   N)r   r   r   MESSAGE)r\  r   s     r<   r[  DetectsXMLParsedAsHTML._warn  s     	"**"!	
r?   c                     SU l         SU l        g)z+Call this method before parsing a document.NrV  rW  r:   s    r<   _initialize_xml_detector/DetectsXMLParsedAsHTML._initialize_xml_detector  s    -1*"r?   c                F    U R                   c  U R                  b  gXl         g)a  Call this method when encountering an XML declaration, or a
"processing instruction" that might be an XML declaration.

This helps Beautiful Soup detect potential issues later, if
the XML document turns out to be a non-XHTML document that's
being parsed as XML.
Nrf  )r;   processing_instructions     r<   _document_might_be_xml-DetectsXMLParsedAsHTML._document_might_be_xml  s'     ..:"". -C*r?   c                    U R                   b  gXl         US:w  aM  U R                  b?  U R                  R                  5       R                  S5      (       a  U R	                  SS9  gggg)zCall this when you encounter the document's root tag.

This is where we actually check whether an XML document is
being incorrectly parsed as HTML, and issue the warning.
Nr0   zxml 
   r   )rW  rV  r   rY  r[  r   s     r<   _root_tag_encountered,DetectsXMLParsedAsHTML._root_tag_encountered  sp     * " FN22>2288:EEfMM
 JJ"J% N ? r?   rf  N)   )r   zOptional[_RawMarkup]r   intrV   rh   )   )r   rr  rV   rW   rU   )rj  rX   rV   rW   r   )rY   rZ   r[   r\   r]   recompileIrQ  r^   rR  rS  rU  classmethodr`  r[  rg  rk  ro  r_   r`   r?   r<   r2   r2     s    
 %'JJ|RTT$BO\B )+

="$$(G~G J #L%" $10!!=> ) 7: 	   D 
 
#
D*&r?   r2   c                    [         R                  [           nU R                   Hg  n[	        X5      n[        U[        5      (       d  M%  [        XU5        UR                  R                  U5        UR                  R                  U5        Mi     g)z9Copy TreeBuilders from the given module into this module.N)sysmodulesrY   __all__getattr
issubclassr*   setattrappendra   rE   )modulethis_moduler   objs       r<   register_treebuilders_fromr  /  sg    ++h'Kf#c;''Ks+&&t,((11#6 r?   r   )_htmlparser)	_html5lib)_lxml)r  r   rV   rW   )F
__future__r   __license__collectionsr   rt  typesr   typingr   r   r	   r
   r   r   r   r   r   r   r   r   ry  bs4.elementr   r   r   r   r   r   r   r   r   r   bs4.exceptionsr   bs4._typingr   r   bs4._warningsr   bs4r    r!   r"   r#   r$   r%   r&   r'   r{  FAST
PERMISSIVESTRICTXMLHTMLHTML_5r   r+   ra   r^   r*   r)   r(   r2   r   r  r  ImportErrorr  r`   r?   r<   <module>r     sH   "  # 	      
   0
 1!  
		A& AL )<(= % =U& Up>[ >Bxk xvy&V y&x
7"  ; '	y)	u%  		  		s$   6D D  DD D)(D)