Your IP : 216.73.216.213


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.opt-1.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�nameZtagspecZ	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)rrrr$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r3�
__classcell__rr)r)rr &s
r rF)rrrc@seZdZddd�ZdS)�HtmlTagr+cCs(g}t|j|dd��|�td��|�S)NF)�
shortemptyr,)�HtmlVisitorr.r/rr0)rr*r1rrrrCszHtmlTag.unicodeN)r+)rrrrrrrrr7Bsr7c@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)rrrr$rrrr�Style[srCN)rrrr7rr�dict�splitrr4rCrrrrr: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)rrGrrrr$eszraw.__init__N)rrr�__doc__r$rrrrrFbsrFc@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�parentsr8)rrIr*rLr8rrrr$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)rJ�KeyError�__mro__�getattrr�_SimpleUnicodeVisitor__object)rZnoderZvisitmethod�subclassrrrr/sszSimpleUnicodeVisitor.visitcCs|�tt|���dS)N)rI�escaper)r�objrrrZ__object�szSimpleUnicodeVisitor.__objectcCs|�|j�dS)N)rIrG)rrTrrrrF�szSimpleUnicodeVisitor.rawcCs<t|�|jkst�d|jt|�<x|D]}|�|�q&WdS)Nr)r2rK�AssertionErrorr/)rrT�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>)r2rKrUrM�parent�
IndexErrorrPr)rrL�	_isinlinerIrr*�
attributesr.r/�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�getstylerr0)rraZattrlistr1r�resrrrr^�s

zSimpleUnicodeVisitor.attributescCs^|dd�dkrZt||�}|�d�r0|dd�}t|t�rB|j}ntt|��}d||fSdS)Nr+�__rrXz %s="%s")rP�endswith�
isinstancerFrGrSr)r�attrsr�value�insertrrrre�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
rBrrrr<�sz1SimpleUnicodeVisitor.getstyle.<locals>.<listcomp>z style="%s"z; N)Zstyler!rr?rr0)rraZ	styledictZ	stylelistrrrrg�szSimpleUnicodeVisitor.getstylecCs|jS)z*can (and will) be overridden in subclasses)r8)rrbrrrr`�sz!SimpleUnicodeVisitor._issingletoncCsdS)z*can (and will) be overridden in subclassesFr)rrbrrrr]�szSimpleUnicodeVisitor._isinlineN)rrT)rrrrHr$r/rQrFrWr r^rergr`r]rrrrr-hs
	
r-cs\eZdZedd�d�d�D��Zedd�d�d�D��Z�fdd	�Zd
d�Zdd
�Z	�Z
S)r9cCsg|]}|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 varrZcs0|dkrt||�}|dkrdStt|��||�S)NZclass_)rPr&r9re)rrlrrm)r)rrre�s

zHtmlVisitor.repr_attributecCs
||jkS)N)�single)rrbrrrr`�szHtmlVisitor._issingletoncCs
||jkS)N)�inline)rrbrrrr]�szHtmlVisitor._isinline)rrrrDrErorprer`r]r6rr)r)rr9�sr9c@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;�|)rrS�re�compiler0�keys�
charef_rex)rrrrr$�s$z_escape.__init__cCs|j|�d�S)Nr)rS�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-8r@)r)r�UnicodeDecodeErrorr{�subr~)rZustringrrr�__call__�s
z_escape.__call__N)rrrr$r~r�rrrrrq�srq)N)rH�sysrx�version_inforrrr
rWr r4rr7r:rFr-r9rqrSrrrr�<module>s&

l