Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/lxml/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/lxml/__pycache__/builder.cpython-311.pyc

�

�܋f����dZddlmZddlmZejZddlm	Z		e
n
#e$reZ
YnwxYw	e
n
#e$reZ
YnwxYwGd�de��Ze��ZdS)z9
The ``E`` Element factory for generating XML documents.
�)�absolute_importN��partialc�*�eZdZdZ		dd�Zd�Zd�ZdS)�ElementMakeracElement generator factory.

    Unlike the ordinary Element factory, the E factory allows you to pass in
    more than just a tag and some optional attributes; you can also pass in
    text and other elements.  The text is added as either text or tail
    attributes, and elements are inserted at the right spot.  Some small
    examples::

        >>> from lxml import etree as ET
        >>> from lxml.builder import E

        >>> ET.tostring(E("tag"))
        '<tag/>'
        >>> ET.tostring(E("tag", "text"))
        '<tag>text</tag>'
        >>> ET.tostring(E("tag", "text", key="value"))
        '<tag key="value">text</tag>'
        >>> ET.tostring(E("tag", E("subtag", "text"), "tail"))
        '<tag><subtag>text</subtag>tail</tag>'

    For simple tags, the factory also allows you to write ``E.tag(...)`` instead
    of ``E('tag', ...)``::

        >>> ET.tostring(E.tag())
        '<tag/>'
        >>> ET.tostring(E.tag("text"))
        '<tag>text</tag>'
        >>> ET.tostring(E.tag(E.subtag("text"), "tail"))
        '<tag><subtag>text</subtag>tail</tag>'

    Here's a somewhat larger example; this shows how to generate HTML
    documents, using a mix of prepared factory functions for inline elements,
    nested ``E.tag`` calls, and embedded XHTML fragments::

        # some common inline elements
        A = E.a
        I = E.i
        B = E.b

        def CLASS(v):
            # helper function, 'class' is a reserved word
            return {'class': v}

        page = (
            E.html(
                E.head(
                    E.title("This is a sample document")
                ),
                E.body(
                    E.h1("Hello!", CLASS("title")),
                    E.p("This is a paragraph with ", B("bold"), " text in it!"),
                    E.p("This is another paragraph, with a ",
                        A("link", href="http://www.python.org"), "."),
                    E.p("Here are some reserved characters: <spam&egg>."),
                    ET.XML("<p>And finally, here is an embedded XHTML fragment.</p>"),
                )
            )
        )

        print ET.tostring(page)

    Here's a prettyprinted version of the output from the above script::

        <html>
          <head>
            <title>This is a sample document</title>
          </head>
          <body>
            <h1 class="title">Hello!</h1>
            <p>This is a paragraph with <b>bold</b> text in it!</p>
            <p>This is another paragraph, with <a href="http://www.python.org">link</a>.</p>
            <p>Here are some reserved characters: &lt;spam&amp;egg&gt;.</p>
            <p>And finally, here is an embedded XHTML fragment.</p>
          </body>
        </html>

    For namespace support, you can pass a namespace map (``nsmap``)
    and/or a specific target ``namespace`` to the ElementMaker class::

        >>> E = ElementMaker(namespace="http://my.ns/")
        >>> print(ET.tostring( E.test ))
        <test xmlns="http://my.ns/"/>

        >>> E = ElementMaker(namespace="http://my.ns/", nsmap={'p':'http://my.ns/'})
        >>> print(ET.tostring( E.test ))
        <p:test xmlns:p="http://my.ns/"/>
    Nc���|�d|zdznd|_|rt|��nd|_|�t|��sJ�|�|ntj|_�rt���ni�d�}d�}t�vr
|�t<t�vr
|�t<tj	�vr|�tj	<�fd�}t�vr
|�t<�|_
dS)N�{�}c�~�	|d}|jpd|z|_dS#t$r|jpd|z|_YdSwxYw)N����)�tail�
IndexError�text)�elem�item�
last_childs   �_/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib64/python3.11/site-packages/lxml/builder.py�add_textz'ElementMaker.__init__.<locals>.add_text�s_��
A�!�"�X�
�$.�?�#8�b�D�"@�
������
5�
5�
5�!�Y�_�"��4��	�	�	�	�
5���s��<�<c�P�|jrtd|jz���||_dS)Nz<Can't add a CDATA section. Element already has some text: %r)r�
ValueError)r�cdatas  r�	add_cdataz(ElementMaker.__init__.<locals>.add_cdata�s0���y�
m� �!_�bf�bk�!k�l�l�l��D�I�I�I�c����|j}|���D]B\}}t|t��r|||<� �t	|��d|��||<�CdS�N)�attrib�items�
isinstance�
basestring�type)rrr�k�v�typemaps     �r�add_dictz'ElementMaker.__init__.<locals>.add_dict�sn����[�F��
�
���
:�
:���1��a��,�,�:� !�F�1�I�I� 0���Q��� 0��q� 9� 9�F�1�I�I�	
:�
:r)�
_namespace�dict�_nsmap�callable�ET�Element�_makeelement�str�unicode�CDATA�_typemap)�selfr$�	namespace�nsmap�makeelementrrr%s `      r�__init__zElementMaker.__init__�s���3<�3H�#�	�/�C�/�/�d���%*�4�d�5�k�k�k�����"�h�{�&;�&;�"�"�;�+6�+B�K�K��
���$+�2�$�w�-�-�-���	A�	A�	A�	�	�	�
�g���#�G�C�L��'�!�!�'�G�G��
�8�7�"�"� )�G�B�H��	:�	:�	:�	:�	:��w���$�G�D�M���
�
�
rc��|j}t|t��st|t��r|j}n|j�|ddkr
|j|z}|�||j���}|r|t||��|D]�}t|��r
|��}|�
t|����}|��tj
|��r|�|���it|��jD]}|�
|��}|�n)�t!dt|��j�d|�d����|||��}	|	r,|�
t|	����||	����|S)Nrr	)r3zbad argument type: �(�))r0rr-�_QNamerr&r,r(r'r)�getr!r*�	iselement�append�__mro__�	TypeError�__name__)
r1�tag�childrenrr$rr�t�basetyper#s
          r�__call__zElementMaker.__call__�s����-���#�s�#�#�	(�
�3��(?�(?�	(��(�C�C�
�_�
(�S��V�s�]�]��/�C�'�C�� � ��D�K� �8�8���	(��G�D�M�$��'�'�'��	.�	.�D���~�~�
��t�v�v�����D��J�J�'�'�A��y��<��%�%���K�K��%�%�%�� $�T�
�
� 2�A�A�H����H�-�-�A��}���%�$�)�%)�$�Z�Z�%8�%8�%8�$�$�$�%@�A�A�A���$��
�
�A��
.�$����D��G�G�$�$�T�1�-�-�-���rc�"�t||��Srr)r1r@s  r�__getattr__zElementMaker.__getattr__�s���t�S�!�!�!r)NNNN)r?�
__module__�__qualname__�__doc__r5rDrF�rrrr<s]������V�V�p $�9=�* �* �* �* �X!�!�!�F"�"�"�"�"rr)rI�
__future__r�
lxml.etree�etreer*�QNamer9�	functoolsrr �	NameErrorr-r.�objectr�ErJrr�<module>rSs���L��'�&�&�&�&�&�������	�����������J�J�������J�J�J�������G�G�������G�G�G�����i"�i"�i"�i"�i"�6�i"�i"�i"�Z�L�N�N���s� �*�*�1�;�;

Hacked By AnonymousFox1.0, Coded By AnonymousFox