403Webshell
Server IP : 104.21.21.239  /  Your IP : 216.73.216.55
Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.7
System : Linux ip-172-31-69-123.ec2.internal 6.1.177-224.371.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jul 27 20:28:29 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.24
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_token.cpython-39.pyc
a

���c���@s�dZddlZddlZddlZddlmZddlmZddlmZddl	m
Z
mZmZm
Z
mZmZmZddlZddlmZdd	lmZmZmZdd
lmZddlmZmZmZmZm Z m!Z!m"Z"m#Z#ddl$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3dd
l4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBddlCmDZDddlEmFZFmGZGddlHmIZImJZJe
�r�ddlKmLZLdZMe e!e"hZNeeeOe
eOeeOffZPGdd�deF�ZQGdd�deQ�ZRGdd�deQ�ZSGdd�deQ�ZTdS)a
XPathToken and helper functions for XPath nodes. XPath error messages and node helper functions
are embedded in XPathToken class, in order to raise errors related to token instances.

In XPath there are 7 kinds of nodes:

    element, attribute, text, namespace, processing-instruction, comment, document

Element-like objects are used for representing elements and comments, ElementTree-like objects
for documents.
XPathNode subclasses are used for representing other node types and typed elements/attributes.
�N)�copy)�Decimal)�product)�
TYPE_CHECKING�Optional�List�Tuple�Union�Any�Iterator)�Element�)�ElementPathError�ElementPathValueError�XPATH_ERROR_CODES)�ordinal)�XQT_ERRORS_NAMESPACE�
XSD_NAMESPACE�XPATH_FUNCTIONS_NAMESPACE�XPATH_MATH_FUNCTIONS_NAMESPACE�XSD_ANY_TYPE�XSD_ANY_SIMPLE_TYPE�XSD_ANY_ATOMIC_TYPE�XSI_NIL)�	XPathNode�ElementNode�TypedElement�
AttributeNode�TextNode�
NamespaceNode�TypedAttribute�is_etree_element�etree_iter_strings�is_comment_node�is_processing_instruction_node�is_element_node�is_document_node�
is_xpath_node�is_schema_node)�xsd10_atomic_types�xsd11_atomic_types�AbstractDateTime�AnyURI�
UntypedAtomic�Timezone�
DateTime10�Date10�DayTimeDuration�Duration�Integer�
DoubleProxy10�DoubleProxy�QName)�AbstractSchemaProxy)�Token�
MultiLabel)�XPathContext�XPathSchemaContext)�XPath1Parserz:http://www.w3.org/2005/xpath-functions/collation/codepointcs�eZdZUdZdZdZded<dseee	d�dd�Z
dteeee	d�dd	�Ze
d
��fdd�Zee
d
��fd
d��Zeed
�dd��Zeed
�dd�Zdudd�Zdvdd�Zdwdd�Zdxdd�Zdd�Zeeee	d�dd �Zd!d"�Zdyd#d$�Zdzd&d'�Zd(d)�Zd*d+�Zd,d-�Z e!j"d.d/��Z#d0d1�Z$d2d3�Z%d4d5�Z&e'e(e)fd6�d7d8�Z*d9d:�Z+d;d<�Z,d=d>�Z-d?d@�Z.dAdB�Z/dCdD�Z0e
e
dE�dFdG�Z1d{e'e
e2fee
e3dH�dIdJ�Z4ddKdL�dMdN�Z5ddKdL�dOdP�Z6d|�fdQdR�	Z7d}dSdT�Z8d~dUdV�Z9ddWdX�Z:d�dYdZ�Z;d�d[d\�Z<d�d]d^�Z=d�d_d`�Z>d�dadb�Z?d�dcdd�Z@d�dedf�ZAd�dgdh�ZBd�didj�ZCd�dkdl�ZDd�dmdn�ZEd�dodp�ZFd�dqdr�ZG�ZHS)��
XPathTokenzBase class for XPath tokens.Nr<�parser��context�returncCsdd�|�|�D�S)zo
        Evaluate default method for XPath tokens.

        :param context: The XPath dynamic context.
        cSsg|]}|�qS�rB��.0�xrBrB�;/usr/lib/python3.9/site-packages/elementpath/xpath_token.py�
<listcomp>G�z'XPathToken.evaluate.<locals>.<listcomp>)�select��selfr@rBrBrF�evaluateAszXPathToken.evaluateccs@|�|�}|dur<t|t�r(|EdHn|dur6||_|VdS)zs
        Select operator that generates XPath results.

        :param context: The XPath dynamic context.
        N)rL�
isinstance�list�item�rKr@rOrBrBrFrIIs

zXPathToken.select)rAcsv|j|j}}|dkr.d|jr(|djndS|dkrJ|jjdkrFdSdS|�d	�s\|d
vrhd||fStt|��	�S)N�$z$%s variable referencer��,�1.0zcomma operatorzcomma symbol�function)�axis�
sequence type�	kind testz%r %s)
�symbol�label�_items�valuer>�version�endswith�superr=�__str__�rKrYrZ��	__class__rBrFr`XszXPathToken.__str__cs��j�j}}|dkr*d�j�djfS|�d�s<|dvrZd�jd�dd	��D��fS|d
krzd�dj�djfS|d
kr��s�dSd�djS|dkr�d�dj�djfS|dkr�d�dj�djfS|dk�r�d�djS|dk�rd�dj�djfS|dk�r<d�dj�dj�djfS|dk�rpd�djd�dd	��dd�D��fS|dk�r�d �djd�d!d	��dd�D��fS|d"k�r�d#d��fd$d	�tdt��dd�D���d%jfStt	��jS)&NrVz%s::%srrU)rWrXz%s(%s)z, css|]}|jVqdS�N��source)rDrOrBrBrF�	<genexpr>hrHz$XPathToken.source.<locals>.<genexpr>�:�%s:%sr
�(z()z(%s)�[z%s[%s]rSz%s, %srQz$%s�{z{%s}%s�ifzif (%s) then %s else %s��instancez%s instance of %srRcss|]}|jVqdSrdre�rD�trBrBrFrgxrHZtreatz%s treat as %scss|]}|jVqdSrdrerprBrBrFrgzrH�forzfor %s return %sc3s*|]"}d�|j�|djfVqdS)z%s in %sr
Nre)rD�k�rKrBrFrg}s����)
rYrZrfr^�joinr\�range�lenr_r=rarbrtrFrfbs>


 
*
*
��zXPathToken.sourcecCs.|jdvrdS|jdkrdS|dj�d�S)zGIs `True` if the token apply child axis for default, `False` otherwise.>	�node�(name)�child�schema-element�*�
document-node�element�textrhFrhTr
rU)rYrZr^rtrBrBrF�
child_axis�s


zXPathToken.child_axisccs�|jdvr|jVnj|jdvrD|jdjdvr~|jd��EdHn:|jdvrd|jd��EdHn|jD]}|��EdHqjdS)z�
        Iterates through the leaf elements of the token tree if there are any,
        returning QNames in prefixed format. A leaf element is an element
        positioned at last path step. Does not consider kind tests and wildcards.
        >rzrh)z//�/ru>rk�parentZ
descendant�.rhrzr{r}rKzancestor-or-selfzdescendant-or-selfzpreceding-siblingZ	precedingZancestorzfollowing-siblingZ	followingz..N)rkr)rYr\r[�iter_leaf_elements)rK�tkrBrBrFr��s




zXPathToken.iter_leaf_elementsrFc	CsBz|j|j}Wnlty||rL|dur4|��d�|jdurD|jn|j}	n,|rpdt|d�}
|�d|
�d�n|YSYn�0d}	t|t	|���D]B\}}|dkr�|}	q�|j
jr��q
q�t|t
�r��q
q�|�d��q�|	du�r
|s�|St|d�}
d}
|�d|
�|
���|du�r>t|	|��s>t|t��s>|�rFt|	|��rF||	�S|j
j�r�t|t��rf|�|	�St|t��s~tt|��r�|�|	�S|j
jd	k�r�d}n||�|	�}t||��r�|St|t��r�t|t��r�||�St|t��rz
||�WSttf�yYn0|du�rd
nd}d}|�||�t|d�t|	�|���|	S)a�
        Get the argument value of a function of constructor token. A zero length sequence is
        converted to a `None` value. If the function has no argument returns the context's
        item if the dynamic context is not `None`.

        :param context: the dynamic context.
        :param index: an index for select the argument to be got, the first for default.
        :param required: if set to `True` missing or empty sequence arguments are not allowed.
        :param default_to_context: if set to `True` then the item of the dynamic context is         returned when the argument is missing.
        :param default: the default value returned in case the argument is an empty sequence.         If not provided returns `None`.
        :param cls: if a type is provided performs a type checking on item.
        :param promote: a class or a tuple of classes that are promoted to `cls` class.
        Nzmissing %s argumentr
�XPST0017rz;a sequence of more than one item is not allowed as argumentz-A not empty sequence required for {} argument�XPTY0004rT�FOTY0012z3the type of the {} argument is {!r} instead of {!r})r[rI�
IndexError�missing_contextrO�rootr�error�	enumeraterr>�compatibility_moderMr;�wrong_context_type�format�
issubclassr=�str�string_value�float�number_valuer]�
data_valuer,r-�	TypeError�
ValueError�type)rKr@�indexZrequiredZdefault_to_context�default�clsZpromote�selectorrO�msgrs�resultZord_arg�coder\�messagerBrBrF�get_argument�sh

�
"




"zXPathToken.get_argumentccs |�|�D]}|�|�Vq
dS)zj
        Yields data value of selected items.

        :param context: the XPath dynamic context.
        N)rIr�rPrBrBrF�select_data_values�szXPathToken.select_data_valuesccsD|�|�D]4}|�|�}|dur8d}|�d|�|���q
|Vq
dS)z�
        Helper method for value atomization of a sequence.

        Ref: https://www.w3.org/TR/xpath20/#id-atomization

        :param context: the XPath dynamic context.
        Nz.argument node {!r} does not have a typed valuer�)rIr�r�r�)rKr@rOr\r�rBrBrF�atomizations
zXPathToken.atomizationcCst|�|��}zt|�}Wnty.YdS0t|dd�}zt|�Wn�ty�t|t�rht|�}t|t�s�|dur�|j	r�t|t�r�|�
|�}|dus�|jtvr�n>z|�
|�}Wn.ttfy�d}|�|�t|����Yn0|YS0d}|�|��dS)z�
        Get the atomized value for an XPath operator.

        :param context: the XPath dynamic context.
        :return: the atomized value of a single length sequence or `None` if the sequence is empty.
        NrOz,Type {!r} is not appropriate for the contextz9atomized operand is a sequence of length greater than one)�iterr��next�
StopIteration�getattrrMr-r�r;�	xsd_types�get_xsd_type�name�XSD_SPECIAL_TYPES�decoder�r�r�r�r�)rKr@r�r\rO�xsd_typer�rBrBrF�get_atomized_operands:

���

zXPathToken.get_atomized_operandccs|jj�r6dd�|jd�t|��D�}dd�|jd�t|��D�}zlt|dt�r|t|�dkr||d|�|�fVWdSt|dt�r�t|�dkr�|�|�|dfVWdSWnt	y�YdS0|j
dv�rttt
t|j|��tt
t|j|���EdHdS|jjdk�r6tt|j|�t|j|��EdHdStt|j|jd�t|���t|j|jd�t|����D]�}td	d
�|D���r�tdd
�|D���rd}t|�t|d�t|d����nLtd
d
�|D���rtdd
�|D���rd}t|�t|d�t|d����|V�qpdS)aK
        Generates comparison data couples for the general comparison of sequences.
        Different sequences maybe generated with an XPath 2.0 parser, depending on
        compatibility mode setting.

        Ref: https://www.w3.org/TR/xpath20/#id-general-comparisons

        :param context: the XPath dynamic context.
        cSsg|]}|�qSrBrBrCrBrBrFrGJrHz3XPathToken.iter_comparison_data.<locals>.<listcomp>rcSsg|]}|�qSrBrBrCrBrBrFrGKrHr
N)�<z<=�>z>=rTcss|]}t|t�VqdSrd)rM�boolrCrBrBrFrgerHz2XPathToken.iter_comparison_data.<locals>.<genexpr>css|]}t|ttf�VqdSrd)rMr�r3rCrBrBrFrgfrHzcannot compare {!r} and {!r}css|]}t|t�VqdSrd)rMr3rCrBrBrFrgirHcss|]}t|t�VqdSrd)rMr�rCrBrBrFrgjrH)r>r�r[rIrrMr�rx�
boolean_valuer�rYr�mapr�r�r]�anyr�r�r�)rKr@Zoperand1Zoperand2�valuesr�rBrBrF�iter_comparison_data?sF


�
 �"� zXPathToken.iter_comparison_dataccs�|dur|j�|j�|�|�D]�}t|t�s6|Vq t|ttf�rN|jVq t|t	�rb|j
Vq t|t�r�t|j
j�r�|j
jVq�|jVq t|t�r |jjr�|j|jfVq |jVq dS)zh
        Generates formatted XPath results.

        :param context: the XPath dynamic context.
        N)r>Zcheck_variables�	variablesrIrMrrrr\r�elemr r(�	attributerr��prefix�uri)rKr@r�rBrBrF�select_resultsos"






zXPathToken.select_resultscCsvdd�|�|�D�}t|�dkrn|d}t|ttttf�r>|St|�sVt|�sVt	|�rZ|S|j
dvrh|S|Sn|SdS)z�
        Returns formatted XPath results.

        :param context: the XPath dynamic context.
        :return: a list or a simple datatype when the result is a single simple type         generated by a literal or function token.
        cSsg|]}|�qSrBrBrCrBrBrFrG�rHz*XPathToken.get_results.<locals>.<listcomp>r
r)rU�literalN)r�rxrMr��intr�rr!r&r(rZ)rKr@�results�resrBrBrF�get_results�s
zXPathToken.get_resultscCs�|j||d�}|durdSt|�r0|d�|�}|j|d|d�}|durLdSt|�rb|d�|�}t|t�r�t|t�r�|dur�|jdur�|jdur�|j|_|jdur�|j|_n\t|t�r�|�|j	�}t|t
�r�|t|�fSt|t��r
|�|j	�}t|t
��r
t|�|fSt|t��rJt|t��r.t
|�|fSt|t
��rJ|t
|�|�fSt|t��r�t|t��rn|t
|�fSt|t
��r�t
|�|�|fS||fS)a�
        Returns the operands for a binary operator. Float arguments are converted
        to decimal if the other argument is a `Decimal` instance.

        :param context: the XPath dynamic context.
        :param cls: if a type is provided performs a type checking on item.
        :return: a couple of values representing the operands. If any operand         is not available returns a `(None, None)` couple.
        �r�N)NNrr
)r�r�)r�r%r�rMr+�timezone�tzinfor-�cast_to_doubler\rr�r2r�)rKr@r�Zop1Zop2rBrBrF�get_operands�sF





zXPathToken.get_operandsTcCs�|s|jj}tj�|�}|js8|js8|j�d�s8|durH|r@|St	|�Stj�
|�}|jsr|js�|js�|j�d�s�|�dd�
|���|r�tj�||�St	tj�||��S)aT
        Obtains an absolute URI from the argument and the static context.

        :param uri: a string representing an URI.
        :param base_uri: an alternative base URI, otherwise the base_uri         of the static context is used.
        :param as_string: if `True` then returns the URI as a string, otherwise         returns the URI as xs:anyURI instance.
        :returns: the argument if it's an absolute URI. Otherwise returns the URI
        obtained by the join o the base_uri of the static context with the
        argument. Returns the argument if the base_uri is `None'.
        r�NZFORG0002z {!r} is not suitable as base URI)r>�base_uri�urllib�parse�urlparse�scheme�netloc�path�
startswithr,�urlsplit�fragmentr�r��urljoin)rKr�r�Z	as_stringZ	url_partsrBrBrF�get_absolute_uri�s&

���
�zXPathToken.get_absolute_uric
CsRz|jj|WStyL}z&dt|�}|�d|�d�WYd}~n
d}~00dS)z�
        Resolves a prefix to a namespace raising an error (FONS0004) if the
        prefix is not found in the namespace map.
        z no namespace found for prefix %r�FONS0004N)r>�
namespaces�KeyErrorr�r�)rKr��errr�rBrBrF�
get_namespace�s
zXPathToken.get_namespacecCs�|jdvrn�||jjkrJ|jdkr6d}|j|dd��q�t|jt�r�d|_n~|tkr�|jdkrpd}|j|dd��q�t|jt�r�d|_nD|tkr�|jdkr�d	}|j|dd��q�t|jt�r�d|_n
|�d��||_	d
S)z�
        Bind a token with a namespace. The token has to be a name, a name wildcard,
        a function or a constructor, otherwise a syntax error is raised. Functions
        and constructors must be limited to its namespaces.
        )rzr}rUz)a name, a wildcard or a function expectedr�)r�zconstructor functionz5a name, a wildcard or a constructor function expectedz
math functionz.a name, a wildcard or a math function expectedN)
rYr>Zfunction_namespacerZ�wrong_syntaxrMr9rr�	namespace)rKr�r�rBrBrF�bind_namespace�s,




zXPathToken.bind_namespacec
Csnt|�dkr4|j||d�}|dur&dSt|dd�}nx|j||d�}|j|dtd�}|dur�zt�|�}Wn6ty�}z|�dt|��d�WYd}~n
d}~00|dur�dSz~|j	du�r(|du�r(t
|t�r�||j7}nNt
|t
�s�||j|j	j7}n0|j|j	jk�r(||j|j	j8}|t�d�8}Wn8t�yb}z|�dt|��d�WYd}~n
d}~00||_	|S)a'
        XSD datetime adjust function helper.

        :param context: the XPath dynamic context.
        :param cls: the XSD datetime subclass to use.
        :return: an empty list if there is only one argument that is the empty sequence         or the adjusted XSD datetime instance.
        r
r�Nr�ZFODT0003ZP1DZFODT0001)rxr�r�r1r.Zfromdurationr�r�r�r�rMr/�offsetr0�
fromstring�
OverflowError)rKr@r�rOr�r�rBrBrF�adjust_datetimes6(

(zXPathToken.adjust_datetimec
cs�t�tj�}|tkrd}n|dur.|�dd��zRzt�tj|�Wn&tjyh|�dd|�d�Yn0dVWt�tj|�nt�tj|�0dS)zQA context manager for use a locale setting for string comparison in a code block.zen_US.UTF-8Nr�z%collation cannot be an empty sequenceZFOCH0002zUnsupported collation %r)�localeZ	getlocale�
LC_COLLATE�UNICODE_CODEPOINT_COLLATIONr��	setlocale�Error)rKZ	collationZlocrBrBrF�
use_localeGszXPathToken.use_localec	csB|��D�]2}|dur>||jjkr2dtkrnqdVqz�t|t�r�|j�|�r�|jdur||jj	j
�|�}|dur|Wq|�|�}|j
�|�}t|||�VnZ|�||j
j�r�|jdur�|jj	j�|�}|dur�Wq|�|�}|j
�|�}t|||�VWqt�y:||jk�r,dtk�r6nn|VYq0qdS)a
        Selector for XSD nodes (elements, attributes and schemas). If there is
        a match with an attribute or an element the node's type is added to
        matching types of the token. For each matching elements or attributes
        yields tuple nodes containing the node, its type and a compatible value
        for doing static evaluation. For matching schemas yields the original
        instance.

        :param schema_context: an XPathSchemaContext instance.
        :param name: a QName in extended format.
        Nz
{%s}schema)Ziter_children_or_selfr��tagrrMrr\Zis_matchingr��mapsZ
attributes�get�add_xsd_typer>�get_atomic_valuer Zdefault_namespace�elementsr�AttributeError)rKZschema_contextr�Zxsd_noder�r\rBrBrF�select_xsd_nodes[s4 




"zXPathToken.select_xsd_nodescCs�t|t�r|j}n$t|t�r&|jj}nt|t�r6|j}t|�sBdS|jdur\|j	|j
i|_nd|j�|j	�}|dur�|j
|j|j	<n>t|t�s�||j
ur�||j
g|j|j	<n|j
|vr�|�
|j
�|j
S)z}
        Adds an XSD type association from an item. The association is
        added using the item's name and type.
        N)rMrr\r r�rr�r(r�r�r�r�rN�append)rKrO�objrBrBrFr��s&







zXPathToken.add_xsd_typecCs�|jrt|jt�rdSt|t�r.|j�|�}n<t|t�rH|j�|j�}n"t|ttf�r\|j	S|j�|j
�}|srdSt|t�s�|St|t�r�|D]}|�|j
�r�|Sq�nBt|�r�|D]4}|��r�|�|j�r�|Sq�|�|�r�|Sq�|dS)z�
        Returns the XSD type associated with an item. Match by item's name
        and XSD validity. Returns `None` if no XSD type is matching.

        :param item: a string or an AttributeNode or an element.
        Nr)r�rMr7r�r�rr�r rr�r�rN�is_validr\r!Z	is_simpler�)rKrOr�rErBrBrFr��s2






zXPathToken.get_xsd_type)rOc	Cs�t|ttf�r|S|�|�}|s$|S|jtvr|t|t�rft|jt�sTt||t	d��St||t	|j��St||t	|j
pvd��St|t�r�nr|��r�t	|j
p�d�}t|||�S|��r�t||d�S|�
�r�t||d�S|�t��r�t|jdd��r�t||d�S|jjdk�rt}nt}z||j}Wnt�y4Yn�0t|ttf��rN|j}nt|t��r`|j}z8t|t��r�t||||j��WSt||||j
��WSWn0ttf�y�d}|�|� ||��d�Yn0|jj!du�r�t	}n`z|jj!�"|�}||j}Wnt�yt	}Yn,0t|ttf��r,|j}nt|t��r>|j}zVt|t��rp|�#|j��r�t||||j��WSn"|�#|j
��r�t||||j
��WSWnttf�y�Yn0d}|�|� ||��d�dS)a�
        Returns a typed node if the item is matching an XSD type.

        Ref:
          https://www.w3.org/TR/xpath20/#id-processing-model
          https://www.w3.org/TR/xpath20/#id-static-analysis
          https://www.w3.org/TR/xquery-semantics/

        :param item: an untyped attribute or element.
        :return: a typed AttributeNode/ElementNode if the argument is matching         any associated XSD type.
        rRNZnillablerTz.Type {!r} does not match sequence type of {!r})$rMr rr�r�r�rr\r�r-r�Zhas_mixed_contentZis_element_onlyZis_emptyr�rr�r�r>�xsd_versionr)r*r�r�r+r2r�r6�
cast_to_qnamer�r��wrong_sequence_typer�ZschemaZget_primitive_typer�)rKrOr�r\Zatomic_typesZbuilderr�Zprimitive_typerBrBrF�get_typed_node�sz





zXPathToken.get_typed_nodec
Cs�zHd|vr$t|jj�d�|���WS|���d�\}}t|jj||�WStytd�|���}|�d|��Yn6t	y�}z|�dd�|���WYd}~n
d}~00dS)z/Cast a prefixed qname string to a QName object.rhrRz"invalid value {!r} for an xs:QName�FORG0001r�z no namespace found for prefix {}N)
r6r>r�r��strip�splitr�r�r�r�)rKZqname�pfx�_r�r�rBrBrFr�#szXPathToken.cast_to_qnamec
CsZz |jjdkrt|�WSt|�WStyT}z|�dt|���WYd}~n
d}~00dS)zCast a value to xs:double.rTr�N)r>r�r4r5r�r�r�)rKr\r�rBrBrFr�0s

zXPathToken.cast_to_doublecCs�t|t�rH|sdSt|d�r"dSt|�dkr@d}|�d|��n|d}t|ttttf�rbt	|�St|t
tf�r�t�
|�r~dSt	|�S|dur�dSd�t|��}|�d|��dS)	zK
        The effective boolean value, as computed by fn:boolean().
        FrTr
zkeffective boolean value is not defined for a sequence of two or more items not starting with an XPath node.�FORG0006Nz0effective boolean value is not defined for {!r}.)rMrNr'rxr�r�r�r-r,r�r�r�math�isnanr�r�)rKr�r�rBrBrFr�;s"
zXPathToken.boolean_valuecCs�|durdSt|t�r4t|ttf�r.t|j�S|jSt|�rJ|j�|j	�St
|d�r�t|�rb|jSt
|�rp|jSt
|d�r�t
|d�r�td�t|���Sn&t|�r�d�t|����}t|�S|SdS)z�
        The typed value, as computed by fn:data() on each item.
        Returns an instance of UntypedAtomic for untyped data.

        https://www.w3.org/TR/xpath20/#dt-typed-value
        Nr��attribr�rR)rMrrrr-r\r(r>r�r��hasattrr#r�r$rvr"r&�getroot�rKr�r\rBrBrFr�Us&


zXPathToken.data_valuecCs�|durdSt|t�rdt|t�rB|jdur8d�t|��St|j�St|ttf�rZt|j�S|jS�nNt	|�r~t|j
�|j��St
|d�r�t|�r�|jSt|�r�|jSt
|d�r�t
|d�r�d�t|��Sn�t|�r�d�t|����St|t��r�|�r�dSdSt|t��r0t|d�}d	|v�r,|�d
��d	�S|St|t��r�t�|��rLdSt�|��rdt|���St|�}d	|v�r�|�d
��d	�}d|v�r�|�dd�}d
|v�r�|��S|St|�S)z?
        The string value, as computed by fn:string().
        NrRr�r�r��trueZfalse�fr��0ZNaN�+�e)rMrrr\rvr"r�rr r(r>r�r�r�r#r�r$r&rr�rr��rstripr�r�r�Zisinf�upper�replacerrBrBrFr�tsT











zXPathToken.string_valuec	Cs@ztt|�r|�|�n|�WSttfy:td�YS0dS)zd
        The numeric value, as computed by fn:number() on each item. Returns a float value.
        �nanN)r�r'r�r�r�)rKr�rBrBrFr��szXPathToken.number_value)r�rAcCsT|jj�d�tkrd|S|jj��D](\}}|tkr&|rFd||fn|Sq&|S)zReturns a prefixed error code.r�zerr:%sri)r>r�r�r�items)rKr�r�r�rBrBrF�
error_code�szXPathToken.error_code)r��message_or_errorrAcCs t|t�r|j}|j}nZd|vr&d}nLz|�d�\}}Wn*tybtd||�d�|d��Yn0|jj	�
|�}|r�|tkr�tdt|�d�|d��zt|\}}Wn*t
y�td||�d�|d��Yn0|dur�|}n,t|t�r�|}nt|t��r|j}nt|�}|||�|�|d�S)	aJ
        Returns an XPath error instance related with a code. An XPath/XQuery/XSLT error code is an
        alphanumeric token starting with four uppercase letters and ending with four digits.

        :param code: the error code as QName or string.
        :param message_or_error: an optional custom additional message.
        rhNz%r is not a prefixed namer�)r�r��tokenz%r namespace is requiredzunknown XPath error code %r)r�r)rMr6r�Z
local_namer�r�rrr>r�r�rrr�r�rr�)rKr�r
r�r�Zerror_classZdefault_messager�rBrBrFr��sH
���
zXPathToken.error�XPST0003)r�r�cGs|r|j|vr|�||��dSrd�rYr��rKr�r�ZsymbolsrBrBrF�expected�szXPathToken.expectedcGs|r|j|vr|�||��dSrdrrrBrBrF�
unexpected�szXPathToken.unexpectedcs>|jdkrd}|r|�||�Stt|��|�}|�|t|��S)NrUr�)rZr�r_r=r�r�)rKr�r�r�rbrBrFr��s
zXPathToken.wrong_syntaxcCs|�d|�S)NZFOCA0002�r��rKr�rBrBrF�wrong_valueszXPathToken.wrong_valuecCs|�d|�S)Nr�rrrBrBrF�
wrong_type
szXPathToken.wrong_typecCs|�d|�S)NZXPST0001rrrBrBrF�missing_schema
szXPathToken.missing_schemacCs|�d|�S)NZXPDY0002rrrBrBrFr�szXPathToken.missing_contextcCs|�d|�S)Nr�rrrBrBrFr�szXPathToken.wrong_context_typecCs|�d|�S)NZXPST0005rrrBrBrF�missing_sequenceszXPathToken.missing_sequencecCs|�d|�S)NZXPST0008rrrBrBrF�missing_nameszXPathToken.missing_namecCs |jjr|�d|�S|�d|�S)NZXPST0010r)r>r�r�rrBrBrF�missing_axisszXPathToken.missing_axiscCs|�d|�S)Nr�rrrBrBrF�wrong_nargs!szXPathToken.wrong_nargscCs|�d|�S)NZXPTY0018rrrBrBrF�wrong_step_result$szXPathToken.wrong_step_resultcCs|�d|�S)NZXPTY0019rrrBrBrF�wrong_intermediate_step_result'sz)XPathToken.wrong_intermediate_step_resultcCs|�d|�S)NZXPTY0020rrrBrBrF�wrong_axis_argument*szXPathToken.wrong_axis_argumentcCs|�d|�S)NZXPDY0050rrrBrBrFr�-szXPathToken.wrong_sequence_typecCs|�d|�S)NZXPST0051rrrBrBrF�unknown_atomic_type0szXPathToken.unknown_atomic_typecCs|�d|�S)NZXPST0080rrrBrBrF�wrong_target_type3szXPathToken.wrong_target_typecCs|�d|�S)NZXPST0081rrrBrBrF�unknown_namespace6szXPathToken.unknown_namespace)N)N)rFFNNN)N)N)N)N)NT)N)Nr)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)I�__name__�
__module__�__qualname__�__doc__r�r��__annotations__rr:r
rLrrIr�r`�propertyrfr�r�rr�r�r�r�r�r�r�r�r�r�r�r�r��
contextlib�contextmanagerr�r�r�r�r	rrr�r�r�r�r�r�r�rr6rr�rrr�rrrr�r�rrrrrrrr�r r!r"�
__classcell__rBrBrbrFr=:s|

 �
U
	

)0
3
+
/$X
3��8















r=c@s*eZdZUdZdZdZeed<dd�ZdS)�	XPathAxiszN\b[^\d\W][\w.\-\xb7\u0300-\u036F\u203F\u2040]*(?=\s*\:\:|\s*\(\:.*\:\)\s*\:\:)rVF�reverse_axisc
CsJ|j�d�|j�dddddddd	d
dd�|jj|jd
�f|dd�<|S)Nz::rzr}r�ryr~Zcommentzprocessing-instructionr�zschema-attributerr|)�rbp)r>�advanceZ
expected_name�
expressionr.rtrBrBrF�nud?s
�z
XPathAxis.nudN)	r#r$r%�patternrZr-r�r'r1rBrBrBrFr,:s
r,c@sDeZdZdZdZd	eeed�dd�Zd
eee	ed�dd�Z
dS)�
ValueTokenz2
    A dummy token for encapsulating a value.
    z(value)Nr?cCs|jSrd�r\rJrBrBrFrLPszValueToken.evaluateccs|jVdSrdr4rJrBrBrFrISszValueToken.select)N)N)r#r$r%r&rYrr:r
rLrrIrBrBrBrFr3Jsr3c	s�eZdZUdZdZeeed<dZdZ	e
edfed<dZe
ed<dd	eedd
��fdd�
Zdeeeeeeee
edffed
�dd�Zedd��Zedd��Zdd�Z�ZS)�
XPathFunctionz1
    A token for processing XPath functions.
    N�_namezO\b[^\d\W][\w.\-\xb7\u0300-\u036F\u203F\u2040]*(?=\s*(?:\(\:.*\:\))?\s*\((?!\:))rB.�sequence_types�nargsr<)r>r8rAcs�t��|�t|t�r�||jkr�|dkr6|�dd��nj|jdurH||_nXt|jt�rb|�dd��n>|jd|ks�|jddur�|jd|kr�|�dd��n||_dS)Nrr�z(number of arguments must be non negativezincongruent number of argumentsr
)r_�__init__rMr�r8r�)rKr>r8rbrBrFr9ds
*zXPathFunction.__init__)r@�
argument_listrAcCs�g}t|ttf�r(|D]}|�|�qnBt|t�rj|jdkrH|�|�n"|��D]}|jdvrP|�|�qPt|�}|jdkr�|dur�|���t	||j
|�D]D\}}}|j�||�s�d}|�
d|�|dj���||j|dj<q�n|tdd�|D���rt	|td	d
�|��D]\}}	||	_�q
n@|��|D]2}t|t��rF|�|�n|�t|j|d���q*|�|�}
|j�|
|j
d��s�d
}|�
d|�|
|j
d���|
S)Nrj)rjrSrUzinvalid type for argument {!r}r�rcss|]}|jdkVqdS)�?N�rY)rDr�rBrBrFrg�rHz)XPathFunction.__call__.<locals>.<genexpr>cSs
|jdkS)Nr;r<)rErBrBrF�<lambda>�rHz(XPathFunction.__call__.<locals>.<lambda>r4ruz${!r} does not match sequence type {})rMrN�tupler�r=rYr�rr��zipr7r>Zmatch_sequence_typer�r�r\r�r��filter�clearr3rL)rKr@r:�argsrZvariableZ
sequence_typer\r�r�r�rBrBrF�__call__rs@




zXPathFunction.__call__cCs||jdkrdS|jdurv|jr(|jtkr<ttd|j�|_n:|jtkrZttd|j�|_n|jtkrvttd|j�|_|jS)NrUzfn:%szxs:%szmath:%s)rYr6r�rr6rrrtrBrBrFr��s



zXPathFunction.namecCst|jt�r|jSt|�Srd)rMr8r�rxrtrBrBrF�arity�szXPathFunction.aritycCs�|jdkrdnd}d|_|j�d�|jdur�|dd�=|jjjdvrR|�|d��|�|j�	d��|jjjdkrtq�|j��qR|j�d	�|S|jd
kr�|jjjd	kr�|jjjdkr�|�|dt
|���|jj���|j��|St|jt
tf��r|j\}}n
|j}}d
}||k�r�|jjjdv�rRd
|}|�|dk�rD|n
|dd���|j�	d�f||d�<|d7}||k�r|jjjd	k�r�d
|}|�||dk�r�|n
|dd���|j�d��q|du�s�||k�rN|jjjdk�r|j�d�|j�	d�f||d�<n6|d
k�rN|jjjd	k�rN|j�	d�f||d�<n�qN|d7}�q�|jjjdk�r�d|}|�||dk�rz|n
|dd���|j�d	�|S)NrUr�rrj)�)�(end)z at least an argument is required�rSrErrFz%s has no argumentsz1Too few arguments: expected at least %s argumentsr
ruz1Too many arguments: expected at most %s arguments)rZr\r>r/r8Z
next_tokenrYr�r�r0r�r�rMr>rNr)rKr�Zmin_argsZmax_argsrsr�rBrBrFr1�s`





 
""zXPathFunction.nud)N)NN)r#r$r%r&r6rr6r'r2r7rr�r8�	NargsTyper�r9r:r	r=rr
rCr(r�rDr1r+rBrBrbrFr5Ws&
���,


r5)Ur&r�r)r�rZdecimalr�	itertoolsr�typingrrrrr	r
r�urllib.parser�Zxml.etree.ElementTreer�
exceptionsrrrZhelpersrr�rrrrrrrrZxpath_nodesrrrrrrr r!r"r#r$r%r&r'r(Z	datatypesr)r*r+r,r-r.r/r0r1r2r3r4r5r6Zschema_proxyr7Ztdopr8r9Z
xpath_contextr:r;Zxpath1r<r�r�r�rHr=r,r3r5rBrBrBrF�<module>
sD$(D@


Youez - 2016 - github.com/yon3zu
LinuXploit