HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/sqlalchemy/engine/__pycache__/row.cpython-310.pyc
o

���g�.�@s
dZddlmZddlmZddlmZddlZddlZddlm	Z	ddlm
Z
ddlmZddlmZdd	lm
Z
dd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZes�es�ddlmZnddl mZer�ddl!m"Z"ddl!m#Z#ddl!m$Z$ede	d�Z%edee	d fd�Z&Gd!d"�d"eee	ee&�Z'eZ(e'Z)Gd#d$�d$e�Z*Gd%d&�d&e*ej+d'ej,e	�Z-Gd(d)�d)e*ej.d'e	f�Z/Gd*d+�d+eejd'e	f�Z0dS),z.Define row constructs including :class:`.Row`.�)�annotations)�ABCN)�Any)�Callable)�Dict)�Generic)�Iterator)�List)�Mapping)�NoReturn)�Optional)�overload)�Sequence)�Tuple)�
TYPE_CHECKING)�TypeVar)�Union�)�util)�
deprecated)�HAS_CYEXTENSION�)�BaseRow)�_KeyType)�_ProcessorsType)�	RMKeyView�_T)�bound�_TP.c@sDeZdZdZdZdKd	d
�ZdLdd�ZdMdd�Zedd�dMdd��Z	e
dMdd��Ze
edd�dMdd���Ze
dNdd��Z
dOdd �ZesOdPd!d"�Zed#�Zed$�ZdQd'd(�ZdRd,d-�ZejZerqedSd/d0��ZedTd3d0��ZdUd5d0�ZdVd6d7�ZdVd8d9�ZdVd:d;�ZdVd<d=�ZdVd>d?�ZdVd@dA�ZdWdBdC�Ze
dXdEdF��Z dYdHdI�Z!dJS)Z�RowaRepresent a single result row.

    The :class:`.Row` object represents a row of a database result.  It is
    typically associated in the 1.x series of SQLAlchemy with the
    :class:`_engine.CursorResult` object, however is also used by the ORM for
    tuple-like results as of SQLAlchemy 1.4.

    The :class:`.Row` object seeks to act as much like a Python named
    tuple as possible.   For mapping (i.e. dictionary) behavior on a row,
    such as testing for containment of keys, refer to the :attr:`.Row._mapping`
    attribute.

    .. seealso::

        :ref:`tutorial_selecting_data` - includes examples of selecting
        rows from SELECT statements.

    .. versionchanged:: 1.4

        Renamed ``RowProxy`` to :class:`.Row`. :class:`.Row` is no longer a
        "proxy" object in that it contains the final form of data within it,
        and now acts mostly like a named tuple. Mapping-like functionality is
        moved to the :attr:`.Row._mapping` attribute. See
        :ref:`change_4710_core` for background on this change.

    ��name�str�valuer�returnrcC�td��)Nzcan't set attribute��AttributeError)�selfr!r#r r �@/usr/local/lib/python3.10/dist-packages/sqlalchemy/engine/row.py�__setattr__P�zRow.__setattr__cCr%)Nzcan't delete attributer&)r(r!r r r)�__delattr__Sr+zRow.__delattr__rcC�|S)a5Return a 'tuple' form of this :class:`.Row`.

        At runtime, this method returns "self"; the :class:`.Row` object is
        already a named tuple. However, at the typing level, if this
        :class:`.Row` is typed, the "tuple" return type will be a :pep:`484`
        ``Tuple`` datatype that contains typing information about individual
        elements, supporting typed unpacking and attribute access.

        .. versionadded:: 2.0.19 - The :meth:`.Row._tuple` method supersedes
           the previous :meth:`.Row.tuple` method, which is now underscored
           to avoid name conflicts with column names in the same way as other
           named-tuple methods on :class:`.Row`.

        .. seealso::

            :attr:`.Row._t` - shorthand attribute notation

            :meth:`.Result.tuples`


        r �r(r r r)�_tupleVsz
Row._tuplez2.0.19z�The :meth:`.Row.tuple` method is deprecated in favor of :meth:`.Row._tuple`; all :class:`.Row` methods and library-level attributes are intended to be underscored to avoid name conflicts.  Please use :meth:`Row._tuple`.cCs|��S)zUReturn a 'tuple' form of this :class:`.Row`.

        .. versionadded:: 2.0

        )r/r.r r r)�tuplens
z	Row.tuplecCr-)awA synonym for :meth:`.Row._tuple`.

        .. versionadded:: 2.0.19 - The :attr:`.Row._t` attribute supersedes
           the previous :attr:`.Row.t` attribute, which is now underscored
           to avoid name conflicts with column names in the same way as other
           named-tuple methods on :class:`.Row`.

        .. seealso::

            :attr:`.Result.t`
        r r.r r r)�_t}s
zRow._tz�The :attr:`.Row.t` attribute is deprecated in favor of :attr:`.Row._t`; all :class:`.Row` methods and library-level attributes are intended to be underscored to avoid name conflicts.  Please use :attr:`Row._t`.cCs|jS)zKA synonym for :meth:`.Row._tuple`.

        .. versionadded:: 2.0

        )r1r.r r r)�t�szRow.t�
RowMappingcCst|jd|j|j�S)a]Return a :class:`.RowMapping` for this :class:`.Row`.

        This object provides a consistent Python mapping (i.e. dictionary)
        interface for the data contained within the row.   The :class:`.Row`
        by itself behaves like a named tuple.

        .. seealso::

            :attr:`.Row._fields`

        .. versionadded:: 1.4

        N)r3�_parent�
_key_to_index�_datar.r r r)�_mapping�szRow._mapping�	processor�Optional[_ProcessorsType]�Row[Any]cCst|j||j|j�S�N)rr4r5r6)r(r8r r r)�_filter_on_values�szRow._filter_on_valuescstd�fdd��}|S)	z3Handle ambiguous names such as "count" and "index" r(rr$rcs*�j���r����Sd��fdd�}|S)N�argr�kwr$csttj���g|�Ri|��Sr;)�getattr�collections_abcr)r=r>)r!r(r r)�meth�s
���z4Row._special_name_accessor.<locals>.go.<locals>.meth)r=rr>rr$r)r4�_has_key�__getattr__)r(rA�r!r.r)�go�s
z&Row._special_name_accessor.<locals>.goN)r(rr$r)�property)r!rEr rDr)�_special_name_accessor�szRow._special_name_accessor�count�index�key�boolcC�
||jvSr;)r6�r(rJr r r)�__contains__��
zRow.__contains__�other�op�Callable[[Any, Any], bool]cCs*t|t�r||��|���S||��|�Sr;)�
isinstancer�_to_tuple_instance)r(rPrQr r r)�_op�s
���zRow._op�intcC�dSr;r �r(rIr r r)�__getitem__��zRow.__getitem__�slice�
Sequence[Any]cCrWr;r rXr r r)rY�rZ�Union[int, slice]cCrWr;r rXr r r)rY��cC�|�|tj�Sr;)rU�operator�lt�r(rPr r r)�__lt__��z
Row.__lt__cCr_r;)rUr`�lerbr r r)�__le__�rdz
Row.__le__cCr_r;)rUr`�gerbr r r)�__ge__�rdz
Row.__ge__cCr_r;)rUr`�gtrbr r r)�__gt__�rdz
Row.__gt__cCr_r;)rUr`�eqrbr r r)�__eq__�rdz
Row.__eq__cCr_r;)rUr`�nerbr r r)�__ne__�rdz
Row.__ne__cCstt�|��Sr;)�repr�sql_util�	_repr_rowr.r r r)�__repr__�rdzRow.__repr__�Tuple[str, ...]cCstdd�|jjD��S)a�Return a tuple of string keys as represented by this
        :class:`.Row`.

        The keys can represent the labels of the columns returned by a core
        statement or the names of the orm classes returned by an orm
        execution.

        This attribute is analogous to the Python named tuple ``._fields``
        attribute.

        .. versionadded:: 1.4

        .. seealso::

            :attr:`.Row._mapping`

        cSsg|]}|dur|�qSr;r ��.0�kr r r)�
<listcomp>�zRow._fields.<locals>.<listcomp>)r0r4�keysr.r r r)�_fields�szRow._fields�Dict[str, Any]cC�
t|j�S)amReturn a new dict which maps field names to their corresponding
        values.

        This method is analogous to the Python named tuple ``._asdict()``
        method, and works by applying the ``dict()`` constructor to the
        :attr:`.Row._mapping` attribute.

        .. versionadded:: 1.4

        .. seealso::

            :attr:`.Row._mapping`

        )�dictr7r.r r r)�_asdict	s
zRow._asdictN)r!r"r#rr$r)r!r"r$r)r$r)r$r3)r8r9r$r:)r!r"r$r)rJrr$rK)rPrrQrRr$rK)rIrVr$r)rIr[r$r\)rIr]r$r�rPrr$rK�r$r")r$rs)r$r{)"�__name__�
__module__�__qualname__�__doc__�	__slots__r*r,r/rr0rFr1r2r7r<rrGrHrIrNrUr�__hash__r
rYrcrfrhrjrlrnrrrzr~r r r r)r2sZ


��











rc@sheZdZUdZded<ded<ddd	�Zd dd
�Zd!dd�Zd"dd�Zd#dd�Z	d$dd�Z
d$dd�ZdS)%�
ROMappingViewr r\�_items�Mapping['_KeyType', Any]r7�mapping�itemscCs||_||_dSr;)r7r�)r(r�r�r r r)�__init__%s
zROMappingView.__init__r$rVcCr|r;)�lenr�r.r r r)�__len__+rOzROMappingView.__len__r"cCs
d�|�S)Nz&{0.__class__.__name__}({0._mapping!r}))�formatr.r r r)rr.rOzROMappingView.__repr__�
Iterator[Any]cCr|r;)�iterr�r.r r r)�__iter__1rOzROMappingView.__iter__�itemrrKcCrLr;�r�)r(r�r r r)rN4rOzROMappingView.__contains__rPcCst|�t|�kSr;��listrbr r r)rl7�zROMappingView.__eq__cCst|�t|�kSr;r�rbr r r)rn:r�zROMappingView.__ne__N)r�r�r�r\�r$rVr�)r$r�)r�rr$rKr)r�r�r�r��__annotations__r�r�rrr�rNrlrnr r r r)r�s






r�c@�eZdZdZdS)�ROMappingKeysValuesViewr�N�r�r�r�r�r r r r)r�>sr�rc@r�)�ROMappingItemsViewr�Nr�r r r r)r�Dsr�c@szeZdZdZdZerd#dd�ZnejZd$d
d�Z	d%d
d�Z
d&dd�Zd'dd�Zd(dd�Z
d)dd�Zd*dd�Zd+d d!�Zd"S),r3a�A ``Mapping`` that maps column names and objects to :class:`.Row`
    values.

    The :class:`.RowMapping` is available from a :class:`.Row` via the
    :attr:`.Row._mapping` attribute, as well as from the iterable interface
    provided by the :class:`.MappingResult` object returned by the
    :meth:`_engine.Result.mappings` method.

    :class:`.RowMapping` supplies Python mapping (i.e. dictionary) access to
    the  contents of the row.   This includes support for testing of
    containment of specific keys (string column names or objects), as well
    as iteration of keys, values, and items::

        for row in result:
            if "a" in row._mapping:
                print("Column 'a': %s" % row._mapping["a"])

            print("Column b: %s" % row._mapping[table.c.b])

    .. versionadded:: 1.4 The :class:`.RowMapping` object replaces the
       mapping-like access previously provided by a database result row,
       which now seeks to behave mostly like a named tuple.

    r rJrr$rcCrWr;r rMr r r)rYfr^zRowMapping.__getitem__�	List[Any]cCr|r;)r�r6r.r r r)�_values_implkrOzRowMapping._values_impl�
Iterator[str]cCsdd�|jjD�S)Ncss�|]	}|dur|VqdSr;r rtr r r)�	<genexpr>os�z&RowMapping.__iter__.<locals>.<genexpr>�r4ryr.r r r)r�nszRowMapping.__iter__rVcCr|r;)r�r6r.r r r)r�qrOzRowMapping.__len__�objectrKcCs|j�|�Sr;)r4rBrMr r r)rNt�zRowMapping.__contains__r"cCstt|��Sr;)ror}r.r r r)rrwr�zRowMapping.__repr__r�cst��fdd����D��S)zeReturn a view of key/value tuples for the elements in the
        underlying :class:`.Row`.

        csg|]}|�|f�qSr r )rurJr.r r)rw�rxz$RowMapping.items.<locals>.<listcomp>)r�ryr.r r.r)r�zs�zRowMapping.itemsrcCs|jjS)znReturn a view of 'keys' for string column names represented
        by the underlying :class:`.Row`.

        r�r.r r r)ry�szRowMapping.keysr�cCst||���S)zeReturn a view of values for the values represented in the
        underlying :class:`.Row`.

        )r�r�r.r r r)�values�szRowMapping.valuesN)rJrr$r)r$r�)r$r�r�)rJr�r$rKr�)r$r�)r$r)r$r�)r�r�r�r�r�rrYr�_get_by_key_impl_mappingr�r�r�rNrrr�ryr�r r r r)r3Hs






	r3)1r��
__future__r�abcr�collections.abcr@r`�typingrrrrrr	r
rrr
rrrrr�sqlrrpr�util._has_cyr�_py_rowr�"sqlalchemy.cyextension.resultproxy�resultrrrrrr�BaseRowProxy�RowProxyr��KeysView�
ValuesViewr��	ItemsViewr�r3r r r r)�<module>sVj
