HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/words/xish/__pycache__/xpath.cpython-38.pyc
U


W[T%�@s�dZddlmZmZddlmZddlmZmZGdd�de�Z	Gdd�d�Z
Gd	d
�d
�ZGdd�d�ZGd
d�d�Z
dd�ZGdd�d�ZGdd�d�ZGdd�d�ZGdd�d�ZGdd�d�ZiZdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%S)&z�
XPath query support.

This module provides L{XPathQuery} to match
L{domish.Element<twisted.words.xish.domish.Element>} instances against
XPath-like expressions.
�)�absolute_import�division)�StringIO)�
StringType�unicodec@seZdZdd�ZdS)�LiteralValuecCs|S�N���self�elemr	r	�:/usr/lib/python3/dist-packages/twisted/words/xish/xpath.py�valueszLiteralValue.valueN)�__name__�
__module__�__qualname__rr	r	r	r
rsrc@seZdZdd�Zdd�ZdS)�
IndexValuecCst|�d|_dS)N�)�int�index)rrr	r	r
�__init__szIndexValue.__init__cCs|j|jSr)�childrenrr
r	r	r
rszIndexValue.valueN)rrrrrr	r	r	r
rsrc@s$eZdZdd�Zdd�Zdd�ZdS)�AttribValuecCs||_|jdkr|j|_dS)NZxmlns)�
attribname�value_nsr)rrr	r	r
r"s
zAttribValue.__init__cCs|jSr)Zurir
r	r	r
r'szAttribValue.value_nscCs |j|jkr|j|jSdSdSr)rZ
attributesr
r	r	r
r*szAttribValue.valueN)rrrrrrr	r	r	r
r!src@s$eZdZdd�Zdd�Zdd�ZdS)�CompareValuecCs*||_||_|dkr|j|_n|j|_dS)N�=)�lhs�rhs�
_compareEqualr�_compareNotEqual�rr�oprr	r	r
r2s

zCompareValue.__init__cCs|j�|�|j�|�kSr�rrrr
r	r	r
r:szCompareValue._compareEqualcCs|j�|�|j�|�kSrr#r
r	r	r
r =szCompareValue._compareNotEqualN)rrrrrr r	r	r	r
r1src@s(eZdZdZdd�Zdd�Zdd�ZdS)	�BooleanValuea^
    Provide boolean XPath expression operators.

    @ivar lhs: Left hand side expression of the operator.
    @ivar op: The operator. One of C{'and'}, C{'or'}.
    @ivar rhs: Right hand side expression of the operator.
    @ivar value: Reference to the method that will calculate the value of
                 this expression given an element.
    cCs*||_||_|dkr|j|_n|j|_dS)N�and)rr�_booleanAndr�
_booleanOrr!r	r	r
rKs

zBooleanValue.__init__cCs|j�|�o|j�|�S)z�
        Calculate boolean and of the given expressions given an element.

        @param elem: The element to calculate the value of the expression from.
        r#r
r	r	r
r&SszBooleanValue._booleanAndcCs|j�|�p|j�|�S)z�
        Calculate boolean or of the given expressions given an element.

        @param elem: The element to calculate the value of the expression from.
        r#r
r	r	r
r'[szBooleanValue._booleanOrN)rrr�__doc__rr&r'r	r	r	r
r$As	r$cCsd|}t�|�}|S)z;
    Internal method which selects the function object
    z_%s_Function)�globals)�fnameZ	klassname�cr	r	r
�Functiondsr,c@s$eZdZdd�Zdd�Zdd�ZdS)�
_not_FunctioncCs
d|_dSr��	baseValue�rr	r	r
rnsz_not_Function.__init__cCs
||_dSrr.)rr/r	r	r
�	setParamsqsz_not_Function.setParamscCs|j�|�Sr)r/rr
r	r	r
rtsz_not_Function.valueN)rrrrr1rr	r	r	r
r-msr-c@seZdZdd�Zdd�ZdS)�_text_FunctioncCsdSrr	r0r	r	r
r1ysz_text_Function.setParamscCst|�Sr)rr
r	r	r
r|sz_text_Function.valueN)rrrr1rr	r	r	r
r2xsr2c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�	_LocationcCsg|_d|_d|_dSr��
predicates�elementName�
childLocationr0r	r	r
r�sz_Location.__init__cCs:|jdkr|j|jkrdS|jD]}|�|�s dSq dS�Nrr)r6�namer5r�rr�pr	r	r
�matchesPredicates�s

z_Location.matchesPredicatescCsB|�|�sdS|jdkr:|��D]}|j�|�r dSq ndSdSr8)r<r7�elements�matches�rrr+r	r	r
r>�s


z_Location.matchescCsH|�|�sdS|jdkr6|��D]}|j�||�q n|�t|��dSr)r<r7r=�queryForString�writer)rr�	resultbufr+r	r	r
r@�s

z_Location.queryForStringcCsD|�|�sdS|jdkr6|��D]}|j�||�q n
|�|�dSr)r<r7r=�
queryForNodes�append�rrZ
resultlistr+r	r	r
rC�s

z_Location.queryForNodescCsZ|�|�sdS|jdkr6|��D]}|j�||�q n |jD]}t|t�r<|�|�q<dSr)r<r7r=�queryForStringListr�
isinstancerrDrEr	r	r
rF�s



z_Location.queryForStringListN)	rrrrr<r>r@rCrFr	r	r	r
r3�s



r3c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�_AnyLocationcCsg|_d|_d|_dSrr4r0r	r	r
r�sz_AnyLocation.__init__cCs |jD]}|�|�sdSqdSr8)r5rr:r	r	r
r<�s

z_AnyLocation.matchesPredicatescCs(|jdkr|�|j|�|�|j�dSr)�parent�listParentsrDr9)rrZ
parentlistr	r	r
rJ�s
z_AnyLocation.listParentscCsT|jdks|j|jkrP|�|�rP|jdkrL|��D]}|j�|�r2dSq2ndSdS�NTF�r6r9r<r7r=r>r?r	r	r
�isRootMatch�s�

z_AnyLocation.isRootMatchcCs~|jdks|j|jkrV|�|�rV|jdkrP|��D]}|j�|�r2|Sq2dS|Sn$|��D]}|�|�r^|Sq^dSdSrrLr?r	r	r
�findFirstRootMatch�s�



z_AnyLocation.findFirstRootMatchcCs4|�|�rdS|��D]}|�|�rdSqdSdSrK)rMr=r>r?r	r	r
r>�s

z_AnyLocation.matchescCstd��dS)Nz2queryForString is not implemented for any location)�NotImplementedError)rrrBr	r	r
r@s�z_AnyLocation.queryForStringcCs2|�|�r|�|�|��D]}|�||�qdSr)rMrDr=rCrEr	r	r
rCs

z_AnyLocation.queryForNodescCsH|�|�r*|jD]}t|t�r|�|�q|��D]}|�||�q2dSr)rMrrGrrDr=rFrEr	r	r
rFs


z_AnyLocation.queryForStringListN)rrrrr<rJrMrNr>r@rCrFr	r	r	r
rH�s

rHc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�
XPathQuerycCs4||_ddlm}m}|||��}t|d��|_dS)Nr)�XPathParser�XPathParserScannerZXPATH)�queryStrZtwisted.words.xish.xpathparserrQrR�getattr�baseLocation)rrSrQrR�parserr	r	r
rszXPathQuery.__init__cCs
|j��Sr)rS�__hash__r0r	r	r
rW szXPathQuery.__hash__cCs|j�|�Sr)rUr>r
r	r	r
r>#szXPathQuery.matchescCst�}|j�||�|��Sr)rrUr@�getvalue�rr�resultr	r	r
r@&szXPathQuery.queryForStringcCs*g}|j�||�t|�dkr"dS|SdS�Nr)rUrC�lenrYr	r	r
rC+s
zXPathQuery.queryForNodescCs*g}|j�||�t|�dkr"dS|SdSr[)rUrFr\rYr	r	r
rF3s
zXPathQuery.queryForStringListN)	rrrrrWr>r@rCrFr	r	r	r
rPsrPcCs|tkrt|�t|<t|Sr)�__internedQueriesrP)ZqueryStringr	r	r
�internQuery>sr^cCst|��|�Sr)r^r>�Zxpathstrrr	r	r
r>Dsr>cCst|��|�Sr)r^rFr_r	r	r
rFHsrFcCst|��|�Sr)r^r@r_r	r	r
r@Lsr@cCst|��|�Sr)r^rCr_r	r	r
rCPsrCN)r(Z
__future__rr�iorZtwisted.python.compatrrrrrrr$r,r-r2r3rHrPr]r^r>rFr@rCr	r	r	r
�<module>s(#	>Y%