403Webshell
Server IP : 172.67.201.108  /  Your IP : 216.73.216.11
Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5
System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3.9/site-packages/elementpath/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.9/site-packages/elementpath/__pycache__/xpath_context.cpython-39.pyc
a

���c
V�@s6ddlZddlZddlmZddlmZddlmZddlmZddl	m
Z
mZmZm
Z
mZmZmZmZmZmZmZddlmZdd	lmZmZdd
lmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(e
r�ddl)m*Z*m+Z+ee'e(fZ,eee'e(e&efZ-ee'e(eefZ.Gdd
�d
�Z/Gdd�de/�Z0dS)�N)�copy)�	lru_cache)�chain)�
ModuleType)�
TYPE_CHECKING�cast�Dict�Any�List�Iterable�Iterator�Optional�Sequence�Union�Callable�)�ElementPathTypeError)�
AnyAtomicType�Timezone)�TypedElement�
AttributeNode�TextNode�TypedAttribute�etree_iter_nodes�is_etree_element�is_element_node�is_document_node�is_schema_node�is_lxml_etree_element�is_lxml_document_node�	XPathNode�ElementNode�DocumentNode��
XPathToken�	XPathAxisc@s�eZdZUdZee�ZdZee	e
efed<dZ
eeed<eed<eeed<dCeee	eefeeeeeeee	eefeejeeeefeeee
eeee	eeefeeeeeeeeedd	�d
d�Zed�d
d�Zdd�dd�ZdDedd�dd�Zee	e
efd�dd��Zeed�dd��Ze dd�ee
e!feee
efd�dd��Z"eed�dd �Z#ed�d!d"�Z$e%e&d�d#d$�Z'e(ee%ed%�d&d'�Z)ed(e%ed)�d*d+�Z*dEe+e,egefee+ee%ed,�d-d.�Z-e%ed�d/d0�Z.e%ee/e0fd�d1d2�Z1e%ed�d3d4�Z2e%e
d�d5d6�Z3dFeee%e
d7�d8d9�Z4dGeeee%ed:�d;d<�Z5dHeee%ed7�d=d>�Z6e%e
d�d?d@�Z7e%e
d�dAdB�Z8dS)I�XPathContexta�	
    The XPath dynamic context. The static context is provided by the parser.

    Usually the dynamic context instances are created providing only the root element.
    Variable values argument is needed if the XPath expression refers to in-scope variables.
    The other optional arguments are needed only if a specific position on the context is
    required, but have to be used with the knowledge of what is their meaning.

    :param root: the root of the XML document, can be a ElementTree instance or an Element.
    :param namespaces: a dictionary with mapping from namespace prefixes into URIs,     used when namespace information is not available within document and element nodes.     This can be useful when the dynamic context has additional namespaces and root     is an Element or an ElementTree instance of the standard library.
    :param item: the context item. A `None` value means that the context is positioned on     the document node.
    :param position: the current position of the node within the input sequence.
    :param size: the number of items in the input sequence.
    :param axis: the active axis. Used to choose when apply the default axis ('child' axis).
    :param variables: dictionary of context variables that maps a QName to a value.
    :param current_dt: current dateTime of the implementation, including explicit timezone.
    :param timezone: implicit timezone to be used when a date, time, or dateTime value does     not have a timezone.
    :param documents: available documents. This is a mapping of absolute URI     strings onto document nodes. Used by the function fn:doc.
    :param collections: available collections. This is a mapping of absolute URI     strings onto sequences of nodes. Used by the XPath 2.0+ function fn:collection.
    :param default_collection: this is the sequence of nodes used when fn:collection     is called with no arguments.
    :param resource_collections: available URI collections. This is a mapping of absolute     URI strings to sequences of URIs. Used by the XPath 3.0+ function fn:uri-collection.
    :param default_resource_collection: this is the sequence of URIs used when     fn:uri-collection is called with no arguments.
    :param allow_environment: defines if the access to system environment is allowed,     for default is `False`. Used by the XPath 3.0+ functions fn:environment-variable     and fn:available-environment-variables.
    N�_parent_map�_etree�root�itemrF)r)�
namespacesr*�position�size�axis�	variables�
current_dt�timezone�	documents�collections�default_collection�resource_collections�default_resource_collection�allow_environment�default_language�default_calendar�
default_place�returncCs�||_||_t|�r(|dur |n||_n"t|�r8||_nd}t|�|���||_||_||_	|durli|_
ndd�|��D�|_
|	dus�t|	t
�r�|	|_nt
�|	�|_|p�tjj|jd�|_|
|_||_||_|
|_||_||_||_||_||_dS)NzAinvalid root {!r}, an Element or an ElementTree instance requiredcSsi|]\}}||�qS�r<��.0�k�vr<r<�=/usr/lib/python3.9/site-packages/elementpath/xpath_context.py�
<dictcomp>s�z)XPathContext.__init__.<locals>.<dictcomp>)Ztz)r)r+rr*rr�formatr,r-r.r/�items�
isinstancerr1Z
fromstring�datetimeZnowr0r2r3r4r5r6r7r8r9r:)�selfr)r+r*r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:�msgr<r<rA�__init__Ms6zXPathContext.__init__)r;cCsd|jj|j|jfS)Nz%s(root=%r, item=%r))�	__class__�__name__r)r*�rHr<r<rA�__repr__�szXPathContext.__repr__cCs:t�|j�}|j�|j�d|_dd�|j��D�|_|S)NcSsi|]\}}||�qSr<r<r=r<r<rArB�rCz)XPathContext.__copy__.<locals>.<dictcomp>��object�__new__rK�__dict__�updater.r/rE)rH�objr<r<rA�__copy__�s
zXPathContext.__copy__T)�
clear_axisr;cCs>t�|j�}|j�|j�|r$d|_dd�|j��D�|_|S)NcSsi|]\}}||�qSr<r<r=r<r<rArB�rCz%XPathContext.copy.<locals>.<dictcomp>rO)rHrVrTr<r<rAr�szXPathContext.copycCsL|jdurF|dd�|j��D�|_t|j�rF|j|jtt|j���<|jS)NcSsi|]}|D]
}||�qqSr<r<)r>�elem�childr<r<rArB�rCz+XPathContext.parent_map.<locals>.<dictcomp>)r'r)�iterrrr"�getrootrMr<r<rA�
parent_map�s

zXPathContext.parent_mapcCsB|jdur<|t|j�s"t|j�r0t�d�|_nt�d�|_|jS)Nz
lxml.etreezxml.etree.ElementTree)r(rr)r�	importlib�
import_modulerMr<r<rA�etree�s
zXPathContext.etreei)�maxsize)rWr;cCsDt|t�r|j}||jurdSz|j|WSty>YdS0dS)z�
        Returns the parent element or `None` for root element and for elements
        that are not included in the tree. Uses a LRU cache to minimize parent
        map rebuilding for trees processed with an incremental parser.
        N)rFrrWr)r[�KeyError)rHrWr<r<rA�
get_parent�s

zXPathContext.get_parent)r*r;cCs�g}t|t�r(|�d|j���|j}n&t|t�rN|�d|jj���|jj}|durf|s^dS|dSt|t�rv|j}z|�|j	�Wnt
y�Yn0|�|�}|dur�d�d�
t|���S|}qvdS)zICached path resolver for elements and attributes. Returns absolute paths.�@N�rz/{}�/)rFr�append�name�parentr�	attributerrW�tag�AttributeErrorrarD�join�reversed)rHr*�pathrgr<r<rA�get_path�s&



zXPathContext.get_pathcCs(|jdkrt|jttf�St|j�SdS)Nrh)r.rFr*rrrrMr<r<rA�is_principal_node_kind�s
z#XPathContext.is_principal_node_kindccs:|j}t|�r"|Vtt|���}|j|dd�EdHdS)z;Iterates context nodes, including text and attribute nodes.T�Zwith_attributesN)r)rrr"rZ�_iter_nodes)rHr)r<r<rArY�s
zXPathContext.iter)�resultsr;ccs�|j}|j|jdd�D]~|_|j|vr0|jVqt|jt�rdtdd�|�D]}|j|jkrJ|VqJqt|j�rtdd�|�D]}|j|jur||Vq|q||_dS)zr
        Iterates results in document order.

        :param results: a container with selection results.
        TrpcSs
