ok

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/
Upload File :
Current File : //usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyc

�
��abc@`s'dZddlmZmZmZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
dd	lmZ
dd
lmZddljZeZejd�Zejd�jZd
efd��YZdefd��YZd�Zd�Zde	jfd��YZdS(u�Module for supporting the lxml.etree library. The idea here is to use as much
of the native library as possible, without using fragile hacks like custom element
names that break between releases. The downside of this is that we cannot represent
all possible trees; specifically the following are known to cause problems:

Text or comments as siblings of the root element
Docypes with no name

When any of these things occur, we emit a DataLossWarning
i(tabsolute_importtdivisiontunicode_literalsNi(tbasei(tDataLossWarning(t	constants(tetree(t	_ihatexmlu
{([^}]*)}(.*)uasdtDocumentTypecB`seZd�ZRS(cC`s||_||_||_dS(N(tnametpublicIdtsystemId(tselfR	R
R((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt__init__#s		(t__name__t
__module__R
(((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyR"stDocumentcB`s/eZd�Zd�Zd�Zee�ZRS(cC`sd|_g|_dS(N(tNonet_elementTreet_childNodes(R((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyR
*s	cC`s|jj�j|j�dS(N(Rtgetroottaddnextt_element(Rtelement((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pytappendChild.scC`s|jS(N(R(R((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt_getChildNodes1s(RRR
RRtpropertyt
childNodes(((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyR)s			c`sJg�tjdt��d���fd���|d�dj��S(NtpreventDoubleDashCommentsic
`sMt|d�s�t|d�r
�jd�|jjr�|jjpL|jjsbd|jj}n%d|jj|jj|jjf}�jdd|d|f�n|j�}x"|j�dk	r�|j�}q�Wx�|dk	r	�||d�|j
�}q�WqIt|t�s+t|t
�rqt|t�sStjd	dksSt��jd
d||f�qI�jd�x�|D]}�||d�q�Wn�|jtkr�jdd||jf�t|d
�rI|jrI�jd
d||jf�qIn=t|tj�s$t�tjj|j�}|dk	r�|jd�}|jd�}tj|}�jdd||�j|�f�n'�jdd|�j|j�f�t|d�r�g}x�|jj�D]�\}	}
tj|	�}|dk	rN|j �\}}	�j|	�}	tj|}d||	f}n�j|	�}|j||
f�q�Wx?t!|�D].\}	}
�jdd|d|	|
f�q�Wn|jr��jd
d|d|jf�n|d7}x|D]}�||�q�Wt|d
�rI|jrI�jd
d|d|jf�ndS(Nutagugetrootu	#documentu
<!DOCTYPE %s>u<!DOCTYPE %s "%s" "%s">u|%s%su iiu|%s"%s"u#document-fragmentu|%s<!-- %s -->utailiu
|%s<%s %s>u|%s<%s>uattribu%s %su
|%s%s="%s"("thasattrtappendtdocinfotinternalDTDt	public_idt
system_urlt	root_nameRtgetpreviousRtgetnextt
isinstancetstrtbytestsystversion_infotAssertionErrorttagtcomment_typettextttailRt_Elementtetree_builderst
tag_regexptmatchtgroupRtprefixestfromXmlNametattribtitemstgroupstsorted(
Rtindenttdtd_strtnext_elementtnsmatchtnsR,tprefixt
attributesR	tvaluetattr_stringtchild(t
infosetFiltertrvtserializeElement(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRG;st
		"(

$

)	%

u
(Rt
InfosetFiltertTruetjoin(R((RERFRGsP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyttestSerializer7s
F
c`s/g���fd���|�dj��S(u4Serialize an element and its child nodes to a stringc`s�t|d�si|jjrV|jjr6|jj}nd|jj}�j|�n�|j��n�|jtkr��jd|j	f�n�|j
s��jd|jf�nUdjg|j
j�D]\}}d||f^q��}�jd|j|f�|j	r&�j|j	�nx|D]}�|�q-W�jd|jf�t|d	�r�|j
r��j|j
�ndS(
Nutagu
<!DOCTYPE %s>u	<!--%s-->u<%s>u u%s="%s"u<%s %s>u</%s>utail(RRR tdoctypeR#RRR,R-R.R7RJR8R/(RR<R	RBtattrRD(RFRG(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRG�s*		2	
u(RJ(R((RFRGsP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyttostring�s 
tTreeBuildercB`s�eZeZeZd	Zd	ZeZ	e
Zed�Z
d�Zd�Zd�Zd�Zd�Zd	d�Zd	d�Zd�ZRS(
c`s�tjtd|��tjdt��|_||_dtf�fd��Y�d�j	f���fd��Y}d�j
f��fd��Y}||_||_t
jj||�dS(	NtfullTreeRt
Attributesc`s)eZd�fd�Z�fd�ZRS(c`s�|dkri}n||_tj||�xo|j�D]a\}}t|t�rzd|d�j|d�f}n�j|�}||jjj|<q;WdS(Nu{%s}%sii(	RRtdictR
R8R&ttupletcoerceAttributeR7(RRRBtkeyR	(RE(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyR
�s		$c`sltj|||�t|t�rFd|d�j|d�f}n�j|�}||jjj|<dS(Nu{%s}%sii(RRt__setitem__R&RSRTRR7(RRURBR	(RE(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRV�s
$N(RRRR
RV((RE(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRQ�stElementc`s�eZ���fd�Z�fd�Z�fd�Zeee�Zd�Z�fd�Zeee�Z	d��fd�Z�fd�ZRS(c`s;�j|�}�jj||d|��|�|_dS(Nt	namespace(t
coerceElementRWR
t_attributes(RR	RX(RQtbuilderRE(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyR
�sc`s4�j|�|_|j|j|j�|j_dS(N(RYt_namet_getETreeTagt
_namespaceRR,(RR	(RE(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt_setName�sc`s�j|j�S(N(R6R\(R(RE(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt_getName�scS`s|jS(N(RZ(R((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt_getAttributes�sc`s�||�|_dS(N(RZ(RRA(RQ(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt_setAttributes�sc`s)�j|�}�jj|||�dS(N(tcoerceCharactersRWt
insertText(RtdatatinsertBefore(R[RE(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRd�sc`s�jj||�dS(N(RWR(RRD(R[(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyR�sN(
RRR
R_R`RR	RaRbRARRdR((RQR[RE(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRW�s	tCommentc`sAeZ��fd�Z�fd�Zd�Zeee�ZRS(c`s&�j|�}�jj||�dS(N(t
coerceCommentRgR
(RRe(R[RE(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyR
�sc`s�j|�}||j_dS(N(RhRR.(RRe(RE(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt_setData�scS`s
|jjS(N(RR.(R((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt_getData�s(RRR
RiRjRRe((R[RE(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRg�s	(R1tgetETreeModuleRRRHRIREtnamespaceHTMLElementsRRRWRgtelementClasstcommentClassRROR
(RRlRPRWRg((RQR[REsP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyR
�s	%"		cC`s2tjj|�|j|_g|_d|_dS(N(RROtresettinsertCommentInitialt
insertCommenttinitial_commentsRRL(R((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRos	cC`s
t|�S(N(RK(RR((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRK	scC`s$tr|jjS|jjj�SdS(N(RPtdocumentRR(R((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pytgetDocuments
cC`seg}|jdj}|jr2|j|j�n|jt|��|jra|j|j�n|S(Ni(topenElementsRR.RtextendtlistR/(RtfragmentR((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pytgetFragments		cC`s�|d}|d}|d}|s@tjdt�d|_nO|jj|�}||krqtjdt�n|j|||�}||_dS(NunameupublicIdusystemIdu#lxml cannot represent empty doctypeu%lxml cannot represent non-xml doctype(twarningstwarnRRRLRERYtdoctypeClass(RttokenR	R
RtcoercedNameRL((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt
insertDoctypes


cC`sM|dks!||jks!t�|jjdks9t�|jj|�dS(N(RRsR+RRrR(RRetparent((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRp,s!cC`s^||jkrA|jjj�djtkrAtjdt�ntt	|�j
||�dS(Ni����u@lxml cannot represent adjacent comments beyond the root elements(RsRRR,R-RzR{RtsuperRORq(RReR�((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pytinsertCommentMain1scC`sld}|jr`|jjs!t�|d|jj7}|jjdk	sY|jjdk	r*|d|jj|jjpwd�7}|jjr|jj}|jd�dkr�|jd�dkr�t	j
dt�|jdd�}n|jd�dkr|d	|7}q'|d
|7}q*|d7}n|d7}|jj|d
kr`t	j
dt�q`n|d7}t
j|�}x4|jD])}|j|d�}|j|j�q�W|j�|_|j�|j_|d
}|jd|j�}|dkr|}	nd||f}	|	|_|j||�}
||
_|jjj|
�|jj|
�|j|_dS(uCreate the document rootuu<!DOCTYPE %su
 PUBLIC "%s" u'iu"u6DOCTYPE system cannot contain single and double quotesuU00027u"%s"u'%s'u''u>unameuGlxml cannot represent doctype with a different name to the root elementu$<THIS_SHOULD_NEVER_APPEAR_PUBLICLY/>udatau	namespaceu{%s}%sN( RLR	R+R
RRREtcoercePubidtfindRzR{RtreplaceRt
fromstringRrRntaddpreviousRt
documentClassRstgetroottreeRtgettdefaultNamespaceR,RmRRRuR�Rq(RR}tdocStrtsysidtroott
comment_tokentcommentR	RXt	etree_tagtroot_element((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt
insertRoot7sL	 *



			N(RRRR�RR|RRmRnt
fragmentClassRtimplementationtFalseR
RoRKRtRyRRpR�R�(((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRO�sL				
	(t__doc__t
__future__RRRRztreR)tRRRRR1Rt
lxml.etreeRIRPtcompileR2RgR,R-tobjectRRRKRNRO(((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt<module>
s$	O	)

Zerion Mini Shell 1.0