Files
old-saburly-wagtail-web/env/lib/python3.10/site-packages/sqlparse/__pycache__/sql.cpython-310.pyc

186 lines
22 KiB
Plaintext
Raw Normal View History

2024-08-27 20:33:44 +02:00
o
<00><><EFBFBD>f0R<00>@s<>dZddlZddlmZddlmZddlmZm Z Gdd<07>d<07>Z
Gdd <09>d <09>Z Gd
d <0B>d e <0B>Z Gd d <0A>d e <0C>Z Gdd<0F>de
e <0C>ZGdd<11>de <0C>ZGdd<13>de <0C>ZGdd<15>de <0C>ZGdd<17>de <0C>ZGdd<19>de <0C>ZGdd<1B>de <0C>ZGdd<1D>de <0C>ZGdd<1F>de <0C>ZGd d!<21>d!e <0C>ZGd"d#<23>d#e <0C>ZGd$d%<25>d%e <0C>ZGd&d'<27>d'e <0C>ZGd(d)<29>d)e <0C>ZGd*d+<2B>d+e
e <0C>ZGd,d-<2D>d-e <0C>ZGd.d/<2F>d/e <0C>ZGd0d1<64>d1e <0C>ZGd2d3<64>d3e <0C>Z dS)4zFThis module contains classes representing syntactical elements of SQL.<2E>N<><01>tokens)<01> SQLParseError)<02>imt<6D> remove_quotesc@<00> eZdZdZdd<03>Zdd<05>ZdS)<07>NameAliasMixinz'Implements get_real_name and get_alias.cCs$|jtjdfd<02>\}}|j|dd<04>S)<05>7Returns the real name (object name) of this identifier.<2E>.<2E><01>mT)<01> real_name)<04> token_next_by<62>T<> Punctuation<6F>_get_first_name)<03>self<6C>dot_idx<64>_<>r<00>N/home/amir/Desktop/saburlyweb/env/lib/python3.10/site-packages/sqlparse/sql.py<70> get_real_nameszNameAliasMixin.get_real_namecCsl|jtjdfd<02>\}}|dur|j|ddd<06>S|jtjd<07>\}}t|j<06>dkr2|dur4|jdd <09>SdSdS)
<EFBFBD>2Returns the alias for this identifier or ``None``.<2E>ASr N<>T)<01>keywords<64><01>t<><00><01>reverse)rr<00>Keywordr<00>
Whitespace<EFBFBD>lenr)r<00>kw_idx<64>kwr<00>wsrrr<00> get_aliass <08>zNameAliasMixin.get_aliasN)<06>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__rr'rrrrrs rc@sfeZdZdZdZdd<04>Zdd<06>Zdd<08>Zd d
<EFBFBD>Zd d <0C>Z d d<0E>Z
ddd<11>Z dd<13>Z dd<15>Z dd<17>ZdS)<1A>Tokenz<6E>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.
)<08>value<75>ttype<70>parent<6E>
normalized<EFBFBD>
is_keyword<EFBFBD>is_group<75> is_whitespace<63>
is_newlinecCsft|<02>}||_||_d|_d|_|tjv|_|jtjv|_ |jtj
v|_ |jr.|<02> <0C>|_ dS||_ dS)NF)<0E>strr-r.r/r2rr!r1r"r3<00>Newliner4<00>upperr0)rr.r-rrr<00>__init__3s zToken.__init__cC<00>|jS<00>N<>r-<00>rrrr<00>__str__>sz Token.__str__cCsF|<00><00>}|<00><01>}|<02>d<01>r|<02>d<01>rdnd}djddt|<00>it<06><00><01>S)N<>'<27>"z"<{cls} {q}{value}{q} at 0x{id:2X}><3E>idr)<07>_get_repr_name<6D>_get_repr_value<75>
startswith<EFBFBD>endswith<74>formatr@<00>locals)r<00>clsr-<00>qrrr<00>__repr__Es<02><06>zToken.__repr__cCst|j<01><01>d<01>dS)Nr
<00><><EFBFBD><EFBFBD><EFBFBD>)r5r.<00>splitr<rrrrAMszToken._get_repr_namecCs2t|<00>}t|<01>dkr|dd<02>d}t<02>dd|<01>S)N<><00>z...z\s+<2B> )r5r#<00>re<72>sub)r<00>rawrrrrBPs zToken._get_repr_valueccs <00>|VdS)zResolve subgroups.Nrr<rrr<00>flattenVs<02>
z Token.flattenFcs<>|j|u}|r |dur |St|t<02>r|f}|r8|jrtjnd<02><00>fdd<04>|D<00>}|D] }|<05>|j<07>r5dSq*dS|jrBdd<04>|D<00>}|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<00>|] }t<00>|<01><00>VqdSr:)rO<00>compile<6C><02>.0<EFBFBD>v<><01>flagrr<00> <genexpr>ps<02>zToken.match.<locals>.<genexpr>TFcss<00>|]}|<01><00>VqdSr:)r7rTrrrrYxs<02>)r.<00>
isinstancer5r1rO<00>
IGNORECASE<EFBFBD>searchr0)rr.<00>values<65>regex<65> type_matched<65>patternrrWr<00>matchZs

 <02>
