Ϫf*dZddlmZmZddlmZmZmZmZm Z ddl m Z ddl Z erddl mZe jddd Gd d Ze jdddd Gd dZdZe jdddd GddZe jdddd GddZe jdddd GddZy)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}'; those which can't have contents and can therefore be self-closing in the output. ) iscoroutine isgenerator) TYPE_CHECKINGDictListOptionalUnion)warnN) FlattenableFT)hasheq auto_attribsceZdZUdZeed< ejdeZ e ded< dZ e ded < dZ e eed < dZe eed < dZe eed <y) slotz4 Marker for markup insertion in a template. nameF)initfactoryTagchildrenNr defaultfilename lineNumber columnNumber)__name__ __module__ __qualname____doc__str__annotations__attriblistrrrrrrintr3/usr/lib/python3/dist-packages/twisted/web/_stan.pyrr#s I $DGG=Hd5k=(,GXm $+#Hhsm" !%J $#'L(3-&r%r)r r reprrceZdZUdZeeefed< eje Z e eeefdfed< eje Zeded< dZeeed< dZeeed < dZeeed < dZeeed < ejd d Zee edfed< ddZddZdddeddfdZddeddfdZddZdefdZy)ra^ 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)rr attributesrNrenderrrrF)rrslotDatareturnc b|ji|_|jj||S)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. )r,update)selfslotss r& fillSlotsz Tag.fillSlotss, == DM U# r%c|jj||jD]L\}}|ddk(r|dd}|dk(r&t|tst d|||_>||j|<N|S)a 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 )rextenditems isinstancer TypeErrorr+r*)r0rkwkvs r&__call__z Tag.__call__s2 X&HHJ 'DAqu|crFH}!!S)#HN  %&" ' r%objdeepc*t|dr|j|St|ttfr |Dcgc]}|j ||c}St |rtdt|St|rtdt|S|Scc}w)a 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) hasattrrAr8r"tuple_clonerr DeprecationWarningr)r0r>r?xs r&rDz Tag._clones 3 99T? " dE] +256QDKK4(6 6   -#  J   -#  JJ)7sBc 8|r*|jDcgc]}|j|d}}n|jdd}|jj}|j D]}|j||d||<d}|j r9|j j}|D]}|j||d||<t |j|||j|j|j|j}||_|Scc}w)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*rr+rrr) rrDr*copykeysr,rr)r+rrr)r0r?rF newchildrennewattrskey newslotdatanewtags r&rAz Tag.clones  9=GA4;;q$/GKG--*K??'')==? =C KK t} block from a template. Given a separate representation in the DOM so that they may be round-tripped through rendering without losing information. datar-c"d|jdS)NzCDATA(rTrorPs r&rVzCDATA.__repr__Hs }A&&r%NrrrrrrrVr$r%r&rnrn=s I7'#'r%rnc*eZdZUdZeed< defdZy)Commentz 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. ror-c"d|jdS)NzComment(rTrqrPs r&rVzComment.__repr__Ws$))a((r%Nrrr$r%r&rtrtLs I2)#)r%rtc*eZdZUdZeed< defdZy)CharRefz 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 ordinalr-c"d|jfzS)Nz CharRef(%d))rxrPs r&rVzCharRef.__repr__gs ..r%N)rrrrr#rrrVr$r%r&rwrw[sLQ/#/r%rw)rinspectrrtypingrrrrr warningsr r twisted.web.templater srr voidElementsrnrtrwr$r%r&rs (-== 0Uu40..1.bUu5t<M.M.=M.` .Uu5t< ' '= 'Uu5t< ) )= )Uu5t< / /= /r%