+
     h%!  c                   s    R t ^ RIHt ]P                  t^ RIHt  ^ RIH	t
  ]  ]  ! R R4      t]! 4       tR#   ] d    R t
 L%i ; i  ] d    ]t L1i ; i  ] d    ]t L=i ; i)z9
The ``E`` Element factory for generating XML documents.
Npartial)GenericAliasc                 s:    V P                    R VP                    R2# )Z[Z])__name__Zclsitem   &&3/usr/lib64/python3.14/site-packages/lxml/builder.py_GenericAliasr   4   s    ,,qq11    c                   s@   a  ] tR t^Bt o RtRR ltR tR tR tRt	V t
R# )	ElementMakeraG  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                s  a Ve   RV,           R,           MR V n         V'       d   \        V4      MR V n        Ve   TM\        P                  V n        S'       d   \        S4      M/ oR pR p\        S9  d
   VS\        &   \        S9  d
   VS\        &   \        P                  S9  d   VS\        P                  &   V3R lp\        S9  d
   VS\        &   SV n	        R # )N{Z}c                 s     V R,          pVP                   ;'       g    RV,           Vn         R#   \         d'    T P                  ;'       g    RT,           T n         R# i ; i)i   Z Ni)ZtailZ
IndexErrortext)elemr   Z
last_childs   && r   add_textZ'ElementMaker.__init__.<locals>.add_text   sR    A!"X
 $.??#8#8bD"@
  5!YY__"4	5s   	/ A A A c                 sn    V P                   '       d   \        R V P                   ,          4      hWn         R# )z<Can't add a CDATA section. Element already has some text: %rN)r   Z
ValueError)r   Zcdatar   r   	add_cdataZ(ElementMaker.__init__.<locals>.add_cdata   s(    yyy !_bfbkbk!kllIr	   c                 s   < V P                   pVP                  4        F<  w  r4\        V\        4      '       d   WBV&   K!  S\	        V4      ,          ! R V4      W#&   K>  	  R # N)attribZitems
isinstance
basestringtype)r   r   r   Zkvtypemaps   &&   r   add_dictZ'ElementMaker.__init__.<locals>.add_dict   sI    [[F

a,, !1I 'Q 0q 9FI	 %r	   )

_namespacedict_nsmapETZElement_makeelementstrunicodeZCDATA_typemap)selfr   Z	namespacensmapZmakeelementr   r   r   s   &f&&&   r   __init__ZElementMaker.__init__   s    3<3H#	/C/d%*d5k ,7+BK

 $+$w-	A	
 g#GCL'!'GG887" )GBHH	: w$GDMr	   c                sP   V P                   p\        V\        4      '       g$   \        V\        4      '       d   VP                  pM/V P
                  e"   V^ ,          R8w  d   V P
                  V,           pV P                  WP                  R7      pV'       d   V\        ,          ! WS4       V F  p\        V4      '       d   V! 4       pVP                  \        V4      4      pVf   \        P                  ! V4      '       d   VP                  V4       Kh  \        V4      P                   F  pVP                  V4      pVf   K   M)	  \!        R\        V4      P"                  : RV: R24      hV! WV4      p	V	'       g   K  VP                  \        V	4      4      ! WY4       K  	  V# )Nr   )r!   zbad argument type: Z(Z))r   r   r   _QNamer   r   r   r   r   ZcallableZgetr   r   Z	iselementZappendZ__mro__Z	TypeErrorr   )
r    tagZchildrenr   r   r   r   ZtZbasetyper   s
   &&*,      r   __call__ZElementMaker.__call__   s@   -- #s##
3(?(?((C__(SVs]//C'C  KK 8DM$'D~~vDJ'Ay<<%%KK% $T
 2 2HH-A}	 !3 $%)$Z%8%8$%@ A A$AqDG$T-% ( r	   c                    \        W4      # r   r    )r    r$   r   r   __getattr__ZElementMaker.__getattr__   s    t!!r	   c                r&   r   )r   r   r   r   __class_getitem__ZElementMaker.__class_getitem__   s    S''r	   )r   r   r   r   )NNNN)r   Z
__module__Z__qualname__Z__firstlineno____doc__r"   r%   r'   r(   Z__static_attributes__Z__classdictcell__)Z__classdict__s   @r   r
   r
   B   s'     Vp* X!F"( (r	   r
   )r)   Z
lxml.etreeZetreer   ZQNamer#   Z	functoolsr   Ztypesr   r   ZImportErrorr   Z	NameErrorr   r   r
   ZE) r	   r   <module>r*      s   L
 	 23
m( m(b NC  222  J
  Gs1   ; A A 
AA	AA	A&%A&