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/xpath2/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

���c���@srdZddlmZddlZddlZddlZddlmZddlmZddl	m
Z
mZddlm
Z
ddlmZmZmZd	d
lmZd	dlmZmZmZmZmZd	dlmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%d	d
l&m'Z'm(Z(m)Z)m*Z*m+Z+d	dl,m-Z-m.Z.m/Z/m0Z0m1Z1d	dl2m3Z3m4Z4m5Z5d	dl6m7Z7d	dl8m9Z9d	dl:m;Z;Gdd�de7�Z<e<j=Z=e<j>Z>e<j?Z?e<j@Z@e<jAZAe>d�e>d�e>d�e>d�e>d�e>d�e>d�e>d�e>d�e=d�e=d�e=d �e=d!�e=d"�e=d#�e=d$�e=d%�e@d&�e@d'�d(d)���ZBe@dd*d+�d,d-��ZCe@d�d�d.d/��ZDe<�Ed0d1�e@e?d2d3d+��e@e?d4d3d+��d�d5d6���ZFe@d7d8d+�d9d:��ZGe@d7�d�d;d<��ZHe@d7�d�d=d>��ZIe@d?d8d+�e@d@d8d+�dAdB���ZJe@d?�e@d@�d�dCdD���ZKe@dEd8d+�dFdG��ZLe@dE�d�dHdI��ZMe@dJdKd+�e@dLdMd+�dNdO���ZNe@dJ�d�dPdQ��ZOe@dL�d�dRdS��ZPe@dTdUd+�e@dVdWd+�dXdY���ZQe@dT�e@dV�d�dZd[���ZRe@e?dd\d+��d�d]d^��ZSe@d�d�d_d`��ZTe@ddad+�dbdc��ZUe@d�d�ddde��ZVe@d�d�dfdg��ZWe@dhdid+�e@djdid+�e@dkdid+�e@dldid+�e@dmdid+�e@dndid+�dodp�������ZXe@dh�e@dj�e@dk�e@dl�e@dm�e@dn�d�dqdr�������ZYe@dsdid+�dtdu��ZZe@ds�e@e?dvdid+��e@e?dwdid+��d�dxdy����Z[e@dzd{d+�d|d}��Z\e@dz�d�d~d��Z]e@dz�d�d�d���Z^e@e?d�d�d+��d�d�d���Z_e@d1�e@d2�e@d4�e@dh�e@dj�e@dk�e@dl�e@dm�e@dn�e@ds�e@dz�e@d��e@dJ�e@dL�e@dT�e@dV�d�d������������������Z`e@eAd�d�d�d���d�d�d���Zae@d��d�d���Zbe@eAd�d�d�d���d�d�d���Zce@d��d�d���Zde@eAd�d�d�d���d�d�d���Zee@eAd�d�d�d���d�d�d���Zfe@d��e@d��d�d����Zge>d��e=d�d*d*d�d�d��e@d��d�d���Zhe@d��d�d�d���ZidS)�zF
XPath 2.0 implementation - part 1 (XPath2Parser class and operators)
�)�ABCMetaN)�MutableSequence)�copy)�Decimal�DivisionByZero)�urlparse)�cast�Dict�Optional���normalize_sequence_type)�ElementPathError�ElementPathTypeError�ElementPathValueError�MissingContextError�xpath_error)�NamespacesType�
XSD_NAMESPACE�
XML_NAMESPACE�XLINK_NAMESPACE�XPATH_FUNCTIONS_NAMESPACE�XQT_ERRORS_NAMESPACE�XSD_NOTATION�XSD_ANY_ATOMIC_TYPE�
get_namespace�get_prefixed_name�get_expanded_name)�
UntypedAtomic�QName�AnyURI�Duration�Integer)�TypedElement�
is_xpath_node�match_attribute_node�is_element_node�is_document_node)�
XPathToken�UNICODE_CODEPOINT_COLLATION�
XPathFunction)�XPath1Parser)�XPathSchemaContext)�AbstractSchemaProxycsneZdZdZdZejhd�BZeee	e
ed�ZdZ
hd�Zej��Zd-eeeeefeeeeeeeeeeeeeeeeeefeeeefedd��fdd
�
Zdd�Zeed�dd��Zejedd�dd��Zeed�dd��Zeeed�dd��Zeed�dd��Z�fdd�Ze d.d!d"��Z!d/d$d%�Z"ed�d&d'�Z#ee$d(��fd)d*�Z%d+d,�Z&�Z'S)0�XPath2ParseraR

    XPath 2.0 expression parser class. This is the default parser used by XPath selectors.
    A parser instance represents also the XPath static context. With *variable_types* you
    can pass a dictionary with the types of the in-scope variables.
    Provide a *namespaces* dictionary argument for mapping namespace prefixes to URI inside
    expressions. If *strict* is set to `False` the parser enables also the parsing of QNames,
    like the ElementPath library. There are some additional XPath 2.0 related arguments.

    :param namespaces: a dictionary with mapping from namespace prefixes into URIs.
    :param variable_types: a dictionary with the static context's in-scope variable     types. It defines the associations between variables and static types.
    :param strict: if strict mode is `False` the parser enables parsing of QNames,     like the ElementPath library. Default is `True`.
    :param compatibility_mode: if set to `True` the parser instance works with     XPath 1.0 compatibility rules.
    :param default_namespace: the default namespace to apply to unprefixed names.     For default no namespace is applied (empty namespace '').
    :param function_namespace: the default namespace to apply to unprefixed function     names. For default the namespace "http://www.w3.org/2005/xpath-functions" is used.
    :param schema: the schema proxy class or instance to use for types, attributes and     elements lookups. If an `AbstractSchemaProxy` subclass is provided then a schema     proxy instance is built without the optional argument, that involves a mapping of     only XSD builtin types. If it's not provided the XPath 2.0 schema's related     expressions cannot be used.
    :param base_uri: an absolute URI maybe provided, used when necessary in the     resolution of relative URIs.
    :param default_collation: the default string collation to use. If not set the     environment's default locale setting is used.
    :param document_types: statically known documents, that is a dictionary from     absolute URIs onto types. Used for type check when calling the *fn:doc* function     with a sequence of URIs. The default type of a document is 'document-node()'.
    :param collection_types: statically known collections, that is a dictionary from     absolute URIs onto types. Used for type check when calling the *fn:collection*     function with a sequence of URIs. The default type of a collection is 'node()*'.
    :param default_collection_type: this is the type of the sequence of nodes that     would result from calling the *fn:collection* function with no arguments.     Default is 'node()*'.
    z2.0>�zadjust-time-to-timezoneZcomparezone-or-moreZdouble�castable�forzyear-from-dateTimeZdateTimeZgDayZmatches�then�returnztimezone-from-time�as�abs�min�replace�schema-elementZsubsequenceZNMTOKENZgYearzelement-with-idzdocument-urizseconds-from-durationzminutes-from-dateTime�ner�intzminutes-from-timez	ends-with�floatZshortZunsignedLongZ	gMonthDayZIDREF�docZbase64Binaryzhours-from-time�	satisfies�leZidref�toZavgZgMonth�everyzseconds-from-dateTime�eqzindex-ofz
resolve-QNamezzero-or-onezexactly-oneznamespace-uri-from-QName�else�elementztimezone-from-dateZtracezbase-uri�treatZIDZNCNamezimplicit-timezone�Name�decimalzyear-from-datezencode-for-uri�timez
insert-beforeZ	hexBinary�geZunsignedByte�except�idivzcodepoint-equalzin-scope-prefixes�gtzround-half-to-evenztimezone-from-dateTime�maxZlong�root�instanceZ
gYearMonthZ	unorderedz
day-from-datez
upper-casez
iri-to-urizmonth-from-dateTimezcurrent-dateTimeZnormalizedString�>>znormalize-unicode�?r�existszdefault-collationZdayTimeDuration�tokenizeZanyURI�somezstring-to-codepoints�	attribute�schema-attributezlocal-name-from-QNameZlanguageZ
dateTimeStamp�inZinteger�ifzresolve-urizprefix-from-QNamezcodepoints-to-stringZpositiveIntegerZ
collectionZ
untypedAtomic�date�removezseconds-from-time�empty-sequencezday-from-dateTime�:)z
lower-casezcurrent-timeZyearMonthDurationZnilled�of�<<ZNOTATIONzyears-from-durationzmonth-from-datez
doc-available�	intersect�unionzhours-from-durationzdays-from-durationz	node-nameznamespace-uri-for-prefix�dataZdurationzhours-from-dateTime�reverseZ
unsignedShortzadjust-date-to-timezonezescape-html-urizadjust-dateTime-to-timezone�(:z
deep-equalzstatic-base-uriZnonNegativeIntegerZnonPositiveIntegerZunsignedInt�empty�
document-node�tokenzmonths-from-durationzcurrent-date�error�is�itemZbytezstring-joinZnegativeIntegerZENTITYzminutes-from-durationzdistinct-values�lt)ZxmlZxsZxlink�fn�err)�axis�function�	kind test>z(float)z	(integer)�{z	(decimal)�.�(name)�(�*�@z(string)z..NTF�node()*)�
namespaces�variable_types�strict�compatibility_mode�default_collation�default_namespace�function_namespace�xsd_version�schema�base_uri�document_types�collection_types�default_collection_typer2csXtt���||�|�_|�_|dur*|nd�_|durB|�jd<|durP|�_|	durZn"t|	t	�srd}t
|��n
|	���|s�i�_n8t
�fdd�|��D��r�dd�|��D��_ntd��|
dur�dn
t|
����_|�rt�fd	d�|��D���rtd
��|�_|�r4t�fdd�|��D���r4td��|�_��|
��sNtd
��|
�_dS)Nz1.0�z<argument 'schema' must be an instance of AbstractSchemaProxyc3s|]}��|�VqdS�N��is_sequence_type��.0�v��self��D/usr/lib/python3.9/site-packages/elementpath/xpath2/xpath2_parser.py�	<genexpr>��z(XPath2Parser.__init__.<locals>.<genexpr>cSsi|]\}}|t|��qSr�r)r��kr�r�r�r��
<dictcomp>�sz)XPath2Parser.__init__.<locals>.<dictcomp>z1invalid sequence type for in-scope variable typesc3s|]}��|�VqdSr�r�r�r�r�r�r��r�z0invalid sequence type in document_types argumentc3s|]}��|�VqdSr�r�r�r�r�r�r��r�z2invalid sequence type in collection_types argumentz:invalid sequence type for default_collection_type argument)�superr.�__init__�_compatibility_mode�_default_collation�_xsd_versionrur{�
isinstancer-rZbind_parserrv�all�values�itemsrr�geturlr~�anyrr�r�r�)r�rurvrwrxryrzr{r|r}r~rr�r��msg��	__class__r�r�r��sB



�
zXPath2Parser.__init__cCs&|j��}|�dd�|�dd�|S)N�symbol_tableZ	tokenizer)�__dict__r�pop)r��stater�r�r��__getstate__�s
zXPath2Parser.__getstate__)r2cCs|jSr��r�r�r�r�r�rxszXPath2Parser.compatibility_mode)�valuer2cCs
||_dSr�r�)r�r�r�r�r�rxscCsZ|jdur|jSt��\}}|dur(tS|dus4|s8|S|�d|��}|dkrR|StSdS)Nrozen_US.UTF-8)r��localeZgetdefaultlocaler))r�Z
language_code�encodingZ	collationr�r�r�rys
zXPath2Parser.default_collationcCs|j�d�S)Nr�)ru�getr�r�r�r�rzszXPath2Parser.default_namespacec	Cs<|jdur|jSz
|jjWSttfy6|jYS0dSr�)r}r�r|�AttributeError�NotImplementedErrorr�r�r�r�r|!s

zXPath2Parser.xsd_versioncs�tt|�j|�|jjdkr�z|j�d�Wnty>Yn0d}|rt|�dd�|jjdkrj|d8}qD|d7}qD|�d�|j�d�|jS)Nra�:�rZ)	r�r.�advance�
next_token�symbolrdZ
unexpectedr�Z
advance_until)r�ZsymbolsZ
comment_levelr�r�r�r�+s


zXPath2Parser.advancerr�r��constructor functionc
sfdd�}ddd�}dd�}|s6|dks*J�d	d
|f}|j||||tf|||||d�
��fdd
�}	|	S)z"Creates a constructor token class.cSstzP|j�d�|j�d�f|dd�<|jjjdkr<|�d��|j�d�d|_Wntyn|�d�d�Yn0|S)Nrq�r�,�/Too many arguments: expected at most 1 argument�)ZXPST0017)	�parserr��
expressionr�r��wrong_nargsr��SyntaxErrorrer�r�r�r��nud_Es

z&XPath2Parser.constructor.<locals>.nud_Nc
Ss�|�|�|��}|durgSz$t|t�r6|�|j�WS|�|�WStyT�Yn6ttfy�}z|�	d|�d�WYd}~n
d}~00dS�N�FORG0001)
�
data_value�get_argumentr�rrr�r�	TypeError�
ValueErrorre)r��context�argrjr�r�r��	evaluate_Qs
z+XPath2Parser.constructor.<locals>.evaluate_cSst�dSr�)r��r�r�r�r��cast__sz'XPath2Parser.constructor.<locals>.cast_r�zxs:anyAtomicType?zxs:%s?)	�nargs�sequence_types�label�bases�lbp�rbp�nud�evaluatercs0|j�d�d}|dkr td��t�||�|S)N�_rrz7The function name must be 'cast' or starts with 'cast_')�__name__�	partitionr��setattr)�funcZmethod_name��token_classr�r��bindjs
z&XPath2Parser.constructor.<locals>.bind)N)�registerr*)
�clsr��bpr�r�r�r�r�r�r�r�r�r��constructorBs


�zXPath2Parser.constructor�Zc	s��tthvrtd��dd�}d�fdd�	}t�|j�}d|�dd	�}|d
dd||||||j|dd
�}t|tf|�}t	�
|�||j|<|S)zFRegisters a token class for a schema atomic type constructor function.�XPST0080cSsZ|j�d�|j�d�f|dd�<|j�d�z|��|_WntyTd|_Yn0|S)Nrqr�rr�)r�r�r�r�r�r)�self_r�r�r�r�wsz-XPath2Parser.schema_constructor.<locals>.nud_Nc
sl|�|�}|durgS|�|�}z|jj�|��WSttfyf}z|�d|��WYd}~n
d}~00dSr�)r��string_valuer�r}�cast_asr�r�re)r�r�r�r�rj��atomic_typer�r�r��s

z2XPath2Parser.schema_constructor.<locals>.evaluate_z_%sConstructorFunctionr�r�r�r�z\b%s(?=\s*\(|\s*\(\:.*\:\)\())r�r�r��patternr�r�r�r��
__module__�__qualname__Z
__return__)N)rrrrrur6r�rr*rr�r�)	r�r�r�r�r�r�Ztoken_class_name�kwargsr�r�r�r��schema_constructorrs,�


zXPath2Parser.schema_constructorcCs
d|jvS)Nr�)r�r�r�r�r��is_schema_bound�szXPath2Parser.is_schema_bound)�sourcer2csvtttt|��|��}|jdkr,|�dd��|jdurXz|��Wqrt	yTYqr0n|j�
�}|�|�D]}ql|S)N�
sequence type�XPST0003znot allowed in XPath expression)rr(r�r+�parser�rer}r�rZget_context�select)r�r�Z
root_tokenr�r�r�r�r�r��s


zXPath2Parser.parsec	Cs�|j��D] \}}||vr
tdd�|���q
|��D]\\}}z|j|}Wn$tynt|t�rfdnd}Yn0|�||�s4d�|�}td|��q4dS)N�XPST0008zmissing variable {!r}zitem()*zitem()z)Unmatched sequence type for variable {!r}ZXPDY0050)rvr�r�format�KeyErrorr��listZmatch_sequence_type)r�r��varname�xsd_typer��
sequence_type�messager�r�r��check_variables�s
zXPath2Parser.check_variables)
NNTFNNNNNNNNrt)rr�r�r�)r�)(r�r�r��__doc__�versionr+ZSYMBOLSrrrrrZDEFAULT_NAMESPACESZPATH_STEP_LABELSZPATH_STEP_SYMBOLSZfunction_signaturesrrr
r	�str�boolr-r�r��propertyrx�setterryrzr|r��classmethodr�r�r�r(r�r��
__classcell__r�r�r�r�r.&sr&e�
��;	/
/r.r�rq�$�containsZlang�idzsubstring-beforezsubstring-afterzstarts-withr1rArUr2r<rOrarZr3r[cCs|�d��dS)NZXPDY0002)rer�r�r�r��nud_as_and_of_symbols�sr�r�)r�cCs(|j�d�|jjdd�f|dd�<|S)Nrpr��r�)r��
expected_namer�r�r�r�r��nud_variable_reference�srcCs|dur|���zt|dj|jj�Wn6ty^}z|�dd�|���WYd}~n
d}~00|dj}z|j|WSt�yt	|t
��r�z|jj|��}Wnty�YnF0|ddvr�|dd�}t
j�|�dur�|j�|�YStd�YSYn0|�dt|���dS)Nr�XPST0081�namespace prefix {} not found���>rrrO�+r�zunknown variable %r)�missing_contextrr�r�rur�rer��	variablesr�r,rv�striprr��matchZget_atomic_valuer�missing_namer�)r�r�rjr�r�r�r�r��evaluate_variable_reference�s*(
r�|r^r]�7rHccs�|dur|���t|d�t|���t|d�t|���}}tdd�|D��sbtdd�|D��rn|�dd��|jdkr�|�||�EdHn|�||@�EdHdS)Nrr�css|]}t|�VqdSr�)r$�r��xr�r�r�r�r�z8select_intersect_and_except_operators.<locals>.<genexpr>�XPTY0004zonly XPath nodes are allowedrH)r�setr�rr�rer�Ziter_results)r�r��s1�s2r�r�r��%select_intersect_and_except_operatorss.$
rrV�cCs�|jjjdkr,|jjd|j|j�}|��S|j�d�|j�d�f|dd�<|j�d�|j�d�|j�d�f|dd�<|j�d�|j�d�f|dd�<|S)	Nrqrpr�r�r1r�rAr)r�r�r�r�r�r�r��r�rdr�r�r��nud_if_expression*srcCs8|�|d�t|���r&|d�|�S|d�|�SdS)Nrr�r)�
boolean_valuer�r�r�r�r�r�r��evaluate_if_expression:srccsP|�dd�|d�t|��D��r8|d�|�EdHn|d�|�EdHdS)NcSsg|]}|�qSr�r�rr�r�r��
<listcomp>Dr�z(select_if_expression.<locals>.<listcomp>rr�r)rr�rrr�r�r��select_if_expressionBs"rrRr?cCs�|dd�=|jjjdkr6|jjd|j|j�}|��S|jj�d�|j�d�}|�|�|j�d�|j�d�}|�|�t	dd�|�
��D]$}|dj|djkr�|�dd	��q�|jjjd
kr�q�|j��q6|j�d�|�|j�d��|S)Nr�rpr�rUcSs
|jdkS�Nr��r��rr�r�r��<lambda>[r�z,nud_quantified_expressions.<locals>.<lambda>rr��%loop variable in its range expressionr�r<�
r�r�r�r�r�Zexpectedr��appendr��filter�iterr�re�r�rdZvariable�exprZtkr�r�r��nud_quantified_expressionsLs&


r)cs�|dur����t|�}�jdk}�fdd�tdt��dd�D�}�fdd�tdt��dd�D�}t|��||�D]X}|j�dd	�t||�D����	d
d��d�
t|��D��r�|r�dSqv|svd
Sqv|S)NrRcsg|]}�|dj�qS�rr��r�r�r�r�r�rpr�z3evaluate_quantified_expressions.<locals>.<listcomp>rr�rcsg|]}�|j�qSr��r�r+r�r�r�rqr�css|]
}|VqdSr�r�rr�r�r�r�tr�z2evaluate_quantified_expressions.<locals>.<genexpr>cSsg|]}|�qSr�r�rr�r�r�rur�rTF)rrr��range�len�iter_productr�update�ziprr�)r�r�rR�varnames�	selectors�resultsr�r�r��evaluate_quantified_expressionshs
"""r5r0cCs�|dd�=|jjjdkr6|jjd|j|j�}|��S|jj�d�|j�d�}|�|�|j�d�|j�d�}|�|�t	dd�|�
��D]$}|dj|djkr�|�dd	��q�|jjjd
kr�q�|j��q6|j�d�|�|j�d��|S)Nr�rpr�rUcSs
|jdkSrrr r�r�r�r!�r�z$nud_for_expression.<locals>.<lambda>rr�r"r�r2r#r'r�r�r��nud_for_expression�s&


r6c#s�|dur����t|�}�fdd�tdt��dd�D�}�fdd�tdt��dd�D�}t|��||�D]8}|j�dd�t||�D���d	�t|��EdHqldS)
Ncsg|]}�|dj�qSr*r�r+r�r�r�r�r�z)select_for_expression.<locals>.<listcomp>rr�rcsg|]}�|j�qSr�r,r+r�r�r�r�r�css|]
}|VqdSr�r�rr�r�r�r��r�z(select_for_expression.<locals>.<genexpr>r)	rrr-r.r/rr0r1r�)r�r�r2r3r4r�r�r��select_for_expression�s""r7rM�<rC�=c
Cs�|j�|jdkrdnd�|jjjdvr6|j�dd�z ||jj|jd�f|dd�<WnBty�}z*t	|dt
|��}|�d	|�d�WYd}~n
d}~00|jjj}|d
jdkr�|dvr�|jj||j�f|d
d�<|j��|S)NrMr[r3�rmr�rpr�rr�r�r�rY)rOrrrr)
r�r�r�r�r�rr�r�r�getattrr�rer�)r��leftrjr�Znext_symbolr�r�r��#led_sequence_type_based_expressions�s $

r=c

Cs�t|�dkr|djnd}d}|djdkrH|d�|�D]}dSdS|djdvr�|durf|���t|d�|��D]F\}|_|d�|�}t|t	�r�|s�dS|rx|dus�|dkrxdSqx|dup�|d	vSzt
|dj|jj
�}Wn8t�y }z|�d
d�|���WYd}~n
d}~00t|d�|��D]x\}}z|j�||��sVWdSWn0t�y�d}	|�d
|	|dj�d�Yn"0|�r4|du�s�|dk�r4dS�q4|du�p�|d	vSdS)Nrr�rYrFTr:rO�rrrOrr�1atomic type %r not found in in-scope schema types�XPST0051)r.r�r�r�r�	enumeratergr�r�r�rr�r�rur�rer��is_instance)
r�r��occurs�positionr��result�qnamerjrgr�r�r�r��evaluate_instance_expression�s<(
rGc
Cst|�dkr|djnd}d}g}|djdkrP|d�|�D]}|���q>�n�|djdvr�t|d�|��D]V\}}|d�|�}t|t�r�|s�|���n|r�|dus�|dkr�|�d��|�	|�qp|dur�|dvr�|�d	���n"zt
|dj|jj
�}Wn<t�y:}	z"|�d
d�t|	����WYd}	~	n
d}	~	00t|d�|��D]�\}}z0|j�||��s�d}
|�|
||djf��Wn0t�y�d
}
|�d|
|dj�d�Yn00|�r�|du�s�|dk�r�|�d��|�	|��qN|du�r|dv�r|�d	��|S)Nrr�rYrr:rOzmore than one item in sequencer>zthe sequence cannot be emptyr�prefix {} not foundzitem %r is not of type %rr?r@)r.r�r�Zwrong_sequence_typer�rAr�r�r�r$rr�r�rur�rer�r�rB)r�r�rCrDZ
castable_exprr�rgrErFrjr�r�r�r��evaluate_treat_expression�sD

,

rIr/�>r�?cCsn|j�d�|j�dd�||jj|jd�f|dd�<|jjjdkrj|jjd|j�f|dd�<|j��|S)Nr3rpr�rrOr)r�r�rr�r�r�r�r��r�r<r�r�r��led_cast_expressionss
rMc
Csnzt|dj|jjd�}Wn:tyT}z"|�dd�t|����WYd}~n
d}~00|tt	fvrl|�d��t
|�}|tkr�|jjdus�|jj�
|�dur�d}|�||��dd�|d	�|�D�}t|�dkr�|jd
kr�dS|�d��nB|�s,t|�d
k�r|jd
k�rgSdS|jd
k�r"dS|�d��|�|d	�}z�|tk�r^|jj�|�|�|�}n^|�d�d}	|jj�|	�}
|
du�s�|
jdk�r�d}|�||dj��|
|j�}|�|�}Wn�t�y�|jd
k�r�YdS�Yn�ttf�yT}zR|jd
k�rWYd}~dSt|ttf��r2|�d|�d�|�d|�d�WYd}~nd}~00|jd
k�rf|SdSdS)Nr��rurrHr�z5atomic type %r not found in the in-scope schema typescSsg|]}|�qSr�r�)r��resr�r�r�r3r�z-evaluate_cast_expressions.<locals>.<listcomp>rrFz!more than one value in expression�Tzan atomic value is required�}r�r�r) rr�r�rur�rer�r�rrrrr}Zget_typeZunknown_atomic_typer�r.r�Zwrong_context_typer�r�r��splitr�r�r�rrr�r�r�r)r�r�r�rj�	namespacer�rEr�r�Z
local_namer�rdr�r�r��evaluate_cast_expressions"s^,

��



$rTr�cCsDg}|D]6}|�|�}t|t�r,|�|�q|dur|�|�q|Sr�)r�r�r��extendr$)r�r�r4�oprEr�r�r��evaluate_comma_operator^s

rWccs$|D]}|jt|�d�EdHqdS)N�r�)r�r)r�r�rVr�r�r��select_comma_operatorjsrY�dcCs2|jjjdkr"|j��f|dd�<|j�d�|S)Nr�)r�r�r�r�r�r�r�r�r��nud_parenthesized_expressionrsr[cCs|r|d�|�SgS)Nr�r�rr�r�r��!evaluate_parenthesized_expressionzsr]cCs|r|d�|�Std�S)Nrr�)r�r&rr�r�r��select_parenthesized_expressionsr^r@�r8rhrJr=rGcCs0|jdvr|���||jjdd�f|dd�<|S)N>r@r=r8rGrJrhr_r�r�Zwrong_syntaxr�r�rLr�r�r��led_value_comparison_operators�s
rac
Cs�|djt|�d�|djt|�d�g}tdd�|D��r>dSt|d�t|d�}}||urj|turjn�tdd�|D��r~n�tdd�|D��r�n�tdd�|D��r�n�td	d�|D��r�t|dt�r�t|d�|d<nt|d�|d<nftd
d�|D���r|jdv�rnDt	||��s$t	||��r2t	|t��s2ndj
|g|�R�}|�d
|��ztt
|j�|�WSt�y�}z|�d
|�d�WYd}~n
d}~00dS)NrrXr�css|]}|duVqdSr�r�rr�r�r�r��r�z6evaluate_value_comparison_operators.<locals>.<genexpr>css|]}t|t�VqdSr�)r�r:rr�r�r�r��r�css|]}t|ttf�VqdSr�)r�r9rrr�r�r�r��r�css|]}t|tttf�VqdSr�)r�r�rr rr�r�r�r��r�css|]}t|tttf�VqdSr�)r�r:rr9rr�r�r�r��r�css|]}t|t�VqdSr�)r�r!rr�r�r�r��r�)r@r8z%cannot apply {} between {!r} and {!r}r)Zget_atomized_operandrr��typer!r�r�r:r��
issubclassr�rer;�operatorr�)r�r�ZoperandsZcls0Zcls1r�rjr�r�r��#evaluate_value_comparison_operators�s8� $rerfcCs0|jdkr|���||jjdd�f|dd�<|S)Nrfr_rr`rLr�r�r��led_node_comparison�s
rfr\rNcCs.|j}dd�|d�|�D�}|s&dSt|�dks>t|d�sR|d�dd|��dd�|d�|�D�}|srdSt|�dks�t|d�s�|d�dd|��|d	kr�|d|duS|d|dur�d
S|j��D]H}|d|u�r�|dkr�dnd
S|d|ur�|dk�rd
ndSq�|�d
d��dS)NcSsg|]}|�qSr�r�rr�r�r�r�r�z,evaluate_node_comparison.<locals>.<listcomp>rr�rz(left operand of %r must be a single nodecSsg|]}|�qSr�r�rr�r�r�r�r�z)right operand of %r must be a single noderfFr\TZFOCA0002z'operands are not nodes of the XML tree!)r�r�r.r$rerLr&)r�r�r�r<�rightrgr�r�r��evaluate_node_comparison�s*rhr>�#cCs0|jdkr|���||jjdd�f|dd�<|S)Nr>rirr`rLr�r�r��led_range_expression�s
rjcCsH|j|td�\}}zdd�t||d�D�WStyBgYS0dS)N)r�cSsg|]}|�qSr�r�rr�r�r�r�r�z-evaluate_range_expression.<locals>.<listcomp>r�)�get_operandsr"r-r�)r�r��start�stopr�r�r��evaluate_range_expression�s
rnccs|�|�EdHdSr�r\rr�r�r��select_range_expression�srorI�-c
Cs|�|�\}}|dus|dur(|�d��zDt�|�rL|�|dkrDdnd��nt�|�s`t�|�rj|�d��Wn2ty�}z|�d|�d�WYd}~n
d}~00z||}Wn"ttfy�|�d�d�YnD0|dks�t|t	�s�t|t	�s�t
|�t
|�k�rt|�St|�dSdS)NZXPST0005rZFOAR0001ZFOAR0002rr�)rkre�mathZisinfZisnanr��ZeroDivisionErrorrr�rr4r9)r�r�Zop1Zop2rjrEr�r�r��evaluate_idiv_operators*

$��rscCs|jjd|j|j�}|��S)Nrp)r�r�r�r�rr�r�r��%nud_disambiguation_of_infix_operatorssrtrc)rr�rm)r�r�ccs�|dur|���n||sJt|j�r�|jdur�|��D]}|dur2|jVq2nDdd�|d�t|��D�}t|j�r�|jdur�t|�dkr�|jVdS)NcSsg|]}t|�r|�qSr�)r&)r��er�r�r�r?r�z2select_document_node_kind_test.<locals>.<listcomp>rr�)rr'rLrg�iter_children_or_selfr�rr.)r�r�rg�elementsr�r�r��select_document_node_kind_test5s
rxcCsz|j�d�|jjjdvrJ|j�d�f|dd�<|jjjdkrd|�d��n|jjjdkrd|�dd	��|j�d�d|_|S)
Nrq)rBr7r�rr�r�r�r�z,element or schema-element kind test expected)r�r�r�r�r�r�rer�r�r�r�r��nud_document_node_kind_testEsryrB)rrccs�|dur|���nx|s4|��D]}t|�r|VqnV|d�|�D]F}t|�dkrZ|VqBt|t�rB|d��D]}||jjkrp|VqpqBdS)Nrr�)	rrvr&r�r.r�r#r��name)r�r�rgZtype_annotationr�r�r��select_element_kind_testSs


r{cCs�|j�d�|jjjdkr�|jjddddd�|j�d�f|d	d�<|jjjd
kr�|j�d
�|jjdddd�|j�d�f|dd�<|j�d�d|_|S)
Nrqr�rpr�rrza QName or a wildcard expected�r�r�rr��a QName expectedr�)r�r�r�r�rr�r�r�r�r�r��nud_element_kind_testesr~rTr�ccs�|dur|���|dj}|��D]L}t||jj�}|jj�|�durT|�d|��t	|j
|�r"|j
VdSq"t|t�s�|�
dd|��dS)Nrz attribute %r not found in schemar�zschema attribute %r not found)rr�rvrr�rur}Z
get_attributerr%rgr�r,re)r�r�Zattribute_namer�rFr�r�r��!select_schema_attribute_kind_testts

rr7ccs�|dur|���|dj}|��D]h}t||jj�}|jj�|�durf|jj�|�durf|�	d|��t
|j�r"|jj|kr"|jVdSq"t
|t�s�|�dd|��dS)Nrzelement %r not found in schemar�zschema element %r not found)rr�rvrr�rur}Zget_elementZget_substitution_grouprr&rg�tagr�r,re)r�r�Zelement_namer�rFr�r�r��select_schema_element_kind_test�s
�
r�cCsJ|j�d�|jjdddd�|j�d�f|dd�<|j�d�d|_|S)	Nrqrpr�r}r|r�rr�)r�r�rr�r�r�r�r�r��nud_schema_node_kind_test�sr�rS)rmrkzA\battribute(?=\s*\:\:|\s*\(\:.*\:\)\s*\:\:|\s*\(|\s*\(\:.*\:\)\())r�r�r�r�c
Cs�|jjjdkrZ|j�d�|j�dddddddd	d
dd�|jjd
d�f|dd�<d|_nr|j�d�|jjjdkr�|j�d�f|dd�<|jjjdkr�|j�d�|j�d�f|dd�<|j�d�d|_|S)Nz::rprr�textZnodercZcommentzprocessing-instructionrSrTrBr7r�rrkrqr�r�r�r�rm)r�r�r�r�rr�r�r�r�r�r��nud_attribute_kind_test_or_axis�s"�r�ccs�|dur|���n�|jdkr@|��D]}|d�|�EdHq$n�|s\|��D]}|jVqLn�|dj}|jjdur�t|�dkr�t|dj|jj	d�}nd}|��D]V}t
||�r�t|t�r�|�
|�q�|s�|jVq�|�|�}|dur�|j|kr�|jVq�dS)Nrkrrr�rN)rr�Ziter_attributesr�r�r�r}r.rrur%r�r,Zadd_xsd_typeZget_xsd_typerz)r�r�r�rSrzZ	type_namer�r�r�r��"select_attribute_kind_test_or_axis�s*






r�)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)jr��abcrr�rqrd�collections.abcrrrErr�urllib.parser�typingrr	r
Zhelpersr
�
exceptionsrrrrrrurrrrrrrrrrrZ	datatypesrrr r!r"Zxpath_nodesr#r$r%r&r'Zxpath_tokenr(r)r*Zxpath1r+Z
xpath_contextr,Zschema_proxyr-r.r�Z
unregisterZinfix�methodrlr�rrZ	duplicaterrrrr)r5r6r7r=rGrIrMrTrWrYr[r]r^rarerfrhrjrnrorsrtrxryr{r~rr�r�r�r�r�r�r�r��<module>
sD4%



	





(-


:

	





%



(



�


Youez - 2016 - github.com/yon3zu
LinuXploit