z Token.matchcCs&|j}|rt||<01>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/rZ)r<00> group_clsr/rrr<00>within|s
<04>z Token.withincCs
|j|kS)z<Returns ``True`` if this token is a direct child of *other*.<2E>r/)r<00>otherrrr<00> is_child_of<6F><00>
zToken.is_child_ofcCs$|j}|r||kr dS|j}|sdS)z7Returns ``True`` if *other* is in this tokens ancestry.TFrd)rrer/rrr<00> has_ancestor<6F>s<04>zToken.has_ancestorN<72>F)r(r)r*r+<00> __slots__r8r=rIrArBrRrarcrfrhrrrrr,(s 
" r,cseZdZdZdZd?<3F>fdd<05> Zdd<07>Zdd <09>Zd
d <0B>Zd d <0A>Z d@dd<11>Z
dd<13>Z dd<15>Z dd<17>Z edd<19><00>ZdAdd<1C>ZdBdd<1F>ZdCd!d"<22>Zd#d$<24>Zd%d&<26>ZdBd'd(<28>ZdDd)d*<2A>ZdEd+d,<2C>Z  dBd-d.<2E>Zd/d0<64>ZdFd1d2<64>Zd3d4<64>Zd5d6<64>Zd7d8<64>Zd9d:<3A>Zd;d<<3C>Z  dGd=d><3E>Z <20>Z!S)H<> TokenListzwA group of tokens.
It has an additional instance attribute ``tokens`` which holds a
list of child-tokens.
rNcs:|pg<00>_<00>fdd<02><08>jD<00>t<01><00>dt<03><00><01>d<03>_dS)Ncsg|]}t|d<00><00><03>qSrd)<01>setattr<74>rU<00>tokenr<rr<00>
<listcomp><3E><00>z&TokenList.__init__.<locals>.<listcomp>T)r<00>superr8r5r2)rr<00><01> __class__r<rr8<00>s

