Your IP : 3.146.176.112


Current Path : /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.pyo

�
��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
`s
t|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�Wq	t|t�s+t|t
�rI�jd	d||f�q	�jd
�x�|D]}�||d�q]Wn�|jtkr��jdd||jf�t|d�r	|jr	�jd	d||jf�q	n%tjj|j�}|dk	rZ|jd
�}|jd�}tj|}�jdd||�j|�f�n'�jdd|�j|j�f�t|d�rvg}x�|jj�D]�\}	}
tj|	�}|dk	r|j�\}}	�j|	�}	tj|}d||	f}n�j|	�}|j||
f�q�Wx?t|�D].\}	}
�jdd|d|	|
f�qAWn|jr��jd	d|d|jf�n|d7}x|D]}�||�q�Wt|d�r	|jr	�jd	d|d|jf�ndS(Nutagugetrootu	#documentu
<!DOCTYPE %s>u<!DOCTYPE %s "%s" "%s">u|%s%su iu|%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
isinstancetstrtbytesttagtcomment_typettextttailtetree_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.pyRC;sp
		"

$

)	%

u
(Rt
InfosetFiltertTruetjoin(R((RARBRCsP/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+R3RFR4R,(RR8R	R>tattrR@(RBRC(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRC�s*		2	
u(RF(R((RBRCsP/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
R4R&ttupletcoerceAttributeR3(RRR>tkeyR	(RA(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(RNt__setitem__R&RORPRR3(RRQR>R	(RA(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRR�s
$N(RRRR
RR((RA(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRM�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
coerceElementRSR
t_attributes(RR	RT(RMtbuilderRA(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyR
�sc`s4�j|�|_|j|j|j�|j_dS(N(RUt_namet_getETreeTagt
_namespaceRR)(RR	(RA(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt_setName�sc`s�j|j�S(N(R2RX(R(RA(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt_getName�scS`s|jS(N(RV(R((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt_getAttributes�sc`s�||�|_dS(N(RV(RR=(RM(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt_setAttributes�sc`s)�j|�}�jj|||�dS(N(tcoerceCharactersRSt
insertText(RtdatatinsertBefore(RWRA(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyR`�sc`s�jj||�dS(N(RSR(RR@(RW(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyR�sN(
RRR
R[R\RR	R]R^R=RR`R((RMRWRA(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRS�s	tCommentc`sAeZ��fd�Z�fd�Zd�Zeee�ZRS(c`s&�j|�}�jj||�dS(N(t
coerceCommentRcR
(RRa(RWRA(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyR
�sc`s�j|�}||j_dS(N(RdRR+(RRa(RA(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
ReRfRRa((RWRA(sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRc�s	(R-tgetETreeModuleRRRDRERAtnamespaceHTMLElementsRNRSRctelementClasstcommentClassRRKR
(RRhRLRSRc((RMRWRAsP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyR
�s	%"		cC`s2tjj|�|j|_g|_d|_dS(N(RRKtresettinsertCommentInitialt
insertCommenttinitial_commentsRRH(R((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRks	cC`s
t|�S(N(RG(RR((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRG	scC`s$tr|jjS|jjj�SdS(N(RLtdocumentRR(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(twarningstwarnRRRHRARUtdoctypeClass(RttokenR	R
RtcoercedNameRH((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt
insertDoctypes


cC`s|jj|�dS(N(RnR(RRatparent((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRl,scC`s^||jkrA|jjj�djtkrAtjdt�ntt	|�j
||�dS(Ni����u@lxml cannot represent adjacent comments beyond the root elements(RoRRR)R*RvRwRtsuperRKRm(RRaR|((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pytinsertCommentMain1scC`sZd}|jrN|d|jj7}|jjdk	sG|jjdk	r|d|jj|jjped�7}|jjr|jj}|jd�dkr�|jd�dkr�tj	dt
�|jdd�}n|jd�dkr�|d	|7}q|d
|7}q|d7}n|d7}|jj|d
krNtj	dt
�qNn|d7}tj
|�}x4|jD])}|j|d�}|j|j�qqW|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(RHR	R
RRRAtcoercePubidtfindRvRwRtreplaceRt
fromstringRnRjtaddpreviousRt
documentClassRotgetroottreeRtgettdefaultNamespaceR)RiRRRqR~Rm(RRytdocStrtsysidtroott
comment_tokentcommentR	RTt	etree_tagtroot_element((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt
insertRoot7sJ	 *



			N(RRRR�RRxRRiRjt
fragmentClassRtimplementationtFalseR
RkRGRpRuR{RlR~R�(((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRK�sL				
	(t__doc__t
__future__RRRRvtretsystRRRRR-Rt
lxml.etreeRERLtcompileR.RcR)R*tobjectRRRGRJRK(((sP/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt<module>
s$	O	)

?>