
    h*                        S r SSKJrJr  SSKJrJrJrJrJ	r	  SSK
Jr  SSKr\(       a  SSKJr  \R                  " SSSS	9 " S
 S5      5       r\R                  " SSSSS9 " S S5      5       rSr\R                  " SSSSS9 " S S5      5       r\R                  " SSSSS9 " S S5      5       r\R                  " SSSSS9 " S S5      5       rg)aC  
An s-expression-like syntax for expressing xml in pure python.

Stan tags allow you to build XML documents using Python.

Stan is a DOM, or Document Object Model, implemented using basic Python types
and functions called "flatteners". A flattener is a function that knows how to
turn an object of a specific type into something that is closer to an HTML
string. Stan differs from the W3C DOM by not being as cumbersome and heavy
weight. Since the object model is built using simple python types such as lists,
strings, and dictionaries, the API is simpler and constructing a DOM less
cumbersome.

@var voidElements: the names of HTML 'U{void
    elements<http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html#void-elements>}';
    those which can't have contents and can therefore be self-closing in the
    output.
    )iscoroutineisgenerator)TYPE_CHECKINGDictListOptionalUnion)warnN)FlattenableFT)unsafe_hasheqauto_attribsc                       \ rS rSr% Sr\\S'    \R                  " S\	S9r
\S   \S'    Sr\S	   \S
'    Sr\\   \S'    Sr\\   \S'    Sr\\   \S'   Srg)slot#   z,
Marker for markup insertion in a template.
nameF)initfactoryTagchildrenNr   defaultfilename
lineNumbercolumnNumber )__name__
__module____qualname____firstlineno____doc__str__annotations__attriblistr   r   r   r   r   r   intr   __static_attributes__r       X/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/web/_stan.pyr   r   #   s     I !GG=Hd5k= (,GXm$+ #Hhsm" !%J$ #'L(3-&r(   r   )r   r   reprr   c                      \ rS rSr% Sr\\\4   \S'    \	R                  " \S9r\\\\4   S4   \S'    \	R                  " \S9r\S   \S'    Sr\\   \S	'    Sr\\   \S
'    Sr\\   \S'    Sr\\   \S'    \	R                  " SSS9r\\\S4      \S'    SS jrSS jrSSS\SS4S jrSS\SS 4S jjrSS jrS\4S jrSrg)r   U   aF  
A L{Tag} represents an XML tags with a tag name, attributes, and children.
A L{Tag} can be constructed using the special L{twisted.web.template.tags}
object, or it may be constructed directly with a tag name. L{Tag}s have a
special method, C{__call__}, which makes representing trees of XML natural
using pure python syntax.
tagName)r   r   
attributesr   Nrenderr   r   r   F)r   r   slotDatareturnc                 d    U R                   c  0 U l         U R                   R                  U5        U $ )a  
Remember the slots provided at this position in the DOM.

During the rendering of children of this node, slots with names in
C{slots} will be rendered as their corresponding values.

@return: C{self}. This enables the idiom C{return tag.fillSlots(...)} in
    renderers.
)r0   update)selfslotss     r)   	fillSlotsTag.fillSlots   s,     == DMU#r(   c                 
   U R                   R                  U5        UR                  5        HS  u  p4US   S:X  a  USS nUS:X  a,  [        U[        5      (       d  [        SU< 35      eX@l        ME  X@R                  U'   MU     U $ )a8  
Add children and change attributes on this tag.

This is implemented using __call__ because it then allows the natural
syntax::

  table(tr1, tr2, width="100%", height="50%", border="1")

Children may be other tag instances, strings, functions, or any other
object which has a registered flatten.

Attributes may be 'transparent' tag instances (so that
C{a(href=transparent(data="foo", render=myhrefrenderer))} works),
strings, functions, or any other object which has a registered
flattener.

If the attribute is a python keyword, such as 'class', you can add an
underscore to the name, like 'class_'.

There is one special keyword argument, 'render', which will be used as
the name of the renderer and saved as the 'render' attribute of this
instance, rather than the DOM 'render' attribute in the attributes
dictionary.
_Nr/   z.Value for "render" attribute must be str, got )r   extenditems
isinstancer!   	TypeErrorr/   r.   )r4   r   kwkvs        r)   __call__Tag.__call__   s    2 	X&HHJDAu|crFH}!!S))#HN   %&"  r(   objdeepc                 T   [        US5      (       a  UR                  U5      $ [        U[        [        45      (       a!  U Vs/ s H  o0R                  X25      PM     sn$ [        U5      (       a  [        S[        5        U$ [        U5      (       a  [        S[        5        U$ U$ s  snf )ah  
Clone a C{Flattenable} object; used by L{Tag.clone}.

Note that both lists and tuples are cloned into lists.