t|t�S�N)rFr��xr<r<rA�<lambda>�rCz+XPathContext.iter_results.<locals>.<lambda>cSs
t|t�Srs)rFrrtr<r<rArv�rCN)	r*rqr)rFr�filterrhrrW)rHrr�statusZtyped_attributeZ
typed_elementr<r<rA�iter_results�s




zXPathContext.iter_resultsr#)�tokenr;ccs�|j|j|jf}dd�|�t|��D�}|jdkrrtd|�jrrt|�|_|_|D]|_|jV|jd8_qRn,t|�|_t	|dd�D]\|_|_|jVq�|\|_|_|_dS)z/Apply the token's selector with an inner focus.cSsg|]}|�qSr<r<�r>rur<r<rA�
<listcomp>rCz3XPathContext.inner_focus_select.<locals>.<listcomp>r.r%r��startN)
r*r-r,ZselectrZlabelrZreverse_axis�len�	enumerate)rHrzrxrrr<r<rA�inner_focus_selects


zXPathContext.inner_focus_select)�	selectors�varnamesr;c		#s��fdd�|D�}t|�}dg|}|d}d}zt||�}Wn4tyt|sXYdS||��||<|d8}Yq00|dur�z|�j||<Wnttfy�Yn0|||<||kr�t|�Vq0|d7}q0dS)z�
        Iterator for cartesian products of selectors.

        :param selectors: a sequence of selector generator functions.
        :param varnames: a sequence of variables for storing the generated values.
        csg|]}|���qSr<r<r{rMr<rAr|rCz-XPathContext.iter_product.<locals>.<listcomp>Nrr)r�next�
StopIterationr/�	TypeError�
IndexError�tuple)	rHr�r�Z	iteratorsZ	dimensionZprodZ	max_indexr?�valuer<rMrA�iter_products*
zXPathContext.iter_productccs|j}d|_|jV||_dS)z*Iterator for 'self' axis and '.' shortcut.rHN)r.r*�rHrxr<r<rA�	iter_self7szXPathContext.iter_selfc#s�t|jttf�r.|j}d|_|jV||_dSt|j�s<dS|j|jf}d|_t|jt�rd|jj|_tt	|j��t
��r�dd��j��D�D]|_|jVq�n(�fdd��j��D�D]|_|jVq�|\|_|_dS)z/Iterator for 'attribute' axis and '@' shortcut.rhNcss|]}t|�VqdSrs�rr{r<r<rA�	<genexpr>TrCz/XPathContext.iter_attributes.<locals>.<genexpr>c3s$|]}t|d|d�d�VqdS)rr)rgNr�r{�rWr<rAr�WrC)
rFr*rrr.rrrWrr!rZattribrEr�r<r�rA�iter_attributes>s&


zXPathContext.iter_attributesccs&|jdur|jVdS|j|jf}d|_t|jt�r>|jj|_|jdur|t|j�rjtt|j�}|�	�|_n|j|_|jVn�t
|j�r�tt|j�}|jdur�t
|j|�|_|jV|D]2}||_|V|jdur�t
|j|d�|_|jVq�n*t|j��rtt|j�}|�	�|_|jV|\|_|_dS)z/Iterator for 'child' forward axis and '/' step.NrXT)r.r*rFrrWrr)rr"rZrr!�textr�tail)rHrxZdocumentrWrXr<r<rA�iter_children_or_self\s:








z"XPathContext.iter_children_or_selfccsft|jt�r|�|jj�}n|�|j�}|durb|j|jf}d|_||_tt|j�V|\|_|_dS)z5Iterator for 'parent' reverse axis and '..' shortcut.Nrg)rFr*rrarWr.rr!)rHrgrxr<r<rA�iter_parent�szXPathContext.iter_parent)r.r;ccs�t|jt�rtt|jj�}n*t|j�r6tt|jd��r:dStt|j�}|�	|�}|dur\dS|j|j
f}|pnd|_
|dkr�|D]}||ur�q�||_|Vq~n,d}|D]"}|r�||_|Vq�||ur�d}q�|\|_|_
dS)z�
        Iterator for 'following-sibling' forward axis and 'preceding-sibling' reverse axis.

        :param axis: the context axis, default is 'following-sibling'.
        riNzfollowing-siblingzpreceding-siblingFT)rFr*rrr!rWr�callable�getattrrar.)rHr.r*rgrxrX�followsr<r<rA�
