https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/sqlparse/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/sqlparse/__pycache__/sql.cpython-310.pyc
o

�{;f�P�@s�dZddlZddlmZddlmZddlmZm	Z	Gdd�d�Z
Gdd	�d	�ZGd
d�de�ZGdd
�d
e�Z
Gdd�de
e�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGd d!�d!e�ZGd"d#�d#e�ZGd$d%�d%e�ZGd&d'�d'e�ZGd(d)�d)e
e�ZGd*d+�d+e�ZGd,d-�d-e�ZGd.d/�d/e�ZGd0d1�d1e�ZdS)2zFThis module contains classes representing syntactical elements of SQL.�N��tokens)�
SQLParseError)�imt�
remove_quotesc@s eZdZdZdd�Zdd�ZdS)�NameAliasMixinz'Implements get_real_name and get_alias.cCs$|jtjdfd�\}}|j|dd�S)�7Returns the real name (object name) of this identifier.�.��mT)�	real_name)�
token_next_by�T�Punctuation�_get_first_name)�self�dot_idx�_�r�./usr/lib/python3/dist-packages/sqlparse/sql.py�
get_real_nameszNameAliasMixin.get_real_namecCsl|jtjdfd�\}}|dur|j|ddd�S|jtjd�\}}t|j�dkr2|dur4|jdd	�SdSdS)
�2Returns the alias for this identifier or ``None``.�ASr
N�T)�keywords��t���reverse)r
r�Keywordr�
Whitespace�lenr)r�kw_idx�kwr�wsrrr�	get_aliass�zNameAliasMixin.get_aliasN)�__name__�
__module__�__qualname__�__doc__rr&rrrrrsrc@sfeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
ddd�Zdd�Zdd�Z
dd�ZdS)�Tokenz�Base class for all other classes in this module.

    It represents a single token and has two instance attributes:
    ``value`` is the unchanged value of the token and ``ttype`` is
    the type of the token.
    )�value�ttype�parent�
normalized�
is_keyword�is_group�
is_whitespacecCsXt|�}||_||_d|_d|_|tjv|_|jtjv|_	|jr'|�
�|_dS||_dS)NF)�strr,r-r.r1rr r0r!r2�upperr/)rr-r,rrr�__init__3szToken.__init__cC�|jS�N�r,�rrrr�__str__=sz
Token.__str__cCsF|��}|��}|�d�r|�d�rdnd}djddt|�it���S)N�'�"z"<{cls} {q}{value}{q} at 0x{id:2X}>�idr)�_get_repr_name�_get_repr_value�
startswith�endswith�formatr=�locals)r�clsr,�qrrr�__repr__Ds��zToken.__repr__cCst|j��d�dS)Nr	���)r3r-�splitr9rrrr>LszToken._get_repr_namecCs2t|�}t|�dkr|dd�d}t�dd|�S)N��z...z\s+� )r3r"�re�sub)r�rawrrrr?OszToken._get_repr_valueccs�|VdS)zResolve subgroups.Nrr9rrr�flattenUs�
z
Token.flattenFcs�|j|u}|r|dur
|St|t�r|f}|r8|jrtjnd��fdd�|D�}|D]}|�|j�r5dSq*dS|jrBdd�|D�}|j|vS)a,Checks whether the token matches the given arguments.

        *ttype* is a token type. If this token doesn't match the given token
        type.
        *values* is a list of possible values for this token. The values
        are OR'ed together so if only one of the values matches ``True``
        is returned. Except for keyword tokens the comparison is
        case-sensitive. For convenience it's OK to pass in a single string.
        If *regex* is ``True`` (default is ``False``) the given values are
        treated as regular expressions.
        Nrc3s�|]	}t�|��VqdSr7)rL�compile��.0�v��flagrr�	<genexpr>os�zToken.match.<locals>.<genexpr>TFcss�|]}|��VqdSr7)r4rQrrrrVws�)r-�
isinstancer3r0rL�
IGNORECASE�searchr/)rr-�values�regex�type_matched�patternrrTr�matchYs 

�
zToken.matchcCs&|j}|rt||�rdS|j}|sdS)z�Returns ``True`` if this token is within *group_cls*.

        Use this method for example to check if an identifier is within
        a function: ``t.within(sql.Function)``.
        TF)r.rW)r�	group_clsr.rrr�within{s
�zToken.withincCs
|j|kS)z<Returns ``True`` if this token is a direct child of *other*.�r.)r�otherrrr�is_child_of��
zToken.is_child_ofcCs$|j}|r||krdS|j}|sdS)z7Returns ``True`` if *other* is in this tokens ancestry.TFra)rrbr.rrr�has_ancestor�s�zToken.has_ancestorN�F)r'r(r)r*�	__slots__r5r:rFr>r?rOr^r`rcrerrrrr+(s

"
r+cseZdZdZdZd?�fdd�	Zdd�Zdd	�Zd
d�Zdd
�Z	d@dd�Z
dd�Zdd�Zdd�Z
edd��ZdAdd�ZdBdd�ZdCd!d"�Zd#d$�Zd%d&�ZdBd'd(�ZdDd)d*�ZdEd+d,�Z		dBd-d.�Zd/d0�ZdFd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z		dGd=d>�Z �Z!S)H�	TokenListzwA group of tokens.

    It has an additional instance attribute ``tokens`` which holds a
    list of child-tokens.
    rNcs:|pg�_�fdd��jD�t��dt���d�_dS)Ncsg|]}t|d���qSra)�setattr�rR�tokenr9rr�
<listcomp>��z&TokenList.__init__.<locals>.<listcomp>T)r�superr5r3r1)rr��	__class__r9rr5�s

zTokenList.__init__cCsd�dd�|��D��S)N�css�|]}|jVqdSr7r8rjrrrrV�s�z$TokenList.__str__.<locals>.<genexpr>)�joinrOr9rrrr:�szTokenList.__str__cCs
t|j�Sr7)�iterrr9rrr�__iter__��
zTokenList.__iter__cCs
|j|Sr7r)r�itemrrr�__getitem__�ruzTokenList.__getitem__cCs
t|�jSr7)�typer'r9rrrr>�ruzTokenList._get_repr_namerrqcCs�t|j�}t|j�D]P\}}|��}|��}	||dk}
|
r dnd}|	�d�r.|	�d�r.dnd}tdjdit	���|d�|j
rZ|dusH||krZ|
rLd	nd
}
|�||d|||
�q
dS)zPretty-print the object tree.rz`- z|- r;r<z${_pre}{pre}{idx} {cls} {q}{value}{q})�fileNz   z|  r)r"r�	enumerater>r?r@rA�printrBrCr1�_pprint_tree)r�	max_depth�depth�f�_pre�token_count�idxrkrDr,�last�prerE�
parent_prerrrr|�s&
�����zTokenList._pprint_treecCsDd}|��D]}|t|j�}||kr|kr|S|}qdS)z-Returns the token that is on position offset.rN)rOr"r,)r�offsetr�rk�endrrr�get_token_at_offset�s��zTokenList.get_token_at_offsetc
csT�z|jD]}|jr|��EdHq|VqWdSty)}ztd�|�d}~ww)znGenerator yielding ungrouped tokens.

        This method is recursively called for all child tokens.
        Nz Maximum recursion depth exceeded)rr1rO�RecursionErrorr)rrk�errrrrrO�s�
�
��zTokenList.flattenccs�|jD]}|jr|VqdSr7)rr1�rrkrrr�get_sublists�s�
��zTokenList.get_sublistscCr6r7rr9rrr�_groupable_tokens�szTokenList._groupable_tokensFcCs�|durdSt|ttf�s|f}|r;|dusJ�t|ddd�D]}|j|}|D]}||�r7||fSq)q dSt|j||�|d�D]\}}|D]}||�rZ||fSqLqFdS)znext token that match functionsNrrG)�start�NN)rW�list�tuple�rangerrz)r�funcsr�r�rr�rk�funcrrr�_token_matching�s*
�����zTokenList._token_matchingTcs��fdd�}|�|�dS)z�Returns the first child token.

        If *skip_ws* is ``True`` (the default), whitespace
        tokens are ignored.

        if *skip_cm* is ``True`` (default: ``False``), comments are
        ignored too.
        c� �r|jp�ot|tjtd�S�N)r�i�r2rr�Comment��tk��skip_cm�skip_wsrr�matcher�
�z&TokenList.token_first.<locals>.matcherr�r�)rr�r�r�rr�r�token_first�s
zTokenList.token_firstrGcs"|d7}|����fdd�||�S)Nrcst|����Sr7)rr��r�rrrr�<lambda>sz)TokenList.token_next_by.<locals>.<lambda>r�)rr�rrr�r�rr�rr
szTokenList.token_next_bycCs2t|ttf�s
|fn|}dd�|D�}|�||�S)Ncsg|]��fdd��qS)cs
�|�Sr7rr��r�rrr�s
z9TokenList.token_not_matching.<locals>.<listcomp>.<lambda>r)rRrr�rrlrmz0TokenList.token_not_matching.<locals>.<listcomp>)rWr�r�r��rr�r�rrr�token_not_matchingszTokenList.token_not_matchingcCs|�||�dS)Nrr�r�rrr�token_matchingszTokenList.token_matchingcCs|j|||dd�S)z�Returns the previous token relative to *idx*.

        If *skip_ws* is ``True`` (the default) whitespace tokens are ignored.
        If *skip_cm* is ``True`` comments are ignored.
        ``None`` is returned if there's no previous token.
        T)�_reverse)�
token_next)rr�r�r�rrr�
token_prevszTokenList.token_prevcs2|durdS|d7}��fdd�}|j|||d�S)z�Returns the next token relative to *idx*.

        If *skip_ws* is ``True`` (the default) whitespace tokens are ignored.
        If *skip_cm* is ``True`` comments are ignored.
        ``None`` is returned if there's no next token.
        Nr�rcr�r�r�r�r�rrr�-r�z%TokenList.token_next.<locals>.matcherrr�)rr�r�r�r�r�rr�rr�"s
zTokenList.token_nextcCs0t|t�r|n|�|�}||j|d��|�S)zReturn list index of token.N)rW�int�token_indexr�index)rrkr�rrrr�2szTokenList.token_indexcCs�|}|j|}||}|r1t||�r1|j|d|�}|}	|	j�|�|j|d|�=t|�|	_n|j||�}||�}	|	g|j||�<||	_|D]}
|	|
_qI|	S)z+Replace tokens by an instance of *grp_cls*.r)rrW�extendr3r,r.)r�grp_clsr�r��include_endr��	start_idx�end_idx�	subtokens�grprkrrr�group_tokens7s 
zTokenList.group_tokenscCs,t|t�s
|�|�}||_|j�||�dS)zInserts *token* before *where*.N)rWr�r�r.r�insert)r�whererkrrr�
insert_beforeUs

zTokenList.insert_beforecCsVt|t�s
|�|�}|j||d�\}}||_|dur"|j�|�dS|j�||�dS)zInserts *token* after *where*.�r�N)rWr�r�r�r.r�appendr�)rr�rkr��nidx�next_rrr�insert_after\s

zTokenList.insert_aftercCs|��duS)z(Returns ``True`` if an alias is present.N)r&r9rrr�	has_aliasgszTokenList.has_aliascC�dS)rNrr9rrrr&k�zTokenList.get_aliascCs|��p|��S)aReturns the name of this identifier.

        This is either it's alias or it's real name. The returned valued can
        be considered as the name under which the object corresponding to
        this identifier is known within the current statement.
        )r&rr9rrr�get_nameoszTokenList.get_namecCr�)rNrr9rrrrxr�zTokenList.get_real_namecCs:|jtjdfd�\}}|�|�\}}|durt|j�SdS)ztReturn name of the parent object if any.

        A parent object is identified by the first occurring dot.
        r	r
N)r
rrr�rr,)rrr�prev_rrr�get_parent_name|szTokenList.get_parent_namecCs�|r	|j|d�n|j}|rt|�n|}tjtjtjjg}|r%|�tj�|D]#}|j	|vr5t
|j�St|t
tf�rJ|rD|��S|��Sq'dS)z/Returns the name of the first token with a nameN)r�reversedr�Name�Wildcard�String�Symbolr�r r-rr,rW�
Identifier�Functionrr�)rr�rrrr�typesrkrrrr�s
��zTokenList._get_first_namer7)NrNrq)rNF)TF)NNNrGN)TFF)r)T)NFFF)"r'r(r)r*rgr5r:rtrwr>r|r�rOr��propertyr�r�r�r
r�r�r�r�r�r�r�r�r�r&r�rr�r�
__classcell__rrrorrh�sF
	








�
		�rhc@�eZdZdZdd�ZdS)�	StatementzRepresents a SQL statement.cCs�|jdd�}|durdS|jtjjtjjfvr|jS|jtjjkrM|�|�}|j	|dd�\}}t
|ttf�rM|j	|dd�\}}|durM|jtjjkrM|jSdS)aMReturns the type of a statement.

        The returned value is a string holding an upper-cased reprint of
        the first DML or DDL keyword. If the first token in this group
        isn't a DML or DDL keyword "UNKNOWN" is returned.

        Whitespaces and comments at the beginning of the statement
        are ignored.
        T)r�N�UNKNOWNr�)
r�r-rr �DML�DDLr/�CTEr�r�rWr��IdentifierList)r�first_token�fidx�tidxrkr�dml_keywordrrr�get_type�s

zStatement.get_typeN)r'r(r)r*r�rrrrr���r�c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)r�zNRepresents an identifier.

    Identifiers may have aliases or typecasts.
    cCs|jtjd�\}}|duS)z7Return ``True`` if this identifier contains a wildcard.rN)r
rr�)rrrkrrr�is_wildcard�szIdentifier.is_wildcardcCs6|jtjdfd�\}}|j|dd�\}}|r|jSdS)z<Returns the typecast or ``None`` of this object as a string.z::r
Fr�N)r
rrr�r,)r�midx�markerr�r�rrr�get_typecast�szIdentifier.get_typecastcCs"|jtjjd�\}}|r|jSdS)z5Returns the ordering or ``None`` as uppercase string.rN)r
rr �Orderr/)rr�orderingrrr�get_ordering�szIdentifier.get_orderingccs,�|jD]}t|t�r|jdd�VqdS)z(Returns an iterator of index token listsrrGN)rrW�SquareBracketsr�rrr�get_array_indices�s�

��zIdentifier.get_array_indicesN)r'r(r)r*r�r�r�r�rrrrr��sr�c@r�)r�z.A list of :class:`~sqlparse.sql.Identifier`'s.ccs,�|jD]}|js|�tjd�s|VqdS)zkReturns the identifiers.

        Whitespaces and punctuations are not included in this generator.
        �,N)rr2r^rrr�rrr�get_identifiers�s�
��zIdentifierList.get_identifiersN)r'r(r)r*r�rrrrr��r�r�c@s<eZdZdZejjdfejdfgZej	j
dfZejdfZdS)�TypedLiteralzEA typed literal, such as "date '2001-09-28'" or "interval '2 hours'".N�	TIMESTAMP)�DAY�HOUR�MINUTE�MONTH�SECOND�YEAR)
r'r(r)r*rr��Builtinr �M_OPENr��Single�M_CLOSE�M_EXTENDrrrrr��s
r�c@�0eZdZdZejdfZejdfZedd��Z	dS)�ParenthesiszTokens between parenthesis.�(�)cC�|jdd�S�NrrGrr9rrrr���zParenthesis._groupable_tokensN�
r'r(r)r*rrr�r�r�r�rrrrr���

r�c@r�)r�zTokens between square brackets�[�]cCr�r�rr9rrrr�r�z SquareBrackets._groupable_tokensNr�rrrrr��r�r�c@�eZdZdZdS)�
Assignmentz An assignment like 'var := val;'N�r'r(r)r*rrrrr�rc@�$eZdZdZejdfZejdfZdS)�Ifz7An 'if' clause with possible 'else if' or 'else' parts.�IFzEND IFN�r'r(r)r*rr r�r�rrrrr	�
rc@r)�Forz
A 'FOR' loop.)�FOR�FOREACHzEND LOOPNrrrrrr	rr	c@s(eZdZdZedd��Zedd��ZdS)�
Comparisonz/A comparison used for example in WHERE clauses.cC�
|jdS�Nrrr9rrr�leftrdzComparison.leftcCr
)NrGrr9rrr�rightrdzComparison.rightN)r'r(r)r*r�rrrrrrrs
rc@r�)r�z
A comment.cCs|jo|jdjtjjkSr)rr-rr��	Multiliner9rrr�is_multiline$szComment.is_multilineN)r'r(r)r*rrrrrr�!r�r�c@r)�WherezA WHERE clause.�WHERE)	�ORDER BYzGROUP BY�LIMIT�UNIONz	UNION ALL�EXCEPT�HAVING�	RETURNING�INTONrrrrrr(rrc@r)�HavingzA HAVING clause.r)rrNrrrrrr0rrc@s.eZdZdZejdfZejdfZddd�ZdS)	�CasezAA CASE statement with one or more WHEN and possibly an ELSE part.�CASE�ENDFcCs�d}d}g}|}|jD]n}|�tjd�rq|r|jtjvrq|�tjd�r/|�ggf�|}n$|�tjd�r9|}n|�tjd�rJ|�dgf�|}n	|�tjd�rSd}|r^|s^|�ggf�||krl|d	d
�|�q||kry|d	d�|�q|S)zeReturns a list of 2-tuples (condition, value).

        If an ELSE exists condition is None.
        rrr�WHEN�THEN�ELSENrrGr)rr^rr r-r!r�)rr��	CONDITION�VALUE�ret�moderkrrr�	get_cases;s6
�zCase.get_casesNrf)	r'r(r)r*rr r�r�r'rrrrr6s


rc@r�)r�zA function or procedure call.cCsN|jd}|jD]}t|t�r|��St|ttftjd�r$|gSqgS)zReturn a list of parameters.rG)r�r)	rrWr�r�rr�r�r�Literal)r�parenthesisrkrrr�get_parametersns



�zFunction.get_parametersN)r'r(r)r*r*rrrrr�kr�r�c@r)�BeginzA BEGIN/END block.�BEGINrNrrrrrr+yrr+c@r)�	OperationzGrouping of operationsNrrrrrr-rr-c@r)�ValueszGrouping of valuesNrrrrrr.�rr.c@r)�CommandzGrouping of CLI commands.Nrrrrrr/�rr/) r*rL�sqlparserr�sqlparse.exceptionsr�sqlparse.utilsrrrr+rhr�r�r�r�r�r�rrr	rr�rrrr�r+r-r.r/rrrr�<module>s:n'


5

https://t.me/RX1948 - 2025