Your IP : 3.147.103.33


Current Path : /lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/
Upload File :
Current File : //lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyc

�
��abc@`s�ddlmZmZmZddlmZddlZddlmZddlm	Z	ddlm
Z
dd	l
mZdd
lm
Z
ejd�Zed�Ze
e�ZdS(
i(tabsolute_importtdivisiontunicode_literals(t	text_typeNi(tbasei(t	_ihatexml(t	constants(t
namespaces(tmoduleFactoryFactoryu
{([^}]*)}(.*)c
`s���jd�j�dtjf�fd��Y�d�f�fd��Y�d�f�fd��Y�d�f�fd	��Y�d
�f�fd��Y��fd��	��fd
�}dtjf��������	fd��Y}t�S(NuasdtElementc`s�eZd�fd�Zd�Zd�Zd�Zeee�Zd�Z	d�Z
ee
e	�Zd�Zd�Z
eee
�Zd�Zd	�Zeee�Zd
�Zd�Zd�Zd
�Zdd�Zd�Zd�ZRS(c`s�||_||_�j|j||��|_|dkrUtd|jf|_n|j|jf|_d|_g|_	g|_
dS(Nuhtml(t_namet
_namespaceR	t_getETreeTagt_elementtNoneRt	nameTupletparentt_childNodest_flags(tselftnamet	namespace(tElementTree(sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyt__init__s				cS`s)|dkr|}nd||f}|S(Nu{%s}%s(R(RRRt	etree_tag((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyR#s	cS`s+||_|j|j|j�|j_dS(N(R
RRR
ttag(RR((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyt_setName*s	cS`s|jS(N(R
(R((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyt_getName.scS`s+||_|j|j|j�|j_dS(N(RRR
R
R(RR((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyt
_setNamespace3s	cS`s|jS(N(R(R((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyt
_getNamespace7scS`s
|jjS(N(R
tattrib(R((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyt_getAttributes<scS`s�x-t|jjj��D]}|jj|=qWx]|j�D]O\}}t|t�rsd|d|df}n|}|jj||�q=WdS(Nu{%s}%sii(tlistR
Rtkeystitemst
isinstancettupletset(Rt
attributestkeytvalueR((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyt_setAttributes?scS`s|jS(N(R(R((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyt_getChildNodesMscS`s2|j2g|_x|D]}|j|�qWdS(N(R
RtinsertChild(RR(telement((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyt_setChildNodesPs	
cS`st|jjpt|j��S(u,Return true if the node has children or text(tboolR
ttexttlen(R((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyt
hasContentXscS`s0|jj|�|jj|j�||_dS(N(RtappendR
R(Rtnode((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pytappendChild\scS`s>t|j�j|j�}|jj||j�||_dS(N(R R
tindextinsertR(RR3trefNodeR5((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pytinsertBeforeascS`s0|jj|�|jj|j�d|_dS(N(RtremoveR
RR(RR3((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pytremoveChildfscS`s-t|j�s?|jjs*d|j_n|jj|7_n�|dkr�|jdjsnd|jd_n|jdj|7_n�t|j�}|j|j�}|dkr�|j|djs�d|j|d_n|j|dj|7_n-|jjsd|j_n|jj|7_dS(Nui����ii(R0R
R/RttailR R5(RtdataR8tchildrenR5((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyt
insertTextks"cS`sLt|�|j|j�}x*|jj�D]\}}||j|<q+W|S(N(ttypeRRR&R"(RR,RR(((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyt	cloneNode�scS`s�|jr+|jdjj|jj7_nH|jjsFd|j_n|jjdk	rs|jj|jj7_nd|j_tjj||�dS(Ni����u(t
childNodesR
R;R/RRtNodetreparentChildren(Rt	newParent((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyRC�s	"N(t__name__t
__module__RRRRRtpropertyRRRRRR)R&R*R-RAR1R4R8R:R>R@RC((R(sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyR	s*
														tCommentc`s8eZ�fd�Zd�Zd�Zeee�ZRS(c`s1�j|�|_d|_g|_g|_dS(N(RHR
RRRR(RR<(R(sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyR�s		cS`s
|jjS(N(R
R/(R((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyt_getData�scS`s||j_dS(N(R
R/(RR(((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyt_setData�s(RERFRRIRJRGR<((R(sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyRH�s		tDocumentTypec`sYeZ�fd�Zd�Zd�Zeee�Zd�Zd�Zeee�Z	RS(c`s2�j|d�||j_||_||_dS(Nu
<!DOCTYPE>(RR
R/tpublicIdtsystemId(RRRLRM(R	(sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyR�s	cS`s|jjdd�S(NupublicIdu(R
tget(R((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyt_getPublicId�scS`s&|dk	r"|jjd|�ndS(NupublicId(RR
R%(RR(((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyt_setPublicId�scS`s|jjdd�S(NusystemIdu(R
RN(R((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyt_getSystemId�scS`s&|dk	r"|jjd|�ndS(NusystemId(RR
R%(RR(((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyt_setSystemId�s(
RERFRRORPRGRLRQRRRM((R	(sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyRK�s				tDocumentc`seZ�fd�ZRS(c`s�j|d�dS(Nu
DOCUMENT_ROOT(R(R(R	(sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyR�s(RERFR((R	(sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyRS�stDocumentFragmentc`seZ�fd�ZRS(c`s�j|d�dS(NuDOCUMENT_FRAGMENT(R(R(R	(sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyR�s(RERFR((R	(sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyRT�sc`s8g�d���fd���|d�dj��S(Nic`s�t|d�s|j�}n|jdkr�|jd�sK|jd�r�|jd�p]d}|jd�prd}�jd|j||f�q0�jd|jf�n�|jdkrM�jd	�|jdk	r��jd
d|d|jf�n|jdk	rtd
��nt|d�r0t	|j
�r0td��q0n�|j�kr}�jdd||jf�n�t|jt�s�t
dt|j�|jf��tj|j�}|dkr�|j}n/|j�\}}tj|}d||f}�jdd||f�t|d�rg}x�|j
j�D]r\}}	tj|�}|dk	r�|j�\}}tj|}d||f}
n|}
|j|
|	f�qJWx?t|�D].\}}	�jdd|d||	f�q�Wn|jr0�jd
d|d|jf�n|d7}x|D]}�||�qAW|jr��jd
d|d|jf�ndS(Nutagu
<!DOCTYPE>upublicIdusystemIduu<!DOCTYPE %s "%s" "%s">u
<!DOCTYPE %s>u
DOCUMENT_ROOTu	#documentu|%s"%s"u iuDocument node cannot have tailuattribu$Document node cannot have attributesu|%s<!-- %s -->uExpected unicode, got %s, %su%s %su|%s<%s>u
|%s%s="%s"(thasattrtgetrootRRNR2R/RR;t	TypeErrorR0RR#RtAssertionErrorR?t
tag_regexptmatchtgroupsRtprefixesR"tsorted(R,tindentRLRMtnsmatchRtnstprefixR&R(tattr_stringtchild(tElementTreeCommentTypetrvtserializeElement(sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyRf�s^	
%!

)	%

	u
(tjoin(R,(Rd(ReRfsK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyttestSerializer�s7
c`sDg�tj�������fd���|�dj��S(u4Serialize an element and its child nodes to a stringc`smt|�j�r!|j�}n|jdkr�|jd�sN|jd�r�|jd�p`d}|jd�pud}�jd|j||f�qM�jd|jf�n�|jdkrL|jdk	r��j|j�n|jdk	rt	d��nt
|d	�r.t|j�r.t	d
��nx|D]}�|�q5Wn|j�kru�jd|jf�n�|js��jd�j
|j�f�n^d
jg|jj�D]%\}}d�j
|�|f^q��}�jd|j|f�|jr�j|j�nx|D]}�|�q"W�jd|jf�|jri�j|j�ndS(Nu
<!DOCTYPE>upublicIdusystemIduu<!DOCTYPE %s PUBLIC "%s" "%s">u
<!DOCTYPE %s>u
DOCUMENT_ROOTuDocument node cannot have tailuattribu$Document node cannot have attributesu	<!--%s-->u<%s>u u%s="%s"u<%s %s>u</%s>(R#RRVRRNR2R/RR;RWRUR0RtfromXmlNameRgR"(R,RLRMRcRR(tattr(RRdtfilterReRf(sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyRfs@	
	#	;	
	u(Rt
InfosetFilterRg(R,(RRd(RkReRfsK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyttostrings
-
tTreeBuilderc`sSeZ�Z�Z�Z�Z�Z�Z�fd�Z�fd�Z	d�Z
RS(c`s
�|�S(N((RR,(Rh(sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyRhAsc`sP�r|jjS|jdk	r9|jjjd|j�S|jjjd�SdS(Nu{%s}htmluhtml(tdocumentR
tdefaultNamespaceRtfind(R(tfullTree(sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pytgetDocumentDs
cS`stjj|�jS(N(RRntgetFragmentR
(R((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyRtNs(RERFt
documentClasstdoctypeClasstelementClasstcommentClasst
fragmentClasstimplementationRhRsRt((RHRSRTRKR	tElementTreeImplementationRrRh(sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyRn9s
(RHRRRBRntlocals(R{RrRmRn((
RHRSRTRKR	RRdR{RrRhsK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pytgetETreeBuilders~>64(t
__future__RRRtpip._vendor.sixRtretRRRRt_utilsRtcompileRYtFalseR}tgetETreeModule(((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/etree.pyt<module>s�D

?>