관리-도구
편집 파일: etree_lxml.cpython-310.pyc
o ƚRe�9 � @ s d Z ddlmZmZmZ ddlZddlZddlZzddlm Z W n e y/ ddlm Z Y nw ddlm Z ddlmZ dd lmZ dd lmZ ddlmZ ddlmZ ddlmZmZ d Ze�d�Ze�d�jZG dd� de�ZG dd� de�Zdd� Z dd� Z!G dd� de j"�Z"dS )a� Module for supporting the lxml.etree library. The idea here is to use as much of the native library as possible, without using fragile hacks like custom element names that break between releases. The downside of this is that we cannot represent all possible trees; specifically the following are known to cause problems: Text or comments as siblings of the root element Docypes with no name When any of these things occur, we emit a DataLossWarning � )�absolute_import�division�unicode_literalsN)�MutableMapping� )�base� )�DataLossWarning)� constants)�etree)� _ihatexml)�PY3�binary_typeTz {([^}]*)}(.*)Zasdc @ s e Zd Zdd� ZdS )�DocumentTypec C s || _ || _|| _d S �N)�name�publicId�systemId)�selfr r r � r ��/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-3.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.py�__init__) s zDocumentType.__init__N)�__name__� __module__�__qualname__r r r r r r ( s r c @ s, e Zd Zdd� Zdd� Zdd� Zee�ZdS )�Documentc C s d | _ g | _d S r )�_elementTree�_childNodes�r r r r r 0 s zDocument.__init__c C s. | j �� }| j �� �� D ]}q|�|j� d S r )r �getrootZitersiblingsZaddnext�_element)r �element�lastr r r �appendChild4 s zDocument.appendChildc C � | j S r )r r r r r �_getChildNodes; � zDocument._getChildNodesN)r r r r r# r% �property� childNodesr r r r r / s r c s6 g �t jdd�� d� ��fdd� ��| d� d���S )NT�ZpreventDoubleDashCommentsr c sD t | d�s�t | d�rg��d� | jjr<| jjs"| jjs"d| jj }n d| jj| jj| jjf }��dd|d |f � | �� }|�� d urP|�� }|�� d usF|d ure�||d � |� � }|d usTd S d S t | t�sqt | t�r�t | t�st jd dksJ ���d d| | f � d S ��d� | D ] }�||d � q�d S | jtkrʈ�dd| | jf � t | d �r�| jrȈ�d d| | jf � d S d S d S t | tj�s�J �tj�| j�}|d ur�|�d�}|�d�}tj| }��dd| |� �|�f � n��dd| � �| j�f � t | d��rcg }| j�� D ]2\} } t�| �}|d u�r=|�� \}} � �| �} tj| }d|| f }n� �| �}|�|| f� �qt|�D ]\} } ��dd|d | | f � �qO| j�ru��d d|d | jf � |d7 }| D ]}�||� �q{t | d ��r�| j�r���d d|d | jf � d S d S d S )N�tagr z #document� <!DOCTYPE %s>z<!DOCTYPE %s "%s" "%s">z|%s%s� r r z|%s"%s"z#document-fragmentz|%s<!-- %s -->�tailr z |%s<%s %s>z|%s<%s>�attribz%s %sz |%s%s="%s") �hasattr�append�docinfo�internalDTD� public_idZ system_url� root_namer ZgetpreviousZgetnext� isinstance�str�bytes�sys�version_infor* �comment_type�textr- r Z_Element�etree_builders� tag_regexp�match�groupr �prefixes�fromXmlNamer. �items�groups�sorted) r! �indent�dtd_strZnext_elementZnsmatch�nsr* �prefix� attributesr �valueZattr_string�child�� infosetFilter�rv�serializeElementr r rO E s� ���� � � � � �z(testSerializer.<locals>.serializeElement� )r )r � InfosetFilter�join�r! r rL r �testSerializerA s F rT c s$ g � � �fdd���| � d� � �S )z4Serialize an element and its child nodes to a stringc s t | d�s$| jjr| jjr| jj}nd| jj }� �|� �| �� � nN| jtkr3� �d| j f � n?| j s@� �d| jf � nd�dd� | j �� D ��}� �d| j|f � | j r`� �| j � | D ]}�|� qb� �d | jf � t | d �r�| j r�� �| j � d S d S d S )Nr* r+ z <!--%s-->z<%s>r, c S s g | ] \}}d ||f �qS )z%s="%s"r )�.0r rJ r r r � <listcomp>� s �z6tostring.<locals>.serializeElement.<locals>.<listcomp>z<%s %s>z</%s>r- )r/ r1 r2 �doctyper4 r0 r r* r: r; r. rR rB r- )r! rF �attrrK �rN rO r r rO � s. � �z"tostring.<locals>.serializeElement� )rR rS r rY r �tostring� s r[ c sz e Zd ZeZeZdZdZeZ e Zddd�Zdd� Z dd� Zd d � Zdd� Zd d� Zddd�Zd� fdd� Zdd� Z� ZS )�TreeBuilderNFc s� t jt|d��tjdd� �| _|| _G �fdd�dt�� G � ��fdd�d�j�}G ��fdd �d �j �}|| _ || _tj �| |� d S ) N)�fullTreeTr) c sP e Zd Zdd� Z� fdd�Zdd� Zdd� Zd d � Zdd� Zd d� Z dd� Z dS )z(TreeBuilder.__init__.<locals>.Attributesc S s || _ d S r )r �r r! r r r r � s z1TreeBuilder.__init__.<locals>.Attributes.__init__c s6 t |t�rd|d � �|d �f }|S � �|�}|S )N�{%s}%sr r )r5 �tupleZcoerceAttribute)r �keyr �rM r r � _coerceKey� s �z3TreeBuilder.__init__.<locals>.Attributes._coerceKeyc S s0 | j j j| �|� }tst|t�r|�d�}|S )N�ascii)r r. rc r r5 r �decode�r ra rJ r r r �__getitem__� s z4TreeBuilder.__init__.<locals>.Attributes.__getitem__c S s || j j j| �|�<