Your IP : 216.73.216.196


Current Path : /opt/alt/python37/lib/python3.7/site-packages/py/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/py/__pycache__/_xmlgen.cpython-37.pyc

B

���]�!�@s�dZddlZddlZejdkr2dd�Zddd�Zndd�ZeZGd	d
�d
e�ZGdd�de�Z	ed
e
fde	dd��ZGdd�de	�ZGdd�de�Z
Gdd�de
�ZGdd�de
�ZGdd�de�ZGdd�d�Ze�ZdS)z�
module for generating and serializing xml and html structures
by using simple python objects.

(c) holger krekel, holger at merlinux eu. 2009
�N)�rcCs|S)N�)�srr�;/opt/alt/python37/lib/python3.7/site-packages/py/_xmlgen.py�u
srcCst|d�r|��St|�S)N�__unicode__)�hasattrr�str)�x�errorsrrr�unicodes
rcCst|�S)N)r)rrrrrsc@seZdZdd�ZdS)�NamespaceMetaclasscCsx|dd�dkrt|��|tkr(td��|j}|dk	rF||krFt|��i}|jrX||d<t||jf|�}t|||�|S)N��_zNamespace class is abstract�xmlname)�AttributeError�	Namespace�
ValueError�__tagspec__�__stickyname__�type�__tagclass__�setattr)�self�nameZtagspec�	classattr�clsrrr�__getattr__szNamespaceMetaclass.__getattr__N)�__name__�
__module__�__qualname__rrrrrr
sr
csJeZdZGdd�de�Z�fdd�Zdd�ZeZddd	�Zd
d�Z	�Z
S)
�Tagc@seZdZdd�ZdS)zTag.AttrcKs|j�|�dS)N)�__dict__�update)r�kwargsrrr�__init__(szTag.Attr.__init__N)rrr r%rrrr�Attr'sr&cs"tt|��|�|jf|�|_dS)N)�superr!r%r&�attr)r�argsr$)�	__class__rrr%+szTag.__init__cCs|jdd�S)Nr)�indent)r)rrrrr/szTag.__unicode__�cCs$g}t|j|��|�td��|�S)N�)�SimpleUnicodeVisitor�append�visitr�join)rr+�lrrrr3szTag.unicodecCs|jj}d|t|�fS)Nz<%r tag object %d>)r*r�id)rrrrr�__repr__8szTag.__repr__)r,)rrr �objectr&r%r�__str__rr4�
__classcell__rr)r*rr!&s
r!rF)rrrc@seZdZddd�ZdS)�HtmlTagr,cCs(g}t|j|dd��|�td��|�S)NF)�
shortemptyr-)�HtmlVisitorr/r0rr1)rr+r2rrrrCszHtmlTag.unicodeN)r,)rrr rrrrrr8Bsr8c@s<eZdZeZdZedd�d�d�D��ZGdd�de	�Z
dS)	�htmlTcCsg|]}|r|df�qS)rr)�.0r
rrr�
<listcomp>Ls
zhtml.<listcomp>a�a,abbr,acronym,address,applet,area,article,aside,audio,b,base,basefont,bdi,bdo,big,blink,blockquote,body,br,button,canvas,caption,center,cite,code,col,colgroup,command,comment,datalist,dd,del,details,dfn,dir,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,font,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,img,input,ins,isindex,kbd,keygen,label,legend,li,link,listing,map,mark,marquee,menu,meta,meter,multicol,nav,nobr,noembed,noframes,noscript,object,ol,optgroup,option,output,p,param,pre,progress,q,rp,rt,ruby,s,samp,script,section,select,small,source,span,strike,strong,style,sub,summary,sup,table,tbody,td,textarea,tfoot,th,thead,time,title,tr,track,tt,u,ul,xmp,var,video,wbr�,c@seZdZdd�ZdS)z
html.StylecKs2x,|��D] \}}|�dd�}t|||�q
WdS)Nr�-)�items�replacer)r�kwr
�yrrrr%\szhtml.Style.__init__N)rrr r%rrrr�Style[srDN)rrr r8rr�dict�splitrr5rDrrrrr;Isr;c@seZdZdZdd�ZdS)�rawz]just a box that can contain a unicode string that will be
    included directly in the outputcCs
