HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/pip/_vendor/html5lib/treebuilders/__pycache__/base.cpython-310.pyc
o

@%Ne�8�@s�ddlmZmZmZddlmZddlmZmZm	Z	dZ
ee�dfeee	ddfhB�dfeee	dd	fe	dd
fhB�dfee	ddfe	ddfg�dfee	ddfe	dd
fg�dfd�ZGdd�de
�ZGdd�de�ZGdd�de
�ZdS)�)�absolute_import�division�unicode_literals)�	text_type�)�scopingElements�tableInsertModeElements�
namespacesNF�html�button�ol�ul�table�optgroup�optionT)Nr�listr�selectc@sbeZdZdZdd�Zdd�Zdd�Zdd	�Zddd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
d
S)�NodezRepresents an item in the treecCs(||_d|_d|_i|_g|_g|_dS)zRCreates a Node

        :arg name: The tag name associated with the node

        N)�name�parent�value�
attributes�
childNodes�_flags)�selfr�r�H/usr/lib/python3/dist-packages/pip/_vendor/html5lib/treebuilders/base.py�__init__s
z
Node.__init__cCs6d�dd�|j��D��}|rd|j|fSd|jS)N� cSsg|]
\}}d||f�qS)z%s="%s"r)�.0rrrrr�
<listcomp>.s�z Node.__str__.<locals>.<listcomp>z<%s %s>�<%s>)�joinr�itemsr)r�
attributesStrrrr�__str__-s
�
zNode.__str__cCs
d|jS)Nr!)r�rrrr�__repr__6s
z
Node.__repr__cC�t�)z[Insert node as a child of the current node

        :arg node: the node to insert

        ��NotImplementedError�r�noderrr�appendChild9�zNode.appendChildNcCr()aBInsert data as text in the current node, positioned before the
        start of node insertBefore or to the end of the node's text.

        :arg data: the data to insert

        :arg insertBefore: True if you want to insert the text before the node
            and False if you want to insert it after the node

        r))r�data�insertBeforerrr�
insertTextA�
zNode.insertTextcCr()aInsert node as a child of the current node, before refNode in the
        list of child nodes. Raises ValueError if refNode is not a child of
        the current node

        :arg node: the node to insert

        :arg refNode: the child node to insert the node before

        r))rr,�refNoderrrr0Mr2zNode.insertBeforecCr()zhRemove node from the children of the current node

        :arg node: the child node to remove

        r)r+rrr�removeChildYr.zNode.removeChildcCs |jD]}|�|�qg|_dS)z�Move all the children of the current node to newParent.
        This is needed so that trees that don't store text as nodes move the
        text in the correct way

        :arg newParent: the node to move all this node's children to

        N)rr-)r�	newParent�childrrr�reparentChildrenas
	
zNode.reparentChildrencCr()z�Return a shallow copy of the current node i.e. a node with the same
        name and attributes but with no parent or child nodes
        r)r&rrr�	cloneNodenszNode.cloneNodecCr()zFReturn true if the node has children or text, false otherwise
        r)r&rrr�
hasContenttszNode.hasContent�N)�__name__�
__module__�__qualname__�__doc__rr%r'r-r1r0r4r7r8r9rrrrrs	

rc@seZdZdd�Zdd�ZdS)�ActiveFormattingElementscCsfd}|tkr+|ddd�D]}|tkrn|�||�r|d7}|dkr*|�|�nq
t�||�dS)Nr�����)�Marker�
nodesEqual�remover�append)rr,�
equalCount�elementrrrrF{s
�zActiveFormattingElements.appendcCs$|j|jksdS|j|jksdSdS)NFT)�	nameTupler)r�node1�node2rrrrD�s
z#ActiveFormattingElements.nodesEqualN)r;r<r=rFrDrrrrr?zs
r?c@s�eZdZdZdZdZdZdZdZdd�Z	dd�Z
d+dd�Zd	d
�Zdd�Z
d
d�Zdd�Zdd�Zd+dd�Zdd�Zdd�Zdd�Zeee�Zdd�Zdd�Zd+dd �Zd!d"�Zd+d#d$�Zd%d&�Zd'd(�Zd)d*�ZdS),�TreeBuilderaBase treebuilder implementation

    * documentClass - the class to use for the bottommost node of a document
    * elementClass - the class to use for HTML Elements
    * commentClass - the class to use for comments
    * doctypeClass - the class to use for doctypes

    NcCs|rd|_nd|_|��dS)zmCreate a TreeBuilder

        :arg namespaceHTMLElements: whether or not to namespace HTML elements

        zhttp://www.w3.org/1999/xhtmlN)�defaultNamespace�reset)r�namespaceHTMLElementsrrrr�szTreeBuilder.__init__cCs.g|_t�|_d|_d|_d|_|��|_dS)NF)�openElementsr?�activeFormattingElements�headPointer�formPointer�insertFromTable�
documentClass�documentr&rrrrN�szTreeBuilder.resetcCs�t|d�}|st|t�rtd|f}t|t�sJ�t|\}}t|j�D]}|r/||kr/dS|s9|j|kr9dS||j|vArCdSq$J�)NrIr
TF)	�hasattr�
isinstancerr	�tuple�listElementsMap�reversedrPrI)r�target�variant�	exactNode�listElements�invertr,rrr�elementInScope�s

�zTreeBuilder.elementInScopecCs�|jsdSt|j�d}|j|}|tks||jvrdS|tkr>||jvr>|dkr,d}n|d8}|j|}|tkr>||jvs%	|d7}|j|}|��}|�d|j|j|jd��}||j|<||jdkrgdSq?)NrArr@T�StartTag)�typer�	namespacer/)	rQ�lenrCrPr8�
insertElementrrdr)r�i�entry�clonerHrrr�#reconstructActiveFormattingElements�s4

�	
�
�z/TreeBuilder.reconstructActiveFormattingElementscCs@|j��}|jr|tkr|j��}|jr|tksdSdSdSdSr:)rQ�poprC)rrhrrr�clearActiveFormattingElementss

�z)TreeBuilder.clearActiveFormattingElementscCs:|jddd�D]}|tkrdS|j|kr|SqdS)z�Check if an element exists between the end of the active
        formatting elements and the last marker. If it does, return it, else
        return falseNr@F)rQrCr)rr�itemrrr�!elementInActiveFormattingElements
s
��z-TreeBuilder.elementInActiveFormattingElementscCs&|�|�}|j�|�|j�|�dSr:)�
createElementrPrFrVr-)r�tokenrHrrr�
insertRoots
zTreeBuilder.insertRootcCs6|d}|d}|d}|�|||�}|j�|�dS)Nr�publicId�systemId)�doctypeClassrVr-)rrprrrrs�doctyperrr�
insertDoctype s
zTreeBuilder.insertDoctypecCs*|dur	|jd}|�|�|d��dS)Nr@r/)rPr-�commentClass)rrprrrr�
insertComment(s
zTreeBuilder.insertCommentcCs0|d}|�d|j�}|�||�}|d|_|S)z.Create an element but don't insert it anywhererrdr/)�getrM�elementClassr�rrprrdrHrrrro-s

zTreeBuilder.createElementcC�|jSr:)�_insertFromTabler&rrr�_getInsertFromTable5szTreeBuilder._getInsertFromTablecCs"||_|r|j|_dS|j|_dS)zsSwitch the function used to insert an element from the
        normal one to the misnested table one and back againN)r}�insertElementTablerf�insertElementNormal)rrrrr�_setInsertFromTable8szTreeBuilder._setInsertFromTablecCsb|d}t|t�sJd|��|�d|j�}|�||�}|d|_|jd�|�|j�|�|S)NrzElement %s not unicoderdr/r@)	rXrryrMrzrrPr-rFr{rrrr�Cs
zTreeBuilder.insertElementNormalcCs`|�|�}|jdjtvr|�|�S|��\}}|dur"|�|�n|�||�|j�|�|S)z-Create an element and insert it into the treer@N)	rorPrrr��getTableMisnestedNodePositionr-r0rF)rrprHrr0rrrrMs

zTreeBuilder.insertElementTablecCsX|dur	|jd}|jr|jr|jdjtvr|�|�dS|��\}}|�||�dS)zInsert text data.Nr@)rPrTrrr1r�)rr/rr0rrrr1]s

�zTreeBuilder.insertTextcCs�d}d}d}|jddd�D]}|jdkr|}nq|r7|jr(|j}|}||fS|j|j�|�d}||fS|jd}||fS)zsGet the foster parent element, and sibling to insert before
        (or None) when inserting a misnested table nodeNr@rrAr)rPrr�index)r�	lastTable�fosterParentr0�elmrrrr�ls&
���
�z)TreeBuilder.getTableMisnestedNodePositioncCs@|jdj}|td�vr||kr|j��|�|�dSdSdS)Nr@)�dd�dt�lirr�p�rp�rt)rPr�	frozensetrk�generateImpliedEndTags)r�excluderrrrr��s
�z"TreeBuilder.generateImpliedEndTagscCr|)zReturn the final tree)rVr&rrr�getDocument�szTreeBuilder.getDocumentcCs|��}|jd�|�|S)zReturn the final fragmentr)�
fragmentClassrPr7)r�fragmentrrr�getFragment�szTreeBuilder.getFragmentcCr()z�Serialize the subtree of node in the format required by unit tests

        :arg node: the node from which to start serializing

        r)r+rrr�testSerializer�r.zTreeBuilder.testSerializerr:)r;r<r=r>rUrzrwrtr�rrNrarjrlrnrqrvrxror~r��propertyrTr�rr1r�r�r�r�r�rrrrrL�s8
.

	



rL)�
__future__rrr�pip._vendor.sixr�	constantsrrr	rCr�rZ�objectrrr?rLrrrr�<module>s2

��
��
���c