@param obj: an object with a clone method, a list or tuple, or something
    which should be immutable.

@param deep: whether to continue cloning child objects; i.e. the
    contents of lists, the sub-tags within a tag.

@return: a clone of C{obj}.
clonezCloning a Tag which contains a generator is unsafe, since the generator can be consumed only once; this is deprecated since Twisted 21.7.0 and will raise an exception in the futurezCloning a Tag which contains a coroutine is unsafe, since the coroutine can run only once; this is deprecated since Twisted 21.7.0 and will raise an exception in the future)
hasattrrG   r=   r%   tuple_cloner   r
   DeprecationWarningr   )r4   rD   rE   xs       r)   rJ   
Tag._clone   s     3  99T?"dE]++256#QKK(#66- # J- # JJ) 7s   B%c           
      H   U(       a,  U R                    Vs/ s H  o R                  US5      PM     nnOU R                   SS nU R                  R                  5       nUR	                  5        H  nU R                  XE   S5      XE'   M     SnU R
                  (       a9  U R
                  R                  5       nU H  nU R                  Xe   S5      Xe'   M     [        U R                  UUU R                  U R                  U R                  U R                  S9nXgl        U$ s  snf )z
Return a clone of this tag. If deep is True, clone all of this tag's
children. Otherwise, just shallow copy the children list without copying
the children themselves.
TN)r.   r   r/   r   r   r   )r   rJ   r.   copykeysr0   r   r-   r/   r   r   r   )r4   rE   rL   newchildrennewattrskeynewslotdatanewtags           r)   rG   	Tag.clone   s     9=GA;;q$/KGK--*K??'')==?C KKt<HM # ==--,,.K"#';;{/?#F  # LL ;;]]**
 &1 Hs   Dc                     / U l         U $ )z,
Clear any existing children from this tag.
)r   r4   s    r)   clear	Tag.clear  s     r(   c                     SnU R                   (       a  USU R                   -  -  nU R                  (       a  USU R                  -  -  nSU R                  < U S3$ )N z, attributes=%rz, children=%rzTag())r.   r   r-   )r4   rstrs     r)   __repr__Tag.__repr__  sT    ??%77D==Odmm33Ddll%dV1--r(   )r   r/   r0   )r5   r   r1   r   )r   r   r?   r   r1   r   )T)r1   r   ) r   r   r   r   r    r	   bytesr!   r"   r#   r$   dictr.   r   r%   r   r   r/   r   r   r   r&   r   r0   r6   rB   boolrJ   rG   rY   r_   r'   r   r(   r)   r   r   U   s+    5#: :>9NJU5#:&56N($(GGD$9Hd=!9& FHSM  #Hhsm" !%J$ #'L(3-& 4877t3THhtC./0T'R%- %t % %N$ % B.# .r(   r   )imgbrhrbasemetalinkparamareainputcolbasefontisindexframecommandembedkeygensourcetrackwbsc                   4    \ rS rSr% Sr\\S'    S\4S jrSrg)CDATAi=  z
A C{<![CDATA[]]>} block from a template.  Given a separate representation in
the DOM so that they may be round-tripped through rendering without losing
information.
datar1   c                 $    SU R                   < S3$ )NzCDATA(r]   ry   rX   s    r)   r_   CDATA.__repr__H  s    		}A&&r(   r   N	r   r   r   r   r    r!   r"   r_   r'   r   r(   r)   rx   rx   =  s     I7'# 'r(   rx   c                   4    \ rS rSr% Sr\\S'    S\4S jrSrg)CommentiL  z
A C{<!-- -->} comment from a template.  Given a separate representation in
the DOM so that they may be round-tripped through rendering without losing
information.
ry   r1   c                 $    SU R                   < S3$ )NzComment(r]   r{   rX   s    r)   r_   Comment.__repr__W  s    $))a((r(   r   Nr}   r   r(   r)   r   r   L  s     I2)# )r(   r   c                   4    \ rS rSr% Sr\\S'    S\4S jrSr	g)CharRefi[  z
A numeric character reference.  Given a separate representation in the DOM
so that non-ASCII characters may be output as pure ASCII.

@since: 12.0
ordinalr1   c                 "    SU R                   4-  $ )NzCharRef(%d))r   rX   s    r)   r_   CharRef.__repr__g  s    ..r(   r   N)
r   r   r   r   r    r&   r"   r!   r_   r'   r   r(   r)   r   r   [  s     LQ/# /r(   r   )r    inspectr   r   typingr   r   r   r   r	   warningsr
   r#   twisted.web.templater   sr   r   voidElementsrx   r   r   r   r(   r)   <module>r      s   
( - = =  0 Ee$7. . 8.b Ee%dCM. M. DM.`. Ee%dC' ' D' Ee%dC) ) D) Ee%dC/ / D/r(   