||_dS)N)�uniobj)rrHrrrr%eszraw.__init__N)rrr �__doc__r%rrrrrGbsrGc@sjeZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)r.z% recursive visitor to write unicode. rTcCs.||_i|_i|_||_||_g|_||_dS)N)�write�cache�visitedr+�	curindent�parentsr9)rrJr+rMr9rrrr%jszSimpleUnicodeVisitor.__init__cCsn|j}y|j|}WnLtk
r`x,|jD]}t||jd�}|dk	r,Pq,W|j}||j|<YnX||�dS)z( dispatcher on node's class/bases name. N)r*rK�KeyError�__mro__�getattrr�_SimpleUnicodeVisitor__object)r�noderZvisitmethod�subclassrrrr0sszSimpleUnicodeVisitor.visitcCs|�tt|���dS)N)rJ�escaper)r�objrrrZ__object�szSimpleUnicodeVisitor.__objectcCs|�|j�dS)N)rJrH)rrVrrrrG�szSimpleUnicodeVisitor.rawcCs<t|�|jkst�d|jt|�<x|D]}|�|�q&WdS)Nr)r3rL�AssertionErrorr0)rrV�elemrrr�list�s
zSimpleUnicodeVisitor.listcCsRt|�|jkst�y|jd|_Wntk
r<d|_YnXd|jt|�<t|d|jj�}|j	r�|�
|�s�|�dtd�|j	�|�r|j	|j
7_	|�td�||�|�f�|j�|�x|D]}|�|�q�W|j��|�td�|�|j	|j
8_	nF||�|�}|�|��r8|�td�|f�n|�td	�||f�dS)
N���rr�
� z<%s%s>z</%s>z<%s/>z	<%s></%s>)r3rLrWrN�parent�
IndexErrorrQr*rrM�	_isinlinerJrr+�
attributesr/r0�pop�_issingleton)r�tag�tagnamer
Znameattrrrrr!�s,

zSimpleUnicodeVisitor.TagcCsbt|j�}|��g}x,|D]$}|�|j|�}|dk	r|�|�qW|�|�|��td��|�S)Nr-)	�dirr(�sort�repr_attributer/�extend�getstylerr1)rrcZattrlistr2r�resrrrr`�s

zSimpleUnicodeVisitor.attributescCs^|dd�dkrZt||�}|�d�r0|dd�}t|t�rB|j}ntt|��}d||fSdS)Nr,�__rrZz %s="%s")rQ�endswith�
isinstancerGrHrUr)r�attrsr�value�insertrrrrg�s


z#SimpleUnicodeVisitor.repr_attributecCsPy|jj}Wntk
r gSXdd�|��D�}td�td��|�gSdS)z- return attribute list suitable for styling. cSsg|]\}}|d|�qS)z: r)r<r
rCrrrr=�sz1SimpleUnicodeVisitor.getstyle.<locals>.<listcomp>z style="%s"z; N)Zstyler"rr@rr1)rrcZ	styledictZ	stylelistrrrri�szSimpleUnicodeVisitor.getstylecCs|jS)z*can (and will) be overridden in subclasses)r9)rrdrrrrb�sz!SimpleUnicodeVisitor._issingletoncCsdS)z*can (and will) be overridden in subclassesFr)rrdrrrr_�szSimpleUnicodeVisitor._isinlineN)rrT)rrr rIr%r0rRrGrYr!r`rgrirbr_rrrrr.hs
	
r.cs\eZdZedd�d�d�D��Zedd�d�d�D��Z�fdd	�Zd
d�Zdd
�Z	�Z
S)r:cCsg|]}|df�qS)rr)r<r
rrrr=�szHtmlVisitor.<listcomp>z3br,img,area,param,col,hr,meta,link,base,input,framer>cCsg|]}|df�qS)rr)r<r
rrrr=�sz�a abbr acronym b basefont bdo big br cite code dfn em font i img input kbd label q s samp select small span strike strong sub sup textarea tt u varr\cs0|dkrt||�}|dkrdStt|��||�S)N�class_)rQr'r:rg)rrnrro)r*rrrg�s

zHtmlVisitor.repr_attributecCs
||jkS)N)�single)rrdrrrrb�szHtmlVisitor._issingletoncCs
||jkS)N)�inline)rrdrrrr_�szHtmlVisitor._isinline)rrr rErFrrrsrgrbr_r7rr)r*rr:�sr:c@s$eZdZdd�Zdd�Zdd�ZdS)�_escapecCsbtd�td�td�td�td�td�td�td�td	�td
�i|_t�td��|j����|_dS)N�"z&quot;�<z&lt;�>z&gt;�&z&amp;�'z&apos;�|)rrU�re�compiler1�keys�
charef_rex)rrrrr%�s$z_escape.__init__cCs|j|�d�S)Nr)rU�group)r�matchrrr�	_replacer�sz_escape._replacercCs@yt|�}Wn"tk
r.t|ddd�}YnX|j�|j|�S)z& xml-escape the given unicode string. zutf-8rA)r)r�UnicodeDecodeErrorr~�subr�)rZustringrrr�__call__�s
z_escape.__call__N)rrr r%r�r�rrrrrt�srt)N)rI�sysr{�version_inforrrr
rYr!r5rr8r;rGr.r:rtrUrrrr�<module>s&

l