iter_siblings�s0


zXPathContext.iter_siblings)r.�inner_focusr;ccs2|dk}|jdurTt|j�r.|j|j|d�}q�|rFtd|�|j��}q�|�|j�}n8t|j�sht|j�rz|j|j|d�}n|r�|jf}ndS|r�|j|j|j|jf}||_dd�|D�}t	|�|_t
|dd�D]\|_|_|jVq�|\|_|_|_|_n4|j|jf}||_|D]|_|jV�q|\|_|_dS)	a�
        Iterator for 'descendant' and 'descendant-or-self' forward axes and '//' shortcut.

        :param axis: the context axis, for default has no explicit axis.
        :param inner_focus: if `True` splits between outer focus and inner focus.         In this case set the context size at start and change both position and         item at each iteration. For default only context item is changed.
        Z
descendantN)Z	with_rootrscSsg|]}|�qSr<r<)r>�er<r<rAr|�rCz1XPathContext.iter_descendants.<locals>.<listcomp>rr})r*rr)rqrrr,r-r.rr�)rHr.r�Z	with_self�descendantsrxrrZstatus_r<r<rA�iter_descendants�s2






zXPathContext.iter_descendantsccs�|j|jf}|pd|_t|jt�r2tt|jj�}nt|j�rJtt|j�}ndSg}|jdkrf|�|�|�	|�}|dur�|�|�|�	|�}qpt
|�D]|_|jVq�|\|_|_dS)z�
        Iterator for 'ancestor' and 'ancestor-or-self' reverse axes.

        :param axis: the context axis, default is 'ancestor'.
        ZancestorNzancestor-or-self)r*r.rFrrr!rWrrerarl)rHr.rxrW�	ancestorsrgr<r<rA�iter_ancestors�s"






zXPathContext.iter_ancestorsccs�t|jt�r|jjn|j}t|�r:||jus:tt|d��r>dS|j|jf}d|_g}|}|�	|�}|durnq~qX|�
|�|}qX|j��D]&}||ur�q�q�||vr�||_|Vq�|\|_|_dS)z&Iterator for 'preceding' reverse axis.riNZ	preceding)rFr*rrWrr)r�r�r.rarerY)rHr*rxr�rWrgr<r<rA�iter_precedings*�

zXPathContext.iter_precedingccs�|j|jf}d|_|jdus(|j|jur,dSt|jt�rD|jj|_nt|j�r^tt|jd��rbdSt	|�
|j��}d}|�
|j�D],}|r�||vr�||_|Vq�|j|ur�d}q�|\|_|_dS)z&Iterator for 'following' forward axis.Z	followingNriFT)r*r.r)rFrrWrr�r��setrq)rHrxr�r�rWr<r<rA�iter_followings!s(
�
zXPathContext.iter_followings)NNrrNNNNNNNNNFNNN)T)N)N)NF)N)9rL�
__module__�__qualname__�__doc__�staticmethodrrqr'r
rr!�ContextRootType�__annotations__r(r�ContextItemType�str�intr	rGrrr"r
�boolrJrNrUr�propertyr[r^rrrarnror�IterableNodeTyperYrryr�rrr�r�rrr�r�r�r�r�r�r�r�r<r<r<rAr&"s�
$��8			
���&(%��-r&c@seZdZdZdS)�XPathSchemaContexta
    The XPath dynamic context base class for schema bounded parsers. Use this class
    as dynamic context for schema instances in order to perform a schema-based type
    checking during the static analysis phase. Don't use this as dynamic context on
    XML instances.
    N)rLr�r�r�r<r<r<rAr�;sr�)1rGr\r�	functoolsr�	itertoolsr�typesr�typingrrrr	r
rrr
rrr�
exceptionsrZ	datatypesrrZxpath_nodesrrrrrrrrrrrr r!r"Zxpath_tokenr$r%r�r�r�r&r�r<r<r<rA�<module>
s(4@

Youez - 2016 - github.com/yon3zu
LinuXploit