�
Ϫ�f�� �
� � d Z ddlmZ ddlZddlZddlmZmZ ddlm Z m
Z
ddlmZ ddl
mZ ddlmZmZ d j% e
e d
ddd� � � Z ej( eed
�� d� Zd� Zd� ZdZ ee� Zej9 � edz Z ee� Zej9 � efd�Zefd�Z G d� de!� Z" G d� d� Z# G d� de#� Z$ G d� de#� Z% G d� de#� Z& G d � d!e&� Z' G d"� d#e&� Z( G d$� d%e&� Z)d&� Z* e*� Z+ G d'� d(e&� Z, G d)� d*e#� Z-d+� Z.d,� Z/ G d-� d.e� Z0d/� Z1d0� Z2d1� Z3d2� Z4 G d3� d4� Z5y)5a�
Micro Document Object Model: a partial DOM implementation with SUX.
This is an implementation of what we consider to be the useful subset of the
DOM. The chief advantage of this library is that, not being burdened with
standards compliance, it can remain very stable between versions. We can also
implement utility 'pythonic' ways to access and mutate the XML tree.
Since this has not subjected to a serious trial by fire, it is not recommended
to use this outside of Twisted applications. However, it seems to work just
fine for the documentation generator, which parses a fairly representative
sample of XML.
Microdom mainly focuses on working with HTML and XHTML.
This module is now deprecated.
� )�annotationsN)�BytesIO�StringIO)�Version�getVersionString)�ioType)�InsensitiveDict)�
ParseError� XMLParserz)twisted.web.microdom was deprecated at {}�Twisted� �
� )�
stacklevelc �� � g }|j }| g}t |� dkD rF|j d� }|j |k( r ||� |j |dd t |� dkD r�F|S )a3
Return a list of all child elements of C{iNode} with a name matching
C{name}.
Note that this implementation does not conform to the DOM Level 1 Core
specification because it may return C{iNode}.
@param iNode: An element at which to begin searching. If C{iNode} has a
name matching C{name}, it will be included in the result.
@param name: A C{str} giving the name of the elements to return.
@return: A C{list} of direct or indirect child elements of C{iNode} with
the name C{name}. This may include C{iNode}.
r N)�append�len�pop�nodeName�
childNodes��iNode�name�matches�matches_append�slice�cs �6/usr/lib/python3/dist-packages/twisted/web/microdom.py�getElementsByTagNamer ) sh � � �G��^�^�N�
�G�E�
�e�*�q�.��I�I�a�L���:�:����1���L�L��b�q� � �e�*�q�.�
�N� c � � |j � }g }|j }| g}t |� dkD rT|j d� }|j j � |k( r ||� |j
|d d t |� dkD r�T|S �Nr )�lowerr r r r r r s r �getElementsByTagNameNoCaser$ D sz � ��:�:�<�D��G��^�^�N�
�G�E�
�e�*�q�.��I�I�a�L���:�:�����%��1���L�L��b�q� � �e�*�q�.�
�Nr c �D � � t � � t k( r� fd�}|S � fd�}|S )Nc �j �� t | t � r| j d� } �j | � y �Nzutf-8)�
isinstance�str�encode�write��s�streams �r �wz_streamWriteWrapper.<locals>.wT s& |