%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python37/lib/python3.7/site-packages/html5lib/treewalkers/__pycache__/
Upload File :
Create Path :
Current File : //opt/alt/python37/lib/python3.7/site-packages/html5lib/treewalkers/__pycache__/base.cpython-37.pyc

B

63)Z4�	@s�ddlmZmZmZddlmZddlmZmZm	Z	ddddd	d
ddd
g	Z
ejZej
ZejZejZejZejZdZd�e	�Z	Gdd�de�ZGdd
�d
e�ZdS)�)�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�J/opt/alt/python37/lib/python3.7/site-packages/html5lib/treewalkers/base.py�__init__szTreeWalker.__init__cCst�dS)N)�NotImplementedError)rrrr�__iter__#szTreeWalker.__iter__cCs
d|d�S)z�Generates an error token with the given message

        :arg msg: the error message

        :returns: SerializeError token

        ZSerializeError)�type�datar)r�msgrrr�error&szTreeWalker.errorFccs$d|||d�V|r |�d�VdS)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

        ZEmptyTag)r�name�	namespacerzVoid 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

        ZStartTag)rrr rr)rr rr!rrr�startTagEs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

        ZEndTag)rrr r)rr rrrr�endTagVs
zTreeWalker.endTagccsx|}|�t�}|dt|�t|��}|r6d|d�V|}|�t�}|t|�d�}|rdd|d�V|rtd|d�VdS)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

        NZSpaceCharacters)rrZ
Characters)�lstripr	�len�rstrip)rrZmiddle�left�rightrrr�textds

zTreeWalker.textcCs
d|d�S)zdGenerates a Comment token

        :arg data: the comment

        :returns: Comment token

        �Comment)rrr)rrrrr�comment�szTreeWalker.commentNcCsd|||d�S)z�Generates a Doctype token

        :arg name:

        :arg publicId:

        :arg systemId:

        :returns: the Doctype token

        ZDoctype)rr�publicId�systemIdr)rrr.r/rrr�doctype�szTreeWalker.doctypecCs
d|d�S)zjGenerates an Entity token

        :arg name: the entity name

        :returns: an Entity token

        ZEntity)rrr)rrrrr�entity�szTreeWalker.entitycCs|�d|�S)zHandles unknown node typeszUnknown node type: )r)rZnodeTyperrr�unknown�szTreeWalker.unknown)F)NN)�__name__�
__module__�__qualname__�__doc__rrrr#r$r%r+r-r0r1r2rrrrrs

&


c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)rcCst�dS)N)r)r�noderrr�getNodeDetails�sz%NonRecursiveTreeWalker.getNodeDetailscCst�dS)N)r)rr7rrr�
getFirstChild�sz$NonRecursiveTreeWalker.getFirstChildcCst�dS)N)r)rr7rrr�getNextSibling�sz%NonRecursiveTreeWalker.getNextSiblingcCst�dS)N)r)rr7rrr�
getParentNode�sz$NonRecursiveTreeWalker.getParentNodeccs|j}�x�|dk	�r|�|�}|d|dd�}}d}|tkrN|j|�Vn�|tkrrx�|j|�D]
}|VqbWn�|tkr�|\}}}}|r�|tdkr�|tkr�x|�	||||�D]
}|Vq�Wd}n|�
|||�VnV|tkr�|�|d�Vn<|t
k�r|�|d�Vn |tk�rd}n|�|d�V|�r>|�|�}	nd}	|	dk	�rR|	}q
x�|dk	�r�|�|�}|d|dd�}}|tk�r�|\}}}}|�r�|tdk�s�|tk�r�|�||�V|j|k�r�d}P|�|�}
|
dk	�r�|
}Pn
|�|�}�qTWq
WdS)Nr�FZhtmlT)rr8rr0rr+r
rrr#r$rr-rr1r
r2r9r%r:r;)rZcurrentNodeZdetailsrr"�tokenr rZ
attributesZ
firstChildZnextSiblingrrrr�sZ









zNonRecursiveTreeWalker.__iter__N)r3r4r5r8r9r:r;rrrrrr�s
N)Z
__future__rrrZxml.domrZ	constantsrrr	�__all__Z
DOCUMENT_NODEr
ZDOCUMENT_TYPE_NODErZ	TEXT_NODErZELEMENT_NODEr
ZCOMMENT_NODErZENTITY_NODErr�join�objectrrrrrr�<module>s
!

Zerion Mini Shell 1.0