403Webshell
Server IP : 192.158.238.246  /  Your IP : 3.148.217.26
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python37/lib64/python3.7/site-packages/sqlalchemy/sql/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python37/lib64/python3.7/site-packages/sqlalchemy/sql/__pycache__/util.cpython-37.pyc
B

��4][r�@sfdZddlmZddlmZddlmZddlmZddlm	Z	ddlm
Z
dd	lmZdd
lm
Z
ddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$ddlm%Z%dd lm&Z&e&j'�(e!j)d!�Z*d"d#�Z+d$d%�Z,d&d'�Z-d(d)�Z.dUd+d,�Z/d-d.�Z0d/d0�Z1d1d2�Z2d3d4�Z3d5d6�Z4d7d8�Z5dVd:d;�Z6d<d=�Z7d>d?�Z8d@dA�Z9GdBdC�dCe:�Z;GdDdE�dEe;�Z<GdFdG�dGe;�Z=dHdI�Z>dWdKdL�Z?dMdN�Z@dXdOdP�ZAGdQdR�dRejB�ZCGdSdT�dTeC�ZDdJS)Yz;High level utilities which build upon other modules here.

�)�deque)�chain�)�	operators)�visitors)�_deep_annotate)�_deep_deannotate)�_shallow_annotate)�
_from_objects)�	ColumnSet)�sort_tables)�_expand_cloned)�
_find_columns)�_label_reference)�_textual_label_reference)�
BindParameter)�ColumnClause)�
ColumnElement)�Null)�UnaryExpression)�Column)�Alias)�
FromClause)�FromGrouping)�Join)�ScalarSelect)�
SelectBase)�TableClause�)�exc)�utilz.sql.util.join_conditioncCsLtt|��}g}x6t|�D]*\}}x |D]}|�|�r(|�|�q(WqW|S)a�Given a list of FROM clauses and a selectable,
    return the first index and element from the list of
    clauses which can be joined against the selectable.  returns
    None, None if no match is found.

    e.g.::

        clause1 = table1.join(table2)
        clause2 = table4.join(table5)

        join_to = table2.join(table3)

        find_join_source([clause1, clause2], join_to) == clause1

    )�listr
�	enumerate�is_derived_from�append)�clauses�join_to�selectables�idx�i�f�s�r,�F/opt/alt/python37/lib64/python3.7/site-packages/sqlalchemy/sql/util.py�find_join_source1s

r.c	Cs�tt|��}g}x8t|�D],\}}x"|D]}|�|�r(|�|�Pq(WqWt|�dkr�g}xD|D]<}||}x.|D]&}tt|���t|��rr|�|�PqrWq`W|r�|S|S)z�Given a list of FROM clauses and a selectable,
    return the indexes from the list of
    clauses which is derived from the selectable.

    r)	r!r
r"r#r$�len�set�surface_selectables�intersection)	r%Z	join_fromr'Zliberal_idxr)r*r+Zconservative_idxr(r,r,r-�#find_left_clause_that_matches_givenKs&








r3c
s
g}tt|��}t��dkr2|dk	r2d}t|�}nd}d}xtt��D]h\}}x^|�|g�D]N}	|r�t|j��|	j��|�r�|�	|�PqZt
�||	�s�|dk	rZ|�	|�PqZWqDWt|�dkr�ttdd��D������fdd�|D�}|�s|dk	�rt
t���S|SdS)aGiven a list of FROM clauses, a selectable,
    and optional ON clause, return a list of integer indexes from the
    clauses list indicating the clauses that can be joined from.

    The presence of an "onclause" indicates that at least one clause can
    definitely be joined from; if the list of clauses is of length one
    and the onclause is given, returns that index.   If the list of clauses
    is more than length one, and the onclause is given, attempts to locate
    which clauses contain the same columns.

    rNTFcSsg|]}t|j��qSr,)r
