ó `8(Zc@`s'dZddlmZmZmZddlZddlZddlZddlm Z ddl m Z ddlm 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 ((sI/tmp/pip-build-0nEYGB/pip/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt__init__#s  (t__name__t __module__R (((sI/tmp/pip-build-0nEYGB/pip/pip/_vendor/html5lib/treebuilders/etree_lxml.pyR"stDocumentcB`s/eZd„Zd„Zd„ZeeƒZRS(cC`sd|_g|_dS(N(tNonet _elementTreet _childNodes(R ((sI/tmp/pip-build-0nEYGB/pip/pip/_vendor/html5lib/treebuilders/etree_lxml.pyR *s cC`s|jjƒj|jƒdS(N(Rtgetroottaddnextt_element(R telement((sI/tmp/pip-build-0nEYGB/pip/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt appendChild.scC`s|jS(N(R(R ((sI/tmp/pip-build-0nEYGB/pip/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt_getChildNodes1s(RRR RRtpropertyt childNodes(((sI/tmp/pip-build-0nEYGB/pip/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ƒqWn|jräˆjd d|d|jfƒn|d7}x|D]} ˆ| |ƒqõWt|d ƒrI|jrIˆjd d|d|jfƒndS(Nutagugetrootu #documentu uu|%s%su iiu|%s"%s"u#document-fragmentu|%sutailiu |%s<%s %s>u|%s<%s>uattribu%s %su |%s%s="%s"("thasattrtappendtdocinfot internalDTDt public_idt system_urlt root_nameRt getpreviousRtgetnextt isinstancetstrtbytestsyst version_infotAssertionErrorttagt comment_typettextttailRt_Elementtetree_builderst tag_regexptmatchtgroupRtprefixest fromXmlNametattribtitemstgroupstsorted( Rtindenttdtd_strt next_elementtnsmatchtnsR,tprefixt attributesR tvaluet attr_stringtchild(t infosetFiltertrvtserializeElement(sI/tmp/pip-build-0nEYGB/pip/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRG;st      " (  $    ) %  u (Rt InfosetFiltertTruetjoin(R((RERFRGsI/tmp/pip-build-0nEYGB/pip/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ƒnUdj g|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 u u<%s>u u%s="%s"u<%s %s>uutail(RRR tdoctypeR#RRR,R-R.R7RJR8R/(RR<R RBtattrRD(RFRG(sI/tmp/pip-build-0nEYGB/pip/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRGŠs*    2  u(RJ(R((RFRGsI/tmp/pip-build-0nEYGB/pip/pip/_vendor/html5lib/treebuilders/etree_lxml.pyttostring†s t TreeBuildercB`s†eZeZeZd Zd ZeZ e Z e 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|unameuGlxml cannot represent doctype with a different name to the root elementu$udatau namespaceu{%s}%sN( RLR R+R RR REt coercePubidtfindRzR{RtreplaceRt fromstringRrRnt addpreviousRt documentClassRst getroottreeRtgettdefaultNamespaceR,RmRRRuR‚Rq( R R}tdocStrtsysidtroott comment_tokentcommentR RXt etree_tagt root_element((sI/tmp/pip-build-0nEYGB/pip/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt insertRoot7sL    *        N(RRRRˆRR|RRmRnt fragmentClassRtimplementationtFalseR RoRKRtRyRRpR‚R“(((sI/tmp/pip-build-0nEYGB/pip/pip/_vendor/html5lib/treebuilders/etree_lxml.pyRO¯s L      (t__doc__t __future__RRRRztreR)tRRRRR1Rt lxml.etreeRIRPtcompileR2RgR,R-tobjectRRRKRNRO(((sI/tmp/pip-build-0nEYGB/pip/pip/_vendor/html5lib/treebuilders/etree_lxml.pyt s$    O )