zTokenList.__init__cCsd<01>dd<03>|<00><01>D<00><01>S)N<>css<00>|]}|jVqdSr:r;rmrrrrY<00>s<02>z$TokenList.__str__.<locals>.<genexpr>)<02>joinrRr<rrrr=<00>szTokenList.__str__cCs
t|j<01>Sr:)<02>iterrr<rrr<00>__iter__<5F><00>
zTokenList.__iter__cCs
|j|Sr:r)r<00>itemrrr<00> __getitem__<5F>rxzTokenList.__getitem__cCs
t|<00>jSr:)<02>typer(r<rrrrA<00>rxzTokenList._get_repr_namerrtcCs<>t|j<01>}t|j<01>D]P\}}|<07><03>}|<07><04>} ||dk}
|
r dnd} | <09>d<04>r.| <09>d<04>r.dnd} tdjd it <09><00><01>|d<07>|j
rZ|dusH||krZ|
rLd nd
} |<07> ||d||| <00>q
dS) zPretty-print the object tree.rz`- z|- r>r?z${_pre}{pre}{idx} {cls} {q}{value}{q})<01>fileNz z| r) r#r<00> enumeraterArBrCrD<00>printrErFr2<00> _pprint_tree)r<00> max_depth<74>depth<74>f<>_pre<72> token_count<6E>idxrnrGr-<00>last<73>prerH<00>
parent_prerrrr<00>s&
  <04><04><06> <02><04>zTokenList._pprint_treecCsDd}|<00><00>D]}|t|j<02>}||kr|kr|S|}qdS)z-Returns the token that is on position offset.rN)rRr#r-)r<00>offsetr<74>rn<00>endrrr<00>get_token_at_offset<65>s <02><04>zTokenList.get_token_at_offsetc
csT<00>z|jD]}|jr|<01><02>EdHq|VqWdSty)}ztd<02>|<02>d}~ww)znGenerator yielding ungrouped tokens.
This method is recursively called for all child tokens.
Nz Maximum recursion depth exceeded)rr2rR<00>RecursionErrorr)rrn<00>errrrrrR<00>s<02>
<06>
<08><02>zTokenList.flattenccs<00>|jD]}|jr |VqdSr:)rr2<00>rrnrrr<00> get_sublists<74>s <02>
<02><04>zTokenList.get_sublistscCr9r:rr<rrr<00>_groupable_tokens<6E>szTokenList._groupable_tokensFc Cs<>|durdSt|ttf<02>s|f}|r!|dusJ<00>t|ddd<03>}n|dur*t|j<05>}t||<03>}|D]}|j|}|D]}||<07>rH||fSq:q1dS)znext token that match functionsNrrJ<00>NN)rZ<00>list<73>tuple<6C>ranger#r) r<00>funcs<63>startr<74>r <00>indexesr<73>rn<00>funcrrr<00>_token_matching<6E>s$ 


<02><02>zTokenList._token_matchingTcs<00><00>fdd<02>}|<00>|<03>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<00> <00>r|jp<0E>ot|tjtd<01> S<00>N)r<00>i<>r3rr<00>Comment<6E><01>tk<74><02>skip_cm<63>skip_wsrr<00>matcher<00>
<04>z&TokenList.token_first.<locals>.matcherr<00>r<>)rr<>r<>r<>rr<>r<00> token_first<73>s
zTokenList.token_firstrJcs"|d7}|<00><00><00><01>fdd<03>||<05>S)Nrcst|<00><00><01><02>Sr:)rr<><00>r<>r rrr<00><lambda>sz)TokenList.token_next_by.<locals>.<lambda>r<>)rr<>r rr<>r<>rr<>rr szTokenList.token_next_bycCs2t|ttf<02>s
|fn|}dd<02>|D<00>}|<00>||<02>S)Ncsg|]<08><00>fdd<01><08>qS)cs
<00>|<00> Sr:rr<><00>r<>rrr<>s
z9TokenList.token_not_matching.<locals>.<listcomp>.<lambda>r)rUrr<>rrorpz0TokenList.token_not_matching.<locals>.<listcomp>)rZr<>r<>r<><00>rr<>r<>rrr<00>token_not_matchings zTokenList.token_not_matchingcCs|<00>||<02>dS)Nrr<>r<>rrr<00>token_matchingszTokenList.token_matchingcCs|j|||dd<02>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)<01>_reverse)<01>
token_next)rr<>r<>r<>rrr<00>
token_prevszTokenList.token_prevcs2|durdS|d7}<01><00>fdd<05>}|j|||d<06>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<4E>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<01>r|n|<00>|<02>}||j|d<01><00>|<01>S)zReturn list index of token.N)rZ<00>int<6E> token_indexr<00>index)rrnr<>rrrr<>3szTokenList.token_indexc Cs<>|}|j|}||}|r1t||<01>r1|j|d|<07>}|} | j<00>|<08>|j|d|<07>=t|<02>| _n|j||<07>}||<08>} | g|j||<07><|| _|D]}
| |
_qI| S)z+Replace tokens by an instance of *grp_cls*.r)rrZ<00>extendr5r-r/) r<00>grp_clsr<73>r<><00> include_endr<64><00> start_idx<64>end_idx<64> subtokens<6E>grprnrrr<00> group_tokens8s 
  zTokenList.group_tokenscCs,t|t<01>s
|<00>|<01>}||_|j<04>||<02>dS)zInserts *token* before *where*.N)rZr<>r<>r/r<00>insert)r<00>wherernrrr<00> insert_beforeVs

zTokenList.insert_beforecCsVt|t<01>s
|<00>|<01>}|j||d<01>\}}||_|dur"|j<05>|<02>dS|j<05>||<02>dS)zInserts *token* after *where*.<2E>r<>N)rZr<>r<>r<>r/r<00>appendr<64>)rr<>rnr<><00>nidx<64>next_rrr<00> insert_after]s

zTokenList.insert_aftercCs |<00><00>duS)z(Returns ``True`` if an alias is present.N)r'r<rrr<00> has_aliashs zTokenList.has_aliascC<00>dS)rNrr<rrrr'l<00>zTokenList.get_aliascCs|<00><00>p|<00><01>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'rr<rrr<00>get_namepszTokenList.get_namecCr<>)r Nrr<rrrryr<>zTokenList.get_real_namecCs:|jtjdfd<02>\}}|<00>|<01>\}}|durt|j<05>SdS)ztReturn name of the parent object if any.
A parent object is identified by the first occurring dot.
r
r N)rrrr<>rr-)rrr<00>prev_rrr<00>get_parent_name}szTokenList.get_parent_namecCs<>|r |j|d<01>n|j}|rt|<05>n|}tjtjtjjg}|r%|<06>tj<08>|D]#}|j |vr5t
|j <0B>St |t tf<02>rJ|rD|<07><0F>S|<07><10>Sq'dS)z/Returns the name of the first token with a nameN)r<00>reversedr<00>Name<6D>Wildcard<72>String<6E>Symbolr<6C>r!r.rr-rZ<00>
Identifier<EFBFBD>Functionrr<>)rr<>r rr r<00>typesrnrrrr<00>s 
<02><04>zTokenList._get_first_namer:)NrNrt)rNF)TF)NNNrJN)TFF)r)T)NFFF)"r(r)r*r+rjr8r=rwrzrArr<>rRr<><00>propertyr<79>r<>r<>rr<>r<>r<>r<>r<>r<>r<>r<>r<>r'r<>rr<>r<00> __classcell__rrrrrrk<00>sF
 






<EFBFBD>
   <12>rkc@<00>eZdZdZdd<03>ZdS)<05> StatementzRepresents a SQL statement.cCs<>|jdd<02>}|dur dS|jtjjtjjfvr|jS|jtjjkrU|<00>|<01>}|durU|j |dd<05>\}}t
|t t f<02>rQ|j |dd<05>\}}|durQ|jtjjkrQ|jS|dus*dS)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<4E>) r<>r.rr!<00>DML<4D>DDLr0<00>CTEr<45>r<>rZr<><00>IdentifierList)rrn<00>tidxrrr<00>get_type<70>s

<08>
zStatement.get_typeN)r(r)r*r+r<>rrrrr<><00><00> r<>c@s0eZdZdZdd<03>Zdd<05>Zdd<07>Zdd <09>Zd
S) r<>zNRepresents an identifier.
Identifiers may have aliases or typecasts.
cCs|jtjd<01>\}}|duS)z7Return ``True`` if this identifier contains a wildcard.rN)rrr<>)rrrnrrr<00> is_wildcard<72>szIdentifier.is_wildcardcCs6|jtjdfd<02>\}}|j|dd<04>\}}|r|jSdS)z<Returns the typecast or ``None`` of this object as a string.z::r Fr<46>N)rrrr<>r-)r<00>midx<64>markerr<72>r<>rrr<00> get_typecast<73>szIdentifier.get_typecastcCs"|jtjjd<01>\}}|r|jSdS)z5Returns the ordering or ``None`` as uppercase string.rN)rrr!<00>Orderr0)rr<00>orderingrrr<00> get_ordering<6E>szIdentifier.get_orderingccs,<00>|jD]}t|t<02>r|jdd<02>VqdS)z(Returns an iterator of index token listsrrJN)rrZ<00>SquareBracketsr<73>rrr<00>get_array_indices<65>s <02>

<02><04>zIdentifier.get_array_indicesN)r(r)r*r+r<>r<>r<>r<>rrrrr<><00>s  r<>c@r<>)r<>z.A list of :class:`~sqlparse.sql.Identifier`'s.ccs,<00>|jD]}|js|<01>tjd<01>s|VqdS)zkReturns the identifiers.
Whitespaces and punctuations are not included in this generator.
<20>,N)rr3rarrr<>rrr<00>get_identifiers<72>s <02>
<02><04>zIdentifierList.get_identifiersN)r(r)r*r+r<>rrrrr<><00>r<>r<>c@s<eZdZdZejjdfejdfgZej j
dfZ ejdfZ dS)<05> TypedLiteralzEA typed literal, such as "date '2001-09-28'" or "interval '2 hours'".N<> TIMESTAMP)<06>DAY<41>HOUR<55>MINUTE<54>MONTH<54>SECOND<4E>YEAR) r(r)r*r+rr<><00>Builtinr!<00>M_OPENr<4E><00>Single<6C>M_CLOSE<53>M_EXTENDrrrrr<><00>s
 r<>c@<00>0eZdZdZejdfZejdfZedd<05><00>Z dS)<07> ParenthesiszTokens between parenthesis.<2E>(<28>)cC<00>|jdd<02>S<00>NrrJrr<rrrr<><00><00>zParenthesis._groupable_tokensN<73>
r(r)r*r+rrr<>r<>r<>r<>rrrrr<><00><00> 

r<>c@r<>)r<>zTokens between square brackets<74>[<5B>]cCr<>r<>rr<rrrr<>r<>z SquareBrackets._groupable_tokensNr<4E>rrrrr<><00>r<>r<>c@<00>eZdZdZdS)<03>
Assignmentz An assignment like 'var := val;'N<>r(r)r*r+rrrrr<00>rc@<00>$eZdZdZejdfZejdfZdS)<05>Ifz7An 'if' clause with possible 'else if' or 'else' parts.<2E>IFzEND IFN<46>r(r)r*r+rr!r<>r<>rrrrr <00>
rc@r)<05>Forz A 'FOR' loop.)<02>FOR<4F>FOREACHzEND LOOPNrrrrrr
r r
c@s(eZdZdZedd<03><00>Zedd<05><00>ZdS)<07>
Comparisonz/A comparison used for example in WHERE clauses.cC<00>
|jdS<00>Nrrr<rrr<00>leftrgzComparison.leftcCr)NrJrr<rrr<00>rightrgzComparison.rightN)r(r)r*r+r<>rrrrrrr s 
r c@r<>)r<>z
A comment.cCs|jo |jdjtjjkSr)rr.rr<><00> Multiliner<rrr<00> is_multiline&szComment.is_multilineN)r(r)r*r+rrrrrr<>#r<>r<>c@r)<05>WherezA WHERE clause.<2E>WHERE) <09>ORDER BYzGROUP BY<42>LIMIT<49>UNIONz UNION ALL<4C>EXCEPT<50>HAVING<4E> RETURNING<4E>INTONrrrrrr*r rc@seZdZdZejdfZdS)<04>OverzAn OVER clause.<2E>OVERN)r(r)r*r+rr!r<>rrrrr2src@r)<05>HavingzA HAVING clause.r)rrNrrrrrr7r rc@s.eZdZdZejdfZejdfZddd<06>ZdS) <09>CasezAA CASE statement with one or more WHEN and possibly an ELSE part.<2E>CASE<53>ENDFcCs<>d}d}g}|}|jD]n}|<06>tjd<03>rq |r|jtjvrq |<06>tjd<04>r/|<04>ggf<02>|}n$|<06>tjd<05>r9|}n|<06>tjd<06>rJ|<04>dgf<02>|}n |<06>tjd<08>rSd}|r^|s^|<04>ggf<02>||krl|d d
<00>|<06>q ||kry|d d<00>|<06>q |S) zeReturns a list of 2-tuples (condition, value).
If an ELSE exists condition is None.
rrr!<00>WHEN<45>THEN<45>ELSENr"rJr)rrarr!r.r"r<>)rr<><00> CONDITION<4F>VALUE<55>ret<65>modernrrr<00> get_casesBs6
<02>zCase.get_casesNri) r(r)r*r+rr!r<>r<>r*rrrrr =s


r c@r)r<>zA function or procedure call.cCsZ|jtd<01>d}g}|jD]}t|t<04>r|<03><05>St|ttt ft
j d<03>r*|<02> |<03>q |S)zReturn a list of parameters.<2E>r<>r)r<>r) rr<>rrZr<>r<>rr<>r<>r<>r<00>Literalr<6C>)r<00> parenthesis<69>resultrnrrr<00>get_parametersus

  <06>
<02>zFunction.get_parameterscCs"|jtd<01>}|s
dS|djdS)zReturn the window if it exists.r+NrrJ)rrr)r<00> over_clauserrr<00>
get_window<EFBFBD>s zFunction.get_windowN)r(r)r*r+r/r1rrrrr<>rs r<>c@r)<05>BeginzA BEGIN/END block.<2E>BEGINr"Nrrrrrr2<00>r r2c@r)<03> OperationzGrouping of operationsNrrrrrr4<00>rr4c@r)<03>ValueszGrouping of valuesNrrrrrr5<00>rr5c@r)<03>CommandzGrouping of CLI commands.Nrrrrrr6<00>rr6)!r+rO<00>sqlparserr<00>sqlparse.exceptionsr<00>sqlparse.utilsrrrr,rkr<>r<>r<>r<>r<>r<>rrr
r r<>rrrr r<>r2r4r5r6rrrr<00><module>s<  o( 

 5