Z_hide_froms)�.0r*r,r,r-�
<listcomp>�sz1find_left_clause_to_join_from.<locals>.<listcomp>csg|]}�|�kr|�qSr,r,)r4r))r%�toremover,r-r5�s)r0r
r/rr"�
difference�c�union�
issupersetr$rZ	_can_joinr�range)
r%r&�onclauser(r'Zresolve_ambiguityZcols_in_onclauser)r*r+r,)r%r6r-�find_left_clause_to_join_fromus.



r=cs$g����fdd��t�|��dS)a�Produce a traversal of the given expression, delivering
    column comparisons to the given function.

    The function is of the form::

        def my_fn(binary, left, right)

    For each binary expression located which has a
    comparison operator, the product of "left" and
    "right" will be delivered to that function,
    in terms of that binary.

    Hence an expression like::

        and_(
            (a + b) == q + func.sum(e + f),
            j == r
        )

    would have the traversal::

        a <eq> q
        a <eq> e
        a <eq> f
        b <eq> q
        b <eq> e
        b <eq> f
        j <eq> r

    That is, every combination of "left" and
    "right" that doesn't further contain
    a binary comparison is passed as pairs.

    c3s�t|t�r|Vn�|jdkr�t�|j�r���d|�x6�|j�D](}x"�|j�D]}��d||�qPWq@W��	d�xT|�
�D]}�|�q�Wn:t|t�r�|Vx(|�
�D]}x�|�D]
}|Vq�Wq�WdS)N�binaryr)�
isinstancerZ__visit_name__rZ
is_comparison�operator�insert�left�right�pop�get_childrenr)�element�l�r�elem�e)�fn�stack�visitr,r-rM�s 


z#visit_binary_product.<locals>.visitN)r!)rK�exprr,)rKrLrMr-�visit_binary_product�s#rOFcs�g�i}|r�j|d<|d<|r,�j|d<|r:�j|d<|r^�fdd�|d<|d<|d	<|rv�fd
d�}||d<�j|d
<t�|ddi|��S)z1locate Table objects within the given expression.�selectZcompound_select�join�aliascs��|j�S)N)r$�table)�ent)�tablesr,r-�<lambda>�zfind_tables.<locals>.<lambda>rA�update�deletecs��|j�dS)N)r$rS)�column)rUr,r-�visit_columnsz!find_tables.<locals>.visit_columnrZrSZcolumn_collectionsF)r$r�traverse)�clauseZ
check_columnsZinclude_aliasesZ
include_joinsZinclude_selectsZinclude_crudZ	_visitorsr[r,)rUr-�find_tables�s 


 
r^cCs�t��}g}t|g�}x�|r�|��}t|t�r~t|t�rDt�|j	�s~t|t
�rT|j}t|t�r`q||kr�|�
|�|�|�qx|��D]}|�|�q�WqW|S)zqBreak up an 'order by' expression into individual column-expressions,
    without DESC/ASC/NULLS FIRST/NULLS LAST)r �
column_setr�popleftr?rrrZis_ordering_modifier�modifierrrFr�addr$rE)r]�cols�resultrL�tr8r,r,r-�unwrap_order_bys$





rfcCsdd�}t�|i|�S)NcSst|ttf�r|jSdS)N)r?rrrF)rIr,r,r-�replace*sz'unwrap_label_reference.<locals>.replace)rZreplacement_traverse)rFrgr,r,r-�unwrap_label_reference)srhcs2tdd�|D����fdd�tdd�|D��D�S)z�Given the columns clause and ORDER BY of a selectable,
    return a list of column expressions that can be added to the collist
    corresponding to the ORDER BY, without repeating those already
    in the collist.

    cSs g|]}|jdk	r|jn|�qS)N)Z_order_by_label_elementrF)r4�colr,r,r-r5:sz4expand_column_list_from_order_by.<locals>.<listcomp>csg|]}|�kr|�qSr,r,)r4ri)�cols_already_presentr,r-r5@scSsg|]}t|��qSr,)rf)r4�or,r,r-r5As)r0r)ZcollistZorder_byr,)rjr-� expand_column_list_from_order_by1s


rlcCs&x t|�D]}||kr
dSq
WdSdS)z�Given a target clause and a second to search within, return True
    if the target is plainly present in the search without any
    subqueries or aliases involved.

    Basically descends through Joins.

    TFN)r1)r]�searchrIr,r,r-�clause_is_presentFs	rnccsV|g}xJ|rP|��}|Vt|t�r8|�|j|jf�qt|t�r|�|j�qWdS)N)	rDr?r�extendrBrCrr$rF)r]rLrIr,r,r-r1Vs

r1ccs||g}xp|rv|��}t|ttf�r(|Vt|t�rF|�|j|jf�qt|t�r^|�	|j
�qt|t�r|�	|j�qWdS)N)
rDr?rrrrorBrCrr$rFrrS)r]rLrIr,r,r-�surface_selectables_onlyas


rpTccsbtf}|s|tf7}t|g�}x>|r\|��}|Vx&|��D]}t||�rLq<|�|�q<Wq WdS)z�traverse and yield only outer-exposed column elements, such as would
    be addressable in the WHERE clause of a SELECT if this element were
    in the columns clause.N)rrrr`rEr?r$)r]Zinclude_scalar_selectsZfilter_rLrI�subr,r,r-�surface_column_elementsos


rrcCsttt|���t|���S)z:Return True if left/right have some overlapping selectable)�boolr0r1r2)rBrCr,r,r-�selectables_overlap�srtcs&g��fdd�}t�|id|i��S)z�Return an ordered list of "bound" values in the given clause.

    E.g.::

        >>> expr = and_(
        ...    table.c.foo==5, table.c.foo==7
        ... )
        >>> bind_values(expr)
        [5, 7]
    cs��|j�dS)N)r$Zeffective_value)�bind)�vr,r-�visit_bindparam�sz$bind_values.<locals>.visit_bindparamZ	bindparam)rr\)r]rwr,)rvr-�bind_values�srxcCs,t|tj�r |�dd�}d|St|�SdS)N�'z''z'%s')r?r �string_typesrg�repr)rFr,r,r-�_quote_ddl_expr�sr|c@s$eZdZdZdZdZdZdd�ZdS)�
_repr_baserrr)�	max_charscCsPt|�}t|�}||jkrL|jd}|d|�d||j||d�}|S)Nrrz# ... (%d characters truncated) ... )r{r/r~)�self�value�repZlenrepZsegment_lengthr,r,r-�trunc�s

(z_repr_base.truncN)�__name__�
__module__�__qualname__�_LIST�_TUPLE�_DICT�	__slots__r�r,r,r,r-r}�s
r}c@s&eZdZdZdZd	dd�Zdd�ZdS)
�	_repr_rowzProvide a string view of a row.)�row�,cCs||_||_dS)N)r�r~)rr�r~r,r,r-�__init__�sz_repr_row.__init__cs:|j�dd��fdd�|jD��t|j�dkr2dndfS)Nz(%s%s)z, c3s|]}�|�VqdS)Nr,)r4r�)r�r,r-�	<genexpr>�sz%_repr_row.__repr__.<locals>.<genexpr>r�,�)r�rQr�r/)rr,)r�r-�__repr__�sz_repr_row.__repr__N)r�)r�r�r��__doc__r�r�r�r,r,r,r-r��s
r�c@s6eZdZdZdZd
dd�Zdd�Zdd	�Zd
d�ZdS)�_repr_paramsz�Provide a string view of bound parameters.

    Truncates display to a given numnber of 'multi' parameter sets,
    as well as long values to a given number of characters.

    )�params�batches�,cCs||_||_||_dS)N)r�r�r~)rr�r�r~r,r,r-r��sz_repr_params.__init__c	Cst|jt�r0|j}|jo,t|jdtttf�}nTt|jt�r`|j}|jo\t|jdtttf�}n$t|jt�rx|j}d}n|�|j�S|r�t	|j�|j
kr�d}d�|�|jd|j
d�|�dd�||j
t	|j�f|�|jdd�|�dd�f�S|�r
|�|j|�S|�
|j|�SdS)	NrFz8 ... displaying %i of %i total bound parameter sets ... � r������r)r?r�r!r��dict�tupler�r�r�r/r�rQ�_repr_multir�)r�typZismulti�msgr,r,r-r��s,"z_repr_params.__repr__cs�|rzt|dt�r�j�nDt|dt�r0�j�n.t|dt�rF�j�nds^tdt|d���d�	��fdd�|D��}nd}|�jkr�d|Sd	|SdS)
NrFzUnknown parameter type %sz, c3s|]}��|��VqdS)N)r�)r4r�)�	elem_typerr,r-r�
sz+_repr_params._repr_multi.<locals>.<genexpr>r�z[%s]z(%s))
r?r!r�r�r�r�r��AssertionError�typerQ)rZmulti_paramsr��elementsr,)r�rr-r��s
z_repr_params._repr_multics�|j�||jkr0dd��fdd�|��D��S||jkrjdd��fdd�|D��t|�dkrbdnd	fSd
d��fdd�|D��SdS)Nz{%s}z, c3s"|]\}}d|�|�fVqdS)z%r: %sNr,)r4�keyr�)r�r,r-r�sz,_repr_params._repr_params.<locals>.<genexpr>z(%s%s)c3s|]}�|�VqdS)Nr,)r4r�)r�r,r-r�"srr�r�z[%s]c3s|]}�|�VqdS)Nr,)r4r�)r�r,r-r�&s)r�r�rQ�itemsr�r/)rr�r�r,)r�r-r�s


z_repr_params._repr_paramsN)r�)	r�r�r�r�r�r�r�r�r�r,r,r,r-r��s
!r�cs�fdd�}t�|id|i�S)zWgiven criterion containing bind params, convert selected elements
    to IS NULL.

    csnt|jt�r:|jj�kr:|j|_t�|_tj|_tj	|_
n0t|jt�rj|jj�krjt�|_tj|_tj	|_
dS)N)r?rBrZ_identifying_keyrCrr�is_r@Zisnot�negate)r>)�nullsr,r-�visit_binary/s
z-adapt_criterion_to_null.<locals>.visit_binaryr>)rZcloned_traverse)Zcritr�r�r,)r�r-�adapt_criterion_to_null)sr�NcCs�|dkr|S|dfg}t|�}d}xz|r�|��\}}t|t�rv||k	rv|��}|��|�|j�|_|�|j	|f�n
|�|�}|dk	r�||_	|dkr$|}q$W|S)N)
�
ClauseAdapterrDr?rZ_cloneZ_reset_exportedr\r<r$rB)rBrC�stop_onrL�adapter�retZ	prevrightr,r,r-�splice_joinsDs$

r�c
s*|�dd�}|�dd��t����t���x��D]�}x�tdd�|jD��D]�}x��D]~}||krbqTy
|j}Wn>tjk
r�|r�wTn�Yn tj	k
r�|r�wTn�YnX|�
|�rT�r�|j|jkrT��|�PqTWqJWq0W|�r���fdd�}x&|D]}	|	dk	r�t
�|	id	|i�q�Wt�����S)
aCgiven a list of columns, return a 'reduced' set based on natural
    equivalents.

    the set is reduced to the smallest list of columns which have no natural
    equivalent present in the list.  A "natural equivalent" means that two
    columns will ultimately represent the same value because they are related
    by a foreign key.

    \*clauses is an optional list of join clauses which will be traversed
    to further identify columns that are "equivalent".

    \**kw may specify 'ignore_nonexistent_tables' to ignore foreign keys
    whose tables are not yet configured, or columns that aren't yet present.

    This function is primarily used to determine the most minimal "primary
    key" from a selectable, by reducing the set of primary key columns present
    in the selectable to just those that are not repeated.

    �ignore_nonexistent_tablesF�
only_synonymscSsg|]
}|j�qSr,)Zforeign_keys)r4r8r,r,r-r5xsz"reduce_columns.<locals>.<listcomp>cs~|jtjkrzt�tdd�����D���}|j|krz|j|krzx:t	��D].}|�
|j�rH�rj|j|jjkrH��|�PqHWdS)NcSsg|]
}|j�qSr,)�	proxy_set)r4r8r,r,r-r5�sz8reduce_columns.<locals>.visit_binary.<locals>.<listcomp>)
r@r�eqr r_rr7rBrC�reversed�shares_lineage�namerb)r>rcr8)�columns�omitr�r,r-r��s
z$reduce_columns.<locals>.visit_binaryNr>)rDr Zordered_column_setr_rr�rZrZNoReferencedColumnErrorZNoReferencedTableErrorr�r�rbrr\rr7)
r�r%�kwr�riZfkr8Zfk_colr�r]r,)r�r�r�r-�reduce_columns]s:






r�csH�r�rt�d��dd�������fdd�}g�t�|id|i��S)z9traverse an expression and locate binary criterion pairs.zSCan only specify one of 'consider_as_foreign_keys' or 'consider_as_referenced_keys'cSs
|�|�S)N)�compare)�a�br,r,r-�col_is�sz"criterion_as_pairs.<locals>.col_iscs~�s|jtjk	rdSt|jt�r,t|jt�s0dS�r�|j�krj�|j|j�sV|j�krj��|j|jf�n4|j�kr��|j|j�s�|j�kr���|j|jf�nڈ�r|j�kr܈|j|j�s�|j�kr܈�|j|jf�n:|j�k�rz�|j|j��s|j�k�rz��|j|jf�nbt|jt��rzt|jt��rz|j�	|j��rX��|j|jf�n"|j�	|j��rz��|j|jf�dS)N)
r@rr�r?rBrrCr$rZ
references)r>)�any_operatorr��consider_as_foreign_keys�consider_as_referenced_keys�pairsr,r-r��s:






z(criterion_as_pairs.<locals>.visit_binaryr>)r�
ArgumentErrorrr\)Z
expressionr�r�r�r�r,)r�r�r�r�r�r-�criterion_as_pairs�s'r�c@s0eZdZdZd
dd�Zejfdd�Zdd	�ZdS)r�a5Clones and modifies clauses based on column correspondence.

    E.g.::

      table1 = Table('sometable', metadata,
          Column('col1', Integer),
          Column('col2', Integer)
          )
      table2 = Table('someothertable', metadata,
          Column('col1', Integer),
          Column('col2', Integer)
          )

      condition = table1.c.col1 == table2.c.col1

    make an alias of table1::

      s = table1.alias('foo')

    calling ``ClauseAdapter(s).traverse(condition)`` converts
    condition to read::

      s.c.col1 == table2.c.col1

    NFcCs:|g|d�|_||_||_||_t�|p*i�|_||_dS)N)r��anonymize_labels)Z__traverse_options__�
selectable�
include_fn�
exclude_fnr Zcolumn_dict�equivalents�adapt_on_names)rr�r�r�r�r�r�r,r,r-r�s

zClauseAdapter.__init__cCs�|jj||d�}|dkrb||jkrb||krbx6|j|D](}|j|||�|g�d�}|dk	r6|Sq6W|jr�|dkr�|jj�|j�}|S)N)�require_embedded)r��_seen)	r�Zcorresponding_columnr��_corresponding_columnr9r�r8�getr�)rrir�r�ZnewcolZequivr,r,r-r�s
z#ClauseAdapter._corresponding_columncCsbt|t�r|j�|�r|jSt|t�s*dS|jr>|�|�s>dS|jrR|�|�rRdS|�|d�SdS)NT)r?rr�r#rr�r�r�)rrir,r,r-rg(s
zClauseAdapter.replace)NNNFF)	r�r�r�r�r�r Z	EMPTY_SETr�rgr,r,r,r-r��s

r�c@s\eZdZdZddd�ZGdd�de�Zd	d
�Zdd�ZeZ	e
jZd
d�Z
dd�Zdd�ZdS)�
ColumnAdaptera�Extends ClauseAdapter with extra utility functions.

    Key aspects of ColumnAdapter include:

    * Expressions that are adapted are stored in a persistent
      .columns collection; so that an expression E adapted into
      an expression E1, will return the same object E1 when adapted
      a second time.   This is important in particular for things like
      Label objects that are anonymized, so that the ColumnAdapter can
      be used to present a consistent "adapted" view of things.

    * Exclusion of items from the persistent collection based on
      include/exclude rules, but also independent of hash identity.
      This because "annotated" items all have the same hash identity as their
      parent.

    * "wrapping" capability is added, so that the replacement of an expression
      E can proceed through a series of adapters.  This differs from the
      visitor's "chaining" feature in that the resulting object is passed
      through all replacing functions unconditionally, rather than stopping
      at the first one that returns non-None.

    * An adapt_required option, used by eager loading to indicate that
      We don't trust a result row column that is not translated.
      This is to prevent a column from being interpreted as that
      of the child row in a self-referential scenario, see
      inheritance/test_basic.py->EagerTargetingTest.test_adapt_stringency

    NFTc			CsXtj|||||||d�t�|j�|_|js2|jrB|�||j�|_||_	||_
d|_dS)N)r�r�r�r�)r�r�r �populate_column_dict�_locate_colr�r�r��_IncludeExcludeMapping�adapt_required�allow_label_resolve�_wrap)	rr�r�r�r�r�r�r�r�r,r,r-r�VszColumnAdapter.__init__c@seZdZdd�Zdd�ZdS)z$ColumnAdapter._IncludeExcludeMappingcCs||_||_dS)N)�parentr�)rr�r�r,r,r-r�ssz-ColumnAdapter._IncludeExcludeMapping.__init__cCsL|jjr|j�|�r(|jjrB|j�|�rB|jjr>|jjj|S|S|j|S)N)r�r�r�r�r�)rr�r,r,r-�__getitem__wsz0ColumnAdapter._IncludeExcludeMapping.__getitem__N)r�r�r�r�r�r,r,r,r-r�rsr�cCsP|j�|j�}|j�|j�||_t�|j�|_|j	s<|j
rL|�||j�|_|S)N)�	__class__�__new__�__dict__rXr�r r�r�r�r�r�r�)rr�Zacr,r,r-�wrap�szColumnAdapter.wrapcCs
|j|S)N)r�)r�objr,r,r-r\�szColumnAdapter.traversecCsHt�||�}|jr*|j�|�}|dk	r*|}|jr<||kr<dS|j|_|S)N)r�r\r�r�r�r�Z_allow_label_resolve)rrir8Zc2r,r,r-r��szColumnAdapter._locate_colcCs|j��}|d=|S)Nr�)r��copy)r�dr,r,r-�__getstate__�s
zColumnAdapter.__getstate__cCs|j�|�t�|j�|_dS)N)r�rXr ZPopulateDictr�r�)r�stater,r,r-�__setstate__�szColumnAdapter.__setstate__)NFNNFTF)r�r�r�r�r��objectr�r�r\Zadapt_clauser�Zcopy_and_processZ
adapt_listr�r�r�r,r,r,r-r�7s 

r�)FFFFF)T)N)NNF)Er��collectionsr�	itertoolsrr�rr�
annotationrrr	�baser
rZddlrr�r
rrrrrrrrZschemarr�rrrrrrrrr ZlanghelpersZpublic_factoryZ_join_conditionZjoin_conditionr.r3r=rOr^rfrhrlrnr1rprrrtrxr|r�r}r�r�r�r�r�r�ZReplacingCloningVisitorr�r�r,r,r,r-�<module>
sz
*4@
"
Z
M
;P

Youez - 2016 - github.com/yon3zu
LinuXploit