Re@sddlmZmZmZddlmZddlZddlmZddl m Z ddl m Z ej d Zd d Ze eZdS) )absolute_importdivisionunicode_literals) OrderedDictN) string_types)base)moduleFactoryFactoryz {([^}]*)}(.*)cs>|}|jdjGfdddtj}tS)NZasdcsLeZdZdZfddZddZddZdd Zd S) z#getETreeBuilder..TreeWalkeraGiven the particular ElementTree representation, this implementation, to avoid using recursion, returns "nodes" as tuples with the following content: 1. The current element 2. The index of the element relative to its parent 3. A stack of ancestor elements 4. A flag "text", "tail" or None to indicate if the current node is a text node; either the text or tail of the current element (1) c st|trI|\}}}}|d krCtjt||fS|}t|dsd|j}|jd kr}tjfS|jdkrtj |j |j d|j dfS|jkrtj |j fSt|jt stt|jtj|j}|r'|j\}}nd}|j}t}xmt|jjD]V\} } tj| }|r| ||jd |jd fpublicIdsystemIdrr )r r )rr) isinstancetuplerZTEXTgetattrhasattrgetrootr ZDOCUMENTZDOCTYPEr getCOMMENTrAssertionErrortype tag_regexpmatchgroupsrlistattribitemsgroupZELEMENTlen) selfnodeelt_flagr namespacer attrsnamevalue)ElementTreeCommentType/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-5.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treewalkers/etree.pygetNodeDetails s8    '  "% z2getETreeBuilder..TreeWalker.getNodeDetailscSst|tr$|\}}}}n|dgdf\}}}}|dkrRdS|jrk|||dfSt|r|j||dd|dfSdSdS)Nr r r)r r )rrr r"append)r#r$elementkeyparentsr'r-r-r. getFirstChildHs    z1getETreeBuilder..TreeWalker.getFirstChildcSst|tr$|\}}}}ndS|dkrht|ra|j||dd|dfSdSnc|jr|dkr|||dfS|t|ddkr|d|d|d|dfSdSdS)Nr rr rr5)rrr"r0r )r#r$r1r2r3r'r-r-r.getNextSiblingYs    z2getETreeBuilder..TreeWalker.getNextSiblingcSst|tr$|\}}}}ndS|dkrQ|s>|S|||dfSn^|j}|sg|St|dj|dkst|t|dj||dfSdS)Nr rr5r5)rrpoprcountrindex)r#r$r1r2r3r'parentr-r-r. getParentNodems  %z1getETreeBuilder..TreeWalker.getParentNodeN)__name__ __module__ __qualname____doc__r/r4r6r;r-)r,r-r. TreeWalkers (  r@)Commentr rZNonRecursiveTreeWalkerlocals)ZElementTreeImplementation ElementTreer@r-)r,r.getETreeBuildersnrD) __future__rrr collectionsrreZpip._vendor.sixrr_utilsr compilerrDgetETreeModuler-r-r-r.s  u