관리-도구
편집 파일: ElementInclude.cpython-37.opt-1.pyc
B o��]p! � @ s� d Z ddlmZ yddlmZ ddlmZ W n, ek rX ddlmZ ddl mZ Y nX dZ e d Ze d Ze d Z d ZG d d� dej�ZG dd � d e�Zddd�Zddd�Zdd� Zddefdd�Zddedfdd�ZdS )a Limited XInclude support for the ElementTree package. While lxml.etree has full support for XInclude (see `etree.ElementTree.xinclude()`), this module provides a simpler, pure Python, ElementTree compatible implementation that supports a simple form of custom URL resolvers. � )�etree)�urljoin)�urlopenz!{http://www.w3.org/2001/XInclude}�includeZfallback�*� c @ s e Zd ZdS )�FatalIncludeErrorN)�__name__� __module__�__qualname__� r r �F/opt/alt/python37/lib64/python3.7/site-packages/lxml/ElementInclude.pyr K s r c @ s e Zd ZdS )�LimitedRecursiveIncludeErrorN)r r r r r r r r O s r Nc C sH t | d�}|dkr"t�|��� }n|�� }|s2d}|�|�}|�� |S )N�rb�xmlzutf-8)�openr �parse�getroot�read�decode�close)�hrefr �encoding�file�datar r r �default_loader` s r c C s\ |dkrt �| |��� }n>d| kr,t| �}n t| d�}|�� }|�� |sNd}|�|�}|S )Nr z://r zutf-8)r r r r r r r r )r r r �parserr �fr r r �_lxml_default_loaderq s r c s d� fdd� }|S )Nc s � | ||�S )Nr )r r r r )�loaderr r �load� s z_wrap_et_loader.<locals>.load)NNr )r r r )r r �_wrap_et_loader� s r! c C s� |d krd}n|dk r"t d| ��|d kr^t| d�rB| }| �� } n| �� }t|d�rp|jj}nt| d�rp| �� } t| |||� d S )N���r z;expected non-negative depth or None for 'max_depth', got %rr �docinfo)� ValueError�hasattrr �getroottreer# ZURL�_include)�elemr �base_url� max_depthZtreer r r r � s c C s |d k rt |�}nt}|d kr$t� }| �� j}t| �t��}�x�|D �]�}|jt k�r�t ||�d��} |�dd�} |�� }| dk�r"| |kr�t d| ��|dkr�td| ��|| | |d�}|d kr�t d| | f ��t||| |d | h|B �}|j�r|jp�d |j |_|d k�r|S |�||� n�| dk�r�|| | |�d�d �} | d k�rZt d| | f ��|�� }|d k �r�|j�pvd | |_n,|d k�r�| S |j�p�d | |j�p�d |_|�|� nt d| ��qD|jtk�r |�� }|d k �r|jt k�rt d|j ��qDt d|j ��qDW | S )Nr r r z recursive include of %r detectedr z5maximum xinclude depth reached when including file %s)r zcannot load %r as %r� � �textr )r z)unknown parse type in xi:include tag (%r)z0xi:fallback tag must be child of xi:include (%r)z0Invalid element found in XInclude namespace (%r))r! r �setr&