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: //usr/lib/python3/dist-packages/pip/_vendor/html5lib/treewalkers/__pycache__/base.cpython-310.pyc
o

@%Ne4�@s�ddlmZmZmZddlmZddlmZmZm	Z	gd�Z
ejZej
ZejZejZejZejZdZd�e	�Z	Gdd	�d	e�ZGd
d�de�ZdS)
�)�absolute_import�division�unicode_literals)�Node�)�
namespaces�voidElements�spaceCharacters)	�DOCUMENT�DOCTYPE�TEXT�ELEMENT�COMMENT�ENTITY�UNKNOWN�
TreeWalker�NonRecursiveTreeWalkerz<#UNKNOWN#>�c@sleZdZdZdd�Zdd�Zdd�Zdd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zddd�Zdd�Z
dd�ZdS)rz}Walks a tree yielding tokens

    Tokens are dicts that all have a ``type`` field specifying the type of the
    token.

    cCs
||_dS)zCCreates a TreeWalker

        :arg tree: the tree to walk

        N)�tree)�selfr�r�G/usr/lib/python3/dist-packages/pip/_vendor/html5lib/treewalkers/base.py�__init__s
zTreeWalker.__init__cC�t��N��NotImplementedError)rrrr�__iter__#�zTreeWalker.__iter__cC�
d|d�S)z�Generates an error token with the given message

        :arg msg: the error message

        :returns: SerializeError token

        �SerializeError��type�datar)r�msgrrr�error&�
zTreeWalker.errorFccs*�d|||d�V|r|�d�VdSdS)arGenerates an EmptyTag token

        :arg namespace: the namespace of the token--can be ``None``

        :arg name: the name of the element

        :arg attrs: the attributes of the element as a dict

        :arg hasChildren: whether or not to yield a SerializationError because
            this tag shouldn't have children

        :returns: EmptyTag token

        �EmptyTag�r"�name�	namespacer#zVoid element has childrenN�r%)rr*r)�attrs�hasChildrenrrr�emptyTag0s���zTreeWalker.emptyTagcCsd|||d�S)z�Generates a StartTag token

        :arg namespace: the namespace of the token--can be ``None``

        :arg name: the name of the element

        :arg attrs: the attributes of the element as a dict

        :returns: StartTag token

        �StartTagr(r)rr*r)r,rrr�startTagE�
�zTreeWalker.startTagcCsd||d�S)z�Generates an EndTag token

        :arg namespace: the namespace of the token--can be ``None``

        :arg name: the name of the element

        :returns: EndTag token

        �EndTag)r"r)r*r)rr*r)rrr�endTagVs
�zTreeWalker.endTagccs~�|}|�t�}|dt|�t|��}|rd|d�V|}|�t�}|t|�d�}|r3d|d�V|r=d|d�VdSdS)atGenerates SpaceCharacters and Characters tokens

        Depending on what's in the data, this generates one or more
        ``SpaceCharacters`` and ``Characters`` tokens.

        For example:

            >>> from html5lib.treewalkers.base import TreeWalker
            >>> # Give it an empty tree just so it instantiates
            >>> walker = TreeWalker([])
            >>> list(walker.text(''))
            []
            >>> list(walker.text('  '))
            [{u'data': '  ', u'type': u'SpaceCharacters'}]
            >>> list(walker.text(' abc '))  # doctest: +NORMALIZE_WHITESPACE
            [{u'data': ' ', u'type': u'SpaceCharacters'},
            {u'data': u'abc', u'type': u'Characters'},
            {u'data': u' ', u'type': u'SpaceCharacters'}]

        :arg data: the text data

        :returns: one or more ``SpaceCharacters`` and ``Characters`` tokens

        N�SpaceCharactersr!�
Characters)�lstripr	�len�rstrip)rr#�middle�left�rightrrr�textds�

�zTreeWalker.textcCr)zdGenerates a Comment token

        :arg data: the comment

        :returns: Comment token

        �Commentr!r)rr#rrr�comment�r&zTreeWalker.commentNcCsd|||d�S)z�Generates a Doctype token

        :arg name:

        :arg publicId:

        :arg systemId:

        :returns: the Doctype token

        �Doctype)r"r)�publicId�systemIdr)rr)r@rArrr�doctype�r1zTreeWalker.doctypecCr)zjGenerates an Entity token

        :arg name: the entity name

        :returns: an Entity token

        �Entity)r"r)r)rr)rrr�entity�r&zTreeWalker.entitycCs|�d|�S)zHandles unknown node typeszUnknown node type: r+)r�nodeTyperrr�unknown�szTreeWalker.unknown)F)NN)�__name__�
__module__�__qualname__�__doc__rrr%r.r0r3r<r>rBrDrFrrrrrs

&


rc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)rcCrrr�r�noderrr�getNodeDetails�rz%NonRecursiveTreeWalker.getNodeDetailscCrrrrKrrr�
getFirstChild�rz$NonRecursiveTreeWalker.getFirstChildcCrrrrKrrr�getNextSibling�rz%NonRecursiveTreeWalker.getNextSiblingcCrrrrKrrr�
getParentNode�rz$NonRecursiveTreeWalker.getParentNodeccs��|j}|dur�|�|�}|d|dd�}}d}|tkr%|j|�Vni|tkr5|j|�D]}|Vq.nY|tkre|\}}}}|rG|tdkr\|tvr\|�	||||�D]}|VqSd}n2|�
|||�Vn)|tkrr|�|d�Vn|t
kr|�|d�Vn|tkr�d}n|�|d�V|r�|�|�}	nd}	|	dur�|	}nN|dur�|�|�}|d|dd�}}|tkr�|\}}}}|r�|tdks�|tvr�|�||�V|j|ur�d}n|�|�}
|
dur�|
}n	|�|�}|dus�|dusdSdS)Nr�F�htmlT)rrMrrBrr<r
rrr.r0rr>rrDr
rFrNr3rOrP)r�currentNode�detailsr"r-�tokenr*r)�
attributes�
firstChild�nextSiblingrrrr�sd�
�
�



��zNonRecursiveTreeWalker.__iter__N)rGrHrIrMrNrOrPrrrrrr�srN)�
__future__rrr�xml.domr�	constantsrrr	�__all__�
DOCUMENT_NODEr
�DOCUMENT_TYPE_NODEr�	TEXT_NODEr�ELEMENT_NODEr
�COMMENT_NODEr�ENTITY_NODErr�join�objectrrrrrr�<module>s
!