Viewing File: /opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyo

ó
“tÆ_c@`sudZddlmZmZmZddlZddlZddlZyddlm	Z	Wn!e
k
r}ddlm	Z	nXddlm
Z
ddlmZdd	lmZdd
lmZddlmZddljZddlmZmZeZejd
ƒZejdƒjZdefd„ƒYZdefd„ƒYZ d„Z!d„Z"de
j#fd„ƒYZ#dS(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_literalsN(tMutableMappingi(tbasei(tDataLossWarning(t	constants(tetree(t	_ihatexml(tPY3tbinary_typeu
{([^}]*)}(.*)uasdtDocumentTypecB`seZd„ZRS(cC`s||_||_||_dS(N(tnametpublicIdtsystemId(tselfRR
R((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt__init__)s		(t__name__t
__module__R(((s]/opt/alt/python35/lib/python3.5/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((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyR0s	cC`sC|jjƒ}x|jjƒjƒD]}q%W|j|jƒdS(N(Rtgetroottitersiblingstaddnextt_element(Rtelementtlast((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pytappendChild4scC`s|jS(N(R(R((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt_getChildNodes;s(RRRRRtpropertyt
childNodes(((s]/opt/alt/python35/lib/python3.5/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(s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRHEsp
		"

$

)	%

u
(Rt
InfosetFiltertTruetjoin(R((RFRGRHs]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyttestSerializerAs
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(R"R$R%tdoctypeR(R#RR.R/R0R8RKR9R1(RR=RRCtattrRE(RGRH(s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRH”s*		2	
u(RK(R((RGRHs]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyttostrings 
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(	NtfullTreeR!t
Attributesc`sVeZd„Z‡fd†Zd„Zd„Zd„Zd„Zd„Zd„Z	RS(cS`s
||_dS(N(R(RR((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRÇsc`sFt|tƒr3d|dˆj|dƒf}nˆj|ƒ}|S(Nu{%s}%sii(R+ttupletcoerceAttribute(RtkeyR(RF(s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt
_coerceKeyÊs$cS`sH|jjj|j|ƒ}trDt|tƒrD|jdƒ}n|S(Nuascii(RR8RVR	R+R
tdecode(RRURC((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt__getitem__ÑscS`s ||jjj|j|ƒ<dS(N(RR8RV(RRURC((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt__setitem__×scS`s|jjj|j|ƒ=dS(N(RR8RV(RRU((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt__delitem__ÚscS`st|jjjƒS(N(titerRR8(R((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt__iter__ÝscS`st|jjjƒS(N(tlenRR8(R((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt__len__àscS`s|jjjjƒS(N(RR8tclear(R((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyR_ãs(
RRRRVRXRYRZR\R^R_((RF(s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRRÆs						tElementc`s‰eZ‡‡‡fd†Z‡fd†Z‡fd†ZeeeƒZd„Zd„ZeeeƒZ	d‡‡fd†Zd„ZRS(c`s;ˆj|ƒ}ˆjj||d|ƒˆ|ƒ|_dS(Nt	namespace(t
coerceElementR`Rt_attributes(RRRa(RRtbuilderRF(s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRçsc`s4ˆj|ƒ|_|j|j|jƒ|j_dS(N(Rbt_namet_getETreeTagt
_namespaceRR.(RR(RF(s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt_setNameìsc`sˆj|jƒS(N(R7Re(R(RF(s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt_getNameñscS`s|jS(N(Rc(R((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt_getAttributesöscS`s$|j}|jƒ|j|ƒdS(N(RBR_tupdate(RRCRB((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt_setAttributesùs	
c`s)ˆj|ƒ}ˆjj|||ƒdS(N(tcoerceCharactersR`t
insertText(RtdatatinsertBefore(RdRF(s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRnscS`sGt|ƒ|j|jƒ}|jjrC|jjj|jjƒn|S(N(ttypeRRaRR8Rk(RR((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt	cloneNodesN(
RRRRhRiRRRjRlRBRRnRr((RRRdRF(s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyR`æs		tCommentc`sAeZ‡‡fd†Z‡fd†Zd„ZeeeƒZRS(c`s&ˆj|ƒ}ˆjj||ƒdS(N(t
coerceCommentRsR(RRo(RdRF(s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRsc`sˆj|ƒ}||j_dS(N(RtRR0(RRo(RF(s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt_setDatascS`s
|jjS(N(RR0(R((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt_getDatas(RRRRuRvRRo((RdRF(s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRs
s	(R2tgetETreeModuleRRRIRJRFtnamespaceHTMLElementsRR`RstelementClasstcommentClassRRPR(RRxRQR`Rs((RRRdRFs]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRÁs	 %$"		cC`s2tjj|ƒ|j|_g|_d|_dS(N(RRPtresettinsertCommentInitialt
insertCommenttinitial_commentsRRM(R((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyR{s	cC`s
t|ƒS(N(RL(RR((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRL#scC`s$tr|jjS|jjjƒSdS(N(RQtdocumentRR(R((s]/opt/alt/python35/lib/python3.5/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openElementsRR0R#textendtlistR1(RtfragmentR((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pytgetFragment,s		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(twarningstwarnRRRMRFRbtdoctypeClass(RttokenRR
RtcoercedNameRM((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt
insertDoctype6s


cC`s|jj|ƒdS(N(R~R#(RRotparent((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyR|FscC`s^||jkrA|jjjƒdjtkrAtjdtƒntt	|ƒj
||ƒdS(Niÿÿÿÿu@lxml cannot represent adjacent comments beyond the root elements(RRRR.R/R†R‡RtsuperRPR}(RRoRŒ((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pytinsertCommentMainKscC`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(Nuu<!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}%s(RMRR
RRRFtcoercePubidtfindR†R‡RtreplaceRt
fromstringR~RztaddpreviousRt
documentClassRtgetroottreeRtgettdefaultNamespaceR.RyRR#RRŽR}(RR‰tdocStrtsysidtroott
comment_tokentcommentRRat	etree_tagtroot_element((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt
insertRootQsJ	 *



			N(RRRR”RRˆRRyRzt
fragmentClassRtimplementationtFalseRR{RLR€R…R‹R|RŽRŸ(((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRP¹s\				
	($t__doc__t
__future__RRRR†tretsystcollections.abcRtImportErrortcollectionstRRRRR2Rt
lxml.etreetpip._vendor.sixR	R
RJRQtcompileR3RsR.R/tobjectRRRLRORP(((s]/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt<module>
s.
	O	)
Back to Directory File Manager