File: //lib/python3/dist-packages/twisted/web/__pycache__/domhelpers.cpython-38.pyc
U
W[�! � @ s d Z ddlmZ ddlmZ ddlmZmZmZ e e G dd� de �Z
dd� Zd9d
d�Zdd
� Z
dd� Zdd� Zdd� Zd:dd�Zdd� Zdd� Zdd� Zd;dd�ZG d d!� d!ej�Zd<d#d$�Zd=d%d&�Zd>d'd(�Zd)d*� Zd+d,� Zd?d-d.�Zd/d0� Zd1d2� Zd3d4� Z d5d6� Z!d7d8� Z"d"S )@z>
A library for performing interesting tasks with DOM objects.
� )�StringIO)�microdom)�getElementsByTagName�escape�unescapec @ s e Zd ZdS )�NodeLookupErrorN)�__name__�
__module__�__qualname__� r r �8/usr/lib/python3/dist-packages/twisted/web/domhelpers.pyr s r c C sF |j D ]:}t|d�r4|jr4|�dt|j�|j| � t| ||� qdS )z�
Look through the given node's children for strings, and
attempt to do string substitution with the given parameter.
� nodeValuer N)�
childNodes�hasattrr
ZreplaceData�len�
substitute)Zrequest�nodeZsubs�childr r r r s
r ��id�classZmodel�patternc C s� t | d�r6| �� r6|D ]}t| �|��|kr| S q| �� r�t | jd�rT| jj}n
t| j�}t|�D ] }t | j| |�}|rf| S qfdS )zx
(internal) Get a node with the specified C{nodeId} as any of the C{class},
C{id} or C{pattern} attributes.
�
hasAttributes�lengthN)
r r �str�getAttribute�
hasChildNodesr r r �range�_get)r �nodeIdZ nodeAttrsZnodeAttrr ZchildNum�resultr r r r ! s
r c C s t | |�}|r|S t|��dS )z�
Get a node with the specified C{nodeId} as any of the C{class},
C{id} or C{pattern} attributes. If there is no such node, raise
L{NodeLookupError}.
N)r r �r r r r r r �get4 s
r"