Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/bs4/builder/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/bs4/builder/__pycache__/__init__.cpython-312.pyc

�

(ٜg�_���dZddlmZddlZddlZddlZddlZddlmZm	Z	m
Z
mZmZm
Z
mZmZgd�ZdZdZdZd	Zd
ZdZGd�d
e�ZGd�de�Ze�ZGd�de�ZGd�de�ZGd�de�ZGd�de�Zd�Z Gd�de!�Z"ddl#m$Z$e e$�	ddl#m%Z%e e%�	ddl#m'Z'e e'�y#e&$rY�wxYw#e&$rYywxYw)�MIT�)�defaultdictN)�CharsetMetaAttributeValue�ContentMetaAttributeValue�RubyParenthesisString�RubyTextString�
Stylesheet�Script�TemplateString�nonwhitespace_re)�HTMLTreeBuilder�SAXTreeBuilder�TreeBuilder�TreeBuilderRegistry�fast�
permissive�strict�xml�html�html5c��eZdZdZdZy)�XMLParsedAsHTMLWarningzWThe warning issued when an HTML parser is used to parse
    XML that is not XHTML.
    a�It looks like you're parsing an XML document using an HTML parser. If this really is an HTML document (maybe it's XHTML?), you can ignore or filter this warning. If it's XML, you should know that using an XML parser will be more reliable. To parse this document as XML, make sure you have the lxml package installed, and pass the keyword argument `features="xml"` into the BeautifulSoup constructor.N)�__name__�
__module__�__qualname__�__doc__�MESSAGE���?/usr/local/lib/python3.12/site-packages/bs4/builder/__init__.pyrr#s���d�Grrc�"�eZdZdZd�Zd�Zd�Zy)rzYA way of looking up TreeBuilder subclasses by their name or by desired
    features.
    c�:�tt�|_g|_y�N)r�list�builders_for_feature�builders��selfs r �__init__zTreeBuilderRegistry.__init__/s��$/��$5��!���
rc��|jD]!}|j|jd|��#|jjd|�y)z�Register a treebuilder based on its advertised features.

        :param treebuilder_class: A subclass of Treebuilder. its .features
           attribute should list its features.
        rN)�featuresr%�insertr&)r(�treebuilder_class�features   r �registerzTreeBuilderRegistry.register3sE��)�1�1�G��%�%�g�.�5�5�a�9J�K�2��
�
���Q� 1�2rc���t|j�dk(ryt|�dk(r|jdSt|�}|j�d}d}t|�dkDrs|j	�}|j
j
|g�}t|�dkDr*|�|}t|�}n|jt|��}t|�dkDr�s|�y|D]
}||vs�|cSy)ajLook 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.
        rN)	�lenr&r$�reverse�popr%�get�set�intersection)r(r+�
candidates�
candidate_setr.�we_have_the_feature�	candidates       r �lookupzTreeBuilderRegistry.lookup=s����t�}�}���"���x�=�A���=�=��#�#���>�������
��
��(�m�a���l�l�n�G�"&�";�";�"?�"?���"L���&�'�!�+��%�!4�J�$'�
�O�M�%2�$>�$>��/�0�%2�M��(�m�a��� ��#�I��M�)� � �$�rN)rrrrr)r/r;rrr rr*s����3�,rrc��eZdZdZdZgZgZdZdZdZ	e
e�Ze
�ZiZe�ZdZeeeefd�Zd�Zd�Zd�Zd	�Z		dd
�Zd�Zd�Zd
�Zy)rz:Turn a textual document into a Beautiful Soup object tree.z[Unknown tree builder]FNc��d|_||jur|j}||_||jur|j}||_||jk(r|j}||_||jk(r|j}||_	y)a�Constructor.

        :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 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 list of tags to treat
         the way <pre> tags are treated in HTML. Tags in this list
         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 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
         `Tag` object. You can turn this off by passing
         store_line_numbers=False. If the parser you're using doesn't 
         keep track of this information, then setting store_line_numbers=True
         will do nothing.
        N)
�soup�USE_DEFAULT�DEFAULT_CDATA_LIST_ATTRIBUTES�cdata_list_attributes� DEFAULT_PRESERVE_WHITESPACE_TAGS�preserve_whitespace_tags�TRACKS_LINE_NUMBERS�store_line_numbers�DEFAULT_STRING_CONTAINERS�string_containers)r(�multi_valued_attributesrCrErGs     r r)zTreeBuilder.__init__�s���H��	�"�d�&6�&6�6�&*�&H�&H�#�%<��"�#�t�'7�'7�7�'+�'L�'L�$�(@��%���!1�!1�1�!%�!9�!9��"4����� 0� 0�0� $� >� >��!2��rc��||_y)z�The BeautifulSoup object has been initialized and is now
        being associated with the TreeBuilder.

        :param soup: A BeautifulSoup object.
        N)r>)r(r>s  r �initialize_soupzTreeBuilder.initialize_soup�s����	rc��y)z�Do any work necessary to reset the underlying parser
        for a new document.

        By default, this does nothing.
        Nrr's r �resetzTreeBuilder.reset�s��	
rc�8�|j�y||jvS)a�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)�empty_element_tags)r(�tag_names  r �can_be_empty_elementz TreeBuilder.can_be_empty_element�s$��&�"�"�*���4�2�2�2�2rc��t��)z�Run some incoming markup through some parsing process,
        populating the `BeautifulSoup` object in self.soup.

        This method is not implemented in TreeBuilder; it must be
        implemented in subclasses.

        :return: None.
        ��NotImplementedError�r(�markups  r �feedzTreeBuilder.feed�s
��"�#�#rc#�K�|dddf��y�w)aRun any preliminary steps necessary to make incoming markup
        acceptable to the parser.

        :param markup: Some markup -- probably a bytestring.
        :param user_specified_encoding: The user asked to try this encoding.
        :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 for converting the
         document to Unicode and parsing 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.
        NFr)r(rU�user_specified_encoding�document_declared_encoding�exclude_encodingss     r �prepare_markupzTreeBuilder.prepare_markup�s����4�d�D�%�'�'�s�
c��|S)aWrap 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 tests.

        :param fragment: A string -- fragment of HTML.
        :return: A string -- a full HTML document.
        r)r(�fragments  r �test_fragment_to_documentz%TreeBuilder.test_fragment_to_documents	���rc��y)a2Set 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.

        :param tag: A `Tag`
        :return: Whether or not a substitution was performed.
        Fr)r(�tags  r �set_up_substitutionsz TreeBuilder.set_up_substitutionss��rc�j�|s|S|jr�|jjdg�}|jj|j�d�}t|j	��D]@}||vs|s�
||vs�||}t|t�rtj|�}n|}|||<�B|S)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.
        �*N)	rAr4�lowerr$�keys�
isinstance�strr�findall)r(rO�attrs�	universal�tag_specific�attr�value�valuess        r �$_replace_cdata_list_attribute_valuesz0TreeBuilder._replace_cdata_list_attribute_values's�����L��%�%��2�2�6�6�s�B�?�I��5�5�9�9���� �$�(�L��U�Z�Z�\�*���9�$��$�,�:N�"�$�K�E�!�%��-�!1�!9�!9�%�!@��"'��"(�E�$�K�!+�"�r)NNN)rrrr�NAME�ALTERNATE_NAMESr+�is_xml�	picklablerNrr$r@r5rBrF�objectr?rDr)rJrLrPrVr[r^rarorrr rros���D�#�D��O��H�
�F��I���
%0��$5�!�(+�u�$�!#���(�K� ��/:�*5�$/�#.�03�d�
�3�.	$�>B�JN�(�8� 
�$rrc�R�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zy
)rz�A Beautiful Soup treebuilder that listens for SAX events.

    This is not currently used for anything, but it demonstrates
    how a simple TreeBuilder would work.
    c��t��r#rRrTs  r rVzSAXTreeBuilder.feedTs��!�#�#rc��yr#rr's r �closezSAXTreeBuilder.closeW���rc��td�t|j��D��}|jj	||�y)Nc3�0K�|]\}}|d|f���y�w)�Nr)�.0�keyrms   r �	<genexpr>z.SAXTreeBuilder.startElement.<locals>.<genexpr>[s����K�7J���e�c�!�f�e�_�7J�s�)�dictr$�itemsr>�handle_starttag)r(�nameris   r �startElementzSAXTreeBuilder.startElementZs1���K�t�E�K�K�M�7J�K�K���	�	�!�!�$��.rc�:�|jj|�yr#)r>�
handle_endtag�r(r�s  r �
endElementzSAXTreeBuilder.endElement_s���	�	����%rc�(�|j||�yr#)r�)r(�nsTuple�nodeNameris    r �startElementNSzSAXTreeBuilder.startElementNScs�����(�E�*rc�&�|j|�yr#)r�)r(r�r�s   r �endElementNSzSAXTreeBuilder.endElementNSgs������!rc��yr#r)r(�prefix�	nodeValues   r �startPrefixMappingz!SAXTreeBuilder.startPrefixMappingls��rc��yr#r)r(r�s  r �endPrefixMappingzSAXTreeBuilder.endPrefixMappingps��	
rc�:�|jj|�yr#)r>�handle_data)r(�contents  r �
characterszSAXTreeBuilder.charactersus���	�	���g�&rc��yr#rr's r �
startDocumentzSAXTreeBuilder.startDocumentxryrc��yr#rr's r �endDocumentzSAXTreeBuilder.endDocument{ryrN)rrrrrVrxr�r�r�r�r�r�r�r�r�rrr rrMs>���$�
�/�
&�+�"�

�
�
'�
�
rrc
��eZdZdZegd��Zegd��Zeee	e
ed�Zgd�ddgddgdgdgdgd	gd
gdgdgdgd
gd�Z
eddg�Zd�Zy)r
z]This TreeBuilder knows facts about HTML.

    Such as which tags are empty-element tags.
    )�area�base�br�col�embed�hr�img�input�keygen�link�menuitem�meta�param�source�track�wbr�basefont�bgsound�command�frame�image�isindex�nextid�spacer)#�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)�rt�rp�style�script�template)�class�	accesskey�dropzone�rel�rev�headerszaccept-charset�archive�sizes�sandbox�for)rc�ar��td�thr�r�rtr��icon�iframer�r��textareac�
�|jdk7ry|jd�}|jd�}|jd�}d}|�|}t|�|d<|duS|�#|�!|j�dk(rt	|�|d<|duS)a�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.

        :param tag: A `Tag`
        :return: Whether or not a substitution was performed.
        r�Fz
http-equivr��charsetNzcontent-type)r�r4rrdr)r(r`�
http_equivr�r��
meta_encodings      r raz$HTMLTreeBuilder.set_up_substitutions�s����8�8�v����W�W�\�*�
��'�'�)�$���'�'�)�$���
���$�M�6�w�?�C�	�N��T�)�*�
�!�j�&<��"�"�$��6�7�w�?�C�	�N��T�)�*rN)rrrrr5rN�block_elementsrrr	r
rrFr@rBrarrr r
r
s����
�����}�~�N�&�$���"�!�� 1��e�n��%�.��{��{��{�"�#��;������;��7�%
�!�"(+�E�:�+>�'?�$�)+rr
c���eZdZdZej
dej�Zej
dej�ZdZ	dZ
edd��Zed
d��Z
d�Zd	�Zd
�Zy)�DetectsXMLParsedAsHTMLaA 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
<[^ +]htmls
<[^ +]htmlz<?xmls<?xmlc��t|t�r|j}|j}n|j}|j
}|�;|j
|�r*|j|dd�s|j|dz��yy)a�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.

        Ni����
stacklevelTF)	rf�bytes�XML_PREFIX_B�LOOKS_LIKE_HTML_B�
XML_PREFIX�LOOKS_LIKE_HTML�
startswith�search�_warn)�clsrUr�r��looks_like_htmls     r �warn_if_markup_looks_like_xmlz4DetectsXMLParsedAsHTML.warn_if_markup_looks_like_xmlsx���f�e�$��%�%�F�!�3�3�O��^�^�F�!�1�1�O����!�!�&�)�#�*�*�6�$�3�<�8��I�I��A��I�.��rc�X�tjtjt|��y)z/Issue a warning about XML being parsed as HTML.r�N)�warnings�warnrr)rr�s  r r�zDetectsXMLParsedAsHTML._warn"s��	�
�
�"�*�*�,B�!�	
rc� �d|_d|_y)z+Call this method before parsing a document.N��_first_processing_instruction�	_root_tagr's r �_initialize_xml_detectorz/DetectsXMLParsedAsHTML._initialize_xml_detector*s��-1��*���rc�D�|j�|j�y||_y)z�Call this method when encountering an XML declaration, or a
        "processing instruction" that might be an XML declaration.
        Nr)r(�processing_instructions  r �_document_might_be_xmlz-DetectsXMLParsedAsHTML._document_might_be_xml/s'��
�.�.�:��~�~�)�
�-C��*rc���|j�y||_|dk7rH|j�;|jj�jd�r|j	�yyyy)z�Call 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.
        Nrzxml )r	rrdr�r�r�s  r �_root_tag_encounteredz,DetectsXMLParsedAsHTML._root_tag_encountered>sb���>�>�%�
�����F�N�t�A�A�M��2�2�8�8�:�E�E�f�M�
�J�J�L�	N� N�NrN)�)�)rrrr�re�compile�Ir�r�r�r��classmethodrr�r
r
rrrr r�r��sv��
�!�b�j�j��r�t�t�4�O�"��
�
�=�"�$�$�7���J��L�����:�
��
��

D�rr�c��tjt}|jD]b}t	||�}t|t�s� t|||�|jj|�|jj|��dy)z9Copy TreeBuilders from the given module into this module.N)�sys�modulesr�__all__�getattr�
issubclassr�setattr�append�builder_registryr/)�module�this_moduler��objs    r �register_treebuilders_fromr"Rsh���+�+�h�'�K������f�d�#���c�;�'��K��s�+����&�&�t�,��(�(�1�1�#�6�rc�"��eZdZdZ�fd�Z�xZS)�ParserRejectedMarkupzgAn Exception to be raised when the underlying parser simply
    refuses to parse the given markup.
    c���t|t�r&|}|jj�dt	|���}t
t|�|�y)zzExplain why the parser rejected the given markup, either
        with a textual explanation or another exception.
        z: N)rf�	Exception�	__class__rrg�superr$r))r(�message_or_exception�er's   �r r)zParserRejectedMarkup.__init__bs?����*�I�6�$�A�/0�{�{�/C�/C�S��V�#L� �
�"�D�2�3G�Hr)rrrrr)�
__classcell__)r's@r r$r$^s����I�Irr$r|)�_htmlparser)�	_html5lib)�_lxml)(�__license__�collectionsr�	itertoolsrrr�bs4.elementrrrrr	r
rrr�FAST�
PERMISSIVE�STRICT�XML�HTML�HTML_5�UserWarningrrtrrrrr
r�r"r&r$�r,r-�ImportErrorr.rrr �<module>r<s����#��	��
�	�	�	�����
�
�	����
��	��d�[�d�?�&�?�F'�(��\�&�\�|/
�[�/
�do+�k�o+�b_�V�_�D
7�I�9�I�"��;�'�	���y�)�	���u�%���	��	���	��	�s$�#C�2C�C	�C	�C�C

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists