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__/schema.cpython-37.pyc
B

��4]���@sdZddlmZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZdd	l
mZdd
l
m
Z
ddl
mZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZe�d�Ze�dd�Z dd�Z!dd �Z"ej#Gd!d"�d"ee	j$��Z%Gd#d$�d$e
e%e�Z&Gd%d&�d&e
e%e�Z'Gd'd(�d(e
e%�Z(Gd)d*�d*e)�Z*Gd+d,�d,e*e%�Z+Gd-d.�d.e+�Z,Gd/d0�d0e+�Z-ej#Gd1d2�d2e*e��Z.Gd3d4�d4e.�Z/e�0d5d6�Gd7d8�d8e/��Z1Gd9d:�d:e
e%�Z2d;d<�Z3d=d>�Z4Gd?d@�d@e)�Z5GdAdB�dBe5e2�Z6GdCdD�dDe6�Z7GdEdF�dFe6�Z8GdGdH�dHe6�Z9GdIdJ�dJe6�Z:GdKdL�dLe
e5e%�Z;e�<dMdNi�Z=GdOdP�dPe%�Z>GdQdR�dRe>�Z?GdSdT�dTe)�Z@e@d�ZAe@jBZBdS)Ua/The schema module provides the building blocks for database metadata.

Each element within this module describes a database entity which can be
created and dropped, or is otherwise part of such an entity.  Examples include
tables, columns, sequences, and indexes.

All entities are subclasses of :class:`~sqlalchemy.schema.SchemaItem`, and as
defined in this module they are intended to be agnostic of any vendor-specific
constructs.

A collection of entities are grouped into a unit called
:class:`~sqlalchemy.schema.MetaData`. MetaData serves as a logical grouping of
schema elements, and can also be associated with an actual database connection
such that operations involving the contained elements can contact the database
as needed.

Two of the elements here also build upon their "syntactic" counterparts, which
are defined in :class:`~sqlalchemy.sql.expression.`, specifically
:class:`~sqlalchemy.schema.Table` and :class:`~sqlalchemy.schema.Column`.
Since these objects are part of the SQL expression language, they are usable
as components in SQL expressions.

�)�absolute_importN�)�ddl)�type_api)�visitors)�_bind_or_error)�ColumnCollection)�
DialectKWArgs)�SchemaEventTarget)�
_as_truncated)�_document_text_coercion)�_literal_as_text)�
ClauseElement)�ColumnClause)�
ColumnElement)�quoted_name)�
TextClause)�TableClause�)�event)�exc)�
inspection)�utilZ
retain_schemaZblank_schemaz�Symbol indicating that a :class:`.Table` or :class:`.Sequence`
    should have 'None' for its schema, even if the parent
    :class:`.MetaData` has specified a schema.

    .. versionadded:: 1.0.14

    cCs|dkr|S|d|SdS)N�.�)�name�schemarr�H/opt/alt/python37/lib64/python3.7/site-packages/sqlalchemy/sql/schema.py�_get_table_keyIsrcs��fdd�}t�|i|�S)Ncs4t|t�r,|j�kr,|j�jkr,�j|jSdSdS)N)�
isinstance�Column�table�key�c)�col)�source_table�target_tablerr�replaceSs


z!_copy_expression.<locals>.replace)rZreplacement_traverse)Z
expressionr%r&r'r)r%r&r�_copy_expressionRs
r(c@sbeZdZdZdZdd�Zdd�Zdd�Zee	�
d	d
�dd���Ze	jd
d��Z
dd�Zdd�ZdS)�
SchemaItemz3Base class for items that define a database schema.�schema_itemcGs$x|D]}|dk	r|�|�qWdS)z7Initialize the list of child items for this SchemaItem.N)�_set_parent_with_dispatch)�self�args�itemrrr�_init_itemsfs
zSchemaItem._init_itemscKsgS)z"used to allow SchemaVisitor accessr)r,�kwargsrrr�get_childrenmszSchemaItem.get_childrencCstj|dgd�S)N�info)Z
omit_kwarg)r�generic_repr)r,rrr�__repr__qszSchemaItem.__repr__z0.9z�The :attr:`.SchemaItem.quote` attribute is deprecated and will be removed in a future release.  Use the :attr:`.quoted_name.quote` attribute on the ``name`` field of the target schema item to retrievequoted status.cCs|jjS)z�Return the value of the ``quote`` flag passed
        to this schema object, for those schema items which
        have a ``name`` field.

        )r�quote)r,rrrr5tszSchemaItem.quotecCsiS)aLInfo dictionary associated with the object, allowing user-defined
        data to be associated with this :class:`.SchemaItem`.

        The dictionary is automatically generated when first accessed.
        It can also be specified in the constructor of some objects,
        such as :class:`.Table` and :class:`.Column`.

        r)r,rrrr2�s
zSchemaItem.infocCs(d|jkr|j��|_|j�|j�|S)Nr2)�__dict__r2�copy�dispatchZ_update)r,r*rrr�_schema_item_copy�s
zSchemaItem._schema_item_copycCs|�||�S)N)�get)r,�effective_schema�map_rrr�_translate_schema�szSchemaItem._translate_schemaN)�__name__�
__module__�__qualname__�__doc__�__visit_name__r/r1r4�propertyr�
deprecatedr5�memoized_propertyr2r9r=rrrrr)`sr)cs:eZdZdZdZejdd�dd��Zee�	dd�d	d
���Z
dd�Z�fd
d�ZdAdd�Z
edd��Zedd��Zdd�Zdd�Zdd�Zdd�Zed d!��Zed"d#��Zd$d%�Zd&d'�Zed(d)��Zd*d+�Zd,d-�Zd.d/�Ze�	d0d1�d2d3��Zd4d5�ZdBd7d8�ZdCd9d:�ZdDd;d<�Z dEd=d>�Z!e"ddfd?d@�Z#�Z$S)F�Tablea�2Represent a table in a database.

    e.g.::

        mytable = Table("mytable", metadata,
                        Column('mytable_id', Integer, primary_key=True),
                        Column('value', String(50))
                   )

    The :class:`.Table` object constructs a unique instance of itself based
    on its name and optional schema name within the given
    :class:`.MetaData` object. Calling the :class:`.Table`
    constructor with the same name and same :class:`.MetaData` argument
    a second time will return the *same* :class:`.Table` object - in this way
    the :class:`.Table` constructor acts as a registry function.

    .. seealso::

        :ref:`metadata_describing` - Introduction to database metadata

    Constructor arguments are as follows:

    :param name: The name of this table as represented in the database.

        The table name, along with the value of the ``schema`` parameter,
        forms a key which uniquely identifies this :class:`.Table` within
        the owning :class:`.MetaData` collection.
        Additional calls to :class:`.Table` with the same name, metadata,
        and schema name will return the same :class:`.Table` object.

        Names which contain no upper case characters
        will be treated as case insensitive names, and will not be quoted
        unless they are a reserved word or contain special characters.
        A name with any number of upper case characters is considered
        to be case sensitive, and will be sent as quoted.

        To enable unconditional quoting for the table name, specify the flag
        ``quote=True`` to the constructor, or use the :class:`.quoted_name`
        construct to specify the name.

    :param metadata: a :class:`.MetaData` object which will contain this
        table.  The metadata is used as a point of association of this table
        with other tables which are referenced via foreign key.  It also
        may be used to associate this table with a particular
        :class:`.Connectable`.

    :param \*args: Additional positional arguments are used primarily
        to add the list of :class:`.Column` objects contained within this
        table. Similar to the style of a CREATE TABLE statement, other
        :class:`.SchemaItem` constructs may be added here, including
        :class:`.PrimaryKeyConstraint`, and :class:`.ForeignKeyConstraint`.

    :param autoload: Defaults to False, unless :paramref:`.Table.autoload_with`
        is set in which case it defaults to True; :class:`.Column` objects
        for this table should be reflected from the database, possibly
        augmenting or replacing existing :class:`.Column` objects that were
        explicitly specified.

        .. versionchanged:: 1.0.0 setting the :paramref:`.Table.autoload_with`
           parameter implies that :paramref:`.Table.autoload` will default
           to True.

        .. seealso::

            :ref:`metadata_reflection_toplevel`

    :param autoload_replace: Defaults to ``True``; when using
        :paramref:`.Table.autoload`
        in conjunction with :paramref:`.Table.extend_existing`, indicates
        that :class:`.Column` objects present in the already-existing
        :class:`.Table` object should be replaced with columns of the same
        name retrieved from the autoload process.   When ``False``, columns
        already present under existing names will be omitted from the
        reflection process.

        Note that this setting does not impact :class:`.Column` objects
        specified programmatically within the call to :class:`.Table` that
        also is autoloading; those :class:`.Column` objects will always
        replace existing columns of the same name when
        :paramref:`.Table.extend_existing` is ``True``.

        .. seealso::

            :paramref:`.Table.autoload`

            :paramref:`.Table.extend_existing`

    :param autoload_with: An :class:`.Engine` or :class:`.Connection` object
        with which this :class:`.Table` object will be reflected; when
        set to a non-None value, it implies that :paramref:`.Table.autoload`
        is ``True``.   If left unset, but :paramref:`.Table.autoload` is
        explicitly set to ``True``, an autoload operation will attempt to
        proceed by locating an :class:`.Engine` or :class:`.Connection` bound
        to the underlying :class:`.MetaData` object.

        .. seealso::

            :paramref:`.Table.autoload`

    :param extend_existing: When ``True``, indicates that if this
        :class:`.Table` is already present in the given :class:`.MetaData`,
        apply further arguments within the constructor to the existing
        :class:`.Table`.

        If :paramref:`.Table.extend_existing` or
        :paramref:`.Table.keep_existing` are not set, and the given name
        of the new :class:`.Table` refers to a :class:`.Table` that is
        already present in the target :class:`.MetaData` collection, and
        this :class:`.Table` specifies additional columns or other constructs
        or flags that modify the table's state, an
        error is raised.  The purpose of these two mutually-exclusive flags
        is to specify what action should be taken when a :class:`.Table`
        is specified that matches an existing :class:`.Table`, yet specifies
        additional constructs.

        :paramref:`.Table.extend_existing` will also work in conjunction
        with :paramref:`.Table.autoload` to run a new reflection
        operation against the database, even if a :class:`.Table`
        of the same name is already present in the target
        :class:`.MetaData`; newly reflected :class:`.Column` objects
        and other options will be added into the state of the
        :class:`.Table`, potentially overwriting existing columns
        and options of the same name.

        As is always the case with :paramref:`.Table.autoload`,
        :class:`.Column` objects can be specified in the same :class:`.Table`
        constructor, which will take precedence.  Below, the existing
        table ``mytable`` will be augmented with :class:`.Column` objects
        both reflected from the database, as well as the given :class:`.Column`
        named "y"::

            Table("mytable", metadata,
                        Column('y', Integer),
                        extend_existing=True,
                        autoload=True,
                        autoload_with=engine
                    )

        .. seealso::

            :paramref:`.Table.autoload`

            :paramref:`.Table.autoload_replace`

            :paramref:`.Table.keep_existing`


    :param implicit_returning: True by default - indicates that
        RETURNING can be used by default to fetch newly inserted primary key
        values, for backends which support this.  Note that
        create_engine() also provides an implicit_returning flag.

    :param include_columns: A list of strings indicating a subset of
        columns to be loaded via the ``autoload`` operation; table columns who
        aren't present in this list will not be represented on the resulting
        ``Table`` object. Defaults to ``None`` which indicates all columns
        should be reflected.

    :param resolve_fks: Whether or not to reflect :class:`.Table` objects
        related to this one via :class:`.ForeignKey` objects, when
        :paramref:`.Table.autoload` or :paramref:`.Table.autoload_with` is
        specified.   Defaults to True.  Set to False to disable reflection of
        related tables as :class:`.ForeignKey` objects are encountered; may be
        used either to save on SQL calls or to avoid issues with related tables
        that can't be accessed. Note that if a related table is already present
        in the :class:`.MetaData` collection, or becomes present later, a
        :class:`.ForeignKey` object associated with this :class:`.Table` will
        resolve to that table normally.

        .. versionadded:: 1.3

        .. seealso::

            :paramref:`.MetaData.reflect.resolve_fks`


    :param info: Optional data dictionary which will be populated into the
        :attr:`.SchemaItem.info` attribute of this object.

    :param keep_existing: When ``True``, indicates that if this Table
        is already present in the given :class:`.MetaData`, ignore
        further arguments within the constructor to the existing
        :class:`.Table`, and return the :class:`.Table` object as
        originally created. This is to allow a function that wishes
        to define a new :class:`.Table` on first call, but on
        subsequent calls will return the same :class:`.Table`,
        without any of the declarations (particularly constraints)
        being applied a second time.

        If :paramref:`.Table.extend_existing` or
        :paramref:`.Table.keep_existing` are not set, and the given name
        of the new :class:`.Table` refers to a :class:`.Table` that is
        already present in the target :class:`.MetaData` collection, and
        this :class:`.Table` specifies additional columns or other constructs
        or flags that modify the table's state, an
        error is raised.  The purpose of these two mutually-exclusive flags
        is to specify what action should be taken when a :class:`.Table`
        is specified that matches an existing :class:`.Table`, yet specifies
        additional constructs.

        .. seealso::

            :paramref:`.Table.extend_existing`

    :param listeners: A list of tuples of the form ``(<eventname>, <fn>)``
        which will be passed to :func:`.event.listen` upon construction.
        This alternate hook to :func:`.event.listen` allows the establishment
        of a listener function specific to this :class:`.Table` before
        the "autoload" process begins.  Particularly useful for
        the :meth:`.DDLEvents.column_reflect` event::

            def listen_for_reflect(table, column_info):
                "handle the column reflection event"
                # ...

            t = Table(
                'sometable',
                autoload=True,
                listeners=[
                    ('column_reflect', listen_for_reflect)
                ])

    :param mustexist: When ``True``, indicates that this Table must already
        be present in the given :class:`.MetaData` collection, else
        an exception is raised.

    :param prefixes:
        A list of strings to insert after CREATE in the CREATE TABLE
        statement.  They will be separated by spaces.

    :param quote: Force quoting of this table's name on or off, corresponding
        to ``True`` or ``False``.  When left at its default of ``None``,
        the column identifier will be quoted according to whether the name is
        case sensitive (identifiers with at least one upper case character are
        treated as case sensitive), or if it's a reserved word.  This flag
        is only needed to force quoting of a reserved word which is not known
        by the SQLAlchemy dialect.

    :param quote_schema: same as 'quote' but applies to the schema identifier.

    :param schema: The schema name for this table, which is required if
        the table resides in a schema other than the default selected schema
        for the engine's database connection.  Defaults to ``None``.

        If the owning :class:`.MetaData` of this :class:`.Table` specifies its
        own :paramref:`.MetaData.schema` parameter, then that schema name will
        be applied to this :class:`.Table` if the schema parameter here is set
        to ``None``.  To set a blank schema name on a :class:`.Table` that
        would otherwise use the schema set on the owning :class:`.MetaData`,
        specify the special symbol :attr:`.BLANK_SCHEMA`.

        .. versionadded:: 1.0.14  Added the :attr:`.BLANK_SCHEMA` symbol to
           allow a :class:`.Table` to have a blank schema name even when the
           parent :class:`.MetaData` specifies :paramref:`.MetaData.schema`.

        The quoting rules for the schema name are the same as those for the
        ``name`` parameter, in that quoting is applied for reserved words or
        case-sensitive names; to enable unconditional quoting for the schema
        name, specify the flag ``quote_schema=True`` to the constructor, or use
        the :class:`.quoted_name` construct to specify the name.

    :param useexisting: the same as :paramref:`.Table.extend_existing`.

    :param comment: Optional string that will render an SQL comment on table
         creation.

         .. versionadded:: 1.2 Added the :paramref:`.Table.comment` parameter
            to :class:`.Table`.

    :param \**kw: Additional keyword arguments not mentioned above are
        dialect specific, and passed in the form ``<dialectname>_<argname>``.
        See the documentation regarding an individual dialect at
        :ref:`dialect_toplevel` for detail on documented arguments.

    r!)z0.7z�The :paramref:`.Table.useexisting` parameter is deprecated and will be removed in a future release.  Please use :paramref:`.Table.extend_existing`.)�useexistingcOs�|st�|�Sy$|d|d|dd�}}}Wntk
rNtd��YnX|�dd�}|dkrl|j}n|tkrxd}|�dd�}|�dd�}d	|kr�|r�d
}t�	|��|�d	d�}|r�|r�d}t�	|��|�dd�}	t
||�}
|
|jk�r2|�s|�st|��rt�
d
|
��|j|
}|�r.|j||�|S|	�rFt�
d|
��t�|�}|j�||�|�|||�y&|j||f|�|�|j�||�|St���|�||�WdQRXYnXdS)Nrrrz$Table() takes at least two argumentsr�
keep_existingF�extend_existingrGz/useexisting is synonymous with extend_existing.z9keep_existing and extend_existing are mutually exclusive.�	mustexistz�Table '%s' is already defined for this MetaData instance.  Specify 'extend_existing=True' to redefine options and columns on an existing Table object.zTable '%s' not defined)�object�__new__�
IndexError�	TypeErrorr:r�BLANK_SCHEMA�popr�
ArgumentErrorr�tables�bool�InvalidRequestError�_init_existingr8Zbefore_parent_attach�
_add_table�_init�after_parent_attachrZsafe_reraise�
_remove_table)�clsr-�kwr�metadatarrHrI�msgrJr"r!rrrrL�sX	
$





z
Table.__new__z0.9z�The :meth:`.SchemaItem.quote` method is deprecated and will be removed in a future release.  Use the :attr:`.quoted_name.quote` attribute on the ``schema`` field of the target schema item to retrieve quoted status.cCs|jjS)z^Return the value of the ``quote_schema`` flag passed
        to this :class:`.Table`.
        )rr5)r,rrr�quote_schema�s
zTable.quote_schemacOsdS)z�Constructor for :class:`~.schema.Table`.

        This method is a no-op.   See the top-level
        documentation for :class:`~.schema.Table`
        for constructor arguments.

        Nr)r,r-r[rrr�__init__szTable.__init__cs�tt|��t||�dd���||_|�dd�|_|jdkrF|j|_n,|jtkrXd|_n|�dd�}t|j|�|_t�|_	t�|_
t�|_t
dd��|�t�|_t�|_|jdk	r�d|j|jf|_n|j|_|�dd�}|�d|dk	�}|�d	d�|�d
d�}|�dd�}	|�dd�}
|�d
d�|_|�dd�|_d|k�rN|�d�|_d|k�r�|�d�}x |D]\}}
t�|||
��qhW|�dg�|_|jf|�|�r�|j|||
||	d�|j|�dS)Nr5rr^T)�_implicit_generatedz%s.%s�
autoload_with�autoload�autoload_replace�
_extend_on�resolve_fks�include_columns�implicit_returning�commentr2�	listeners�prefixes)rdre)�superrFr_rrPr\rrO�set�indexes�constraintsr�_columns�PrimaryKeyConstraintr+�foreign_keys�_extra_dependenciesr�fullnamergrhr2r�listenZ	_prefixes�
_extra_kwargs�	_autoloadr/)r,rr\r-r0r^rarbrdrerfri�evt�fn)�	__class__rrrWsZ







zTable._initrTNcCsJ|r |j|jj|||||d�n&t|dd�}|j|jj|||||d�dS)N)rdz�No engine is bound to this Table's MetaData. Pass an engine to the Table via autoload_with=<someengine>, or associate the MetaData with an engine via metadata.bind=<someengine>)r])�run_callable�dialectZreflecttabler)r,r\rarf�exclude_columnsrerd�bindrrrrvPs$

zTable._autoloadcCst|jdd�d�S)zTReturn the set of constraints as a list, sorted by creation
        order.

        cSs|jS)N)Z_creation_order)r#rrr�<lambda>{�z+Table._sorted_constraints.<locals>.<lambda>)r")�sortedrn)r,rrr�_sorted_constraintsuszTable._sorted_constraintscCstdd�|jD��S)z�:class:`.ForeignKeyConstraint` objects referred to by this
        :class:`.Table`.

        This list is produced from the collection of :class:`.ForeignKey`
        objects currently associated.

        .. versionadded:: 1.0.0

        css|]}|jVqdS)N)�
constraint)�.0�fkcrrr�	<genexpr>�sz0Table.foreign_key_constraints.<locals>.<genexpr>)rlrq)r,rrr�foreign_key_constraints}szTable.foreign_key_constraintsc
OsD|�dd�}|�d|dk	�}|�dd�}|�dd�}|�dd�}|r`||jkr`t�d|j|f��|�dd�}|�d	d�}	|dk	r�x$|jD]}
|
j|kr�|j�|
�q�Wxd
D]}||kr�t�d��q�Wd|kr�|�dd�|_d
|kr�|�d
�|_	|�r*|�sdd�|jD�}nd}|j
|j||||	|d�|jf|�|j
|�dS)NrarbrcTrrdz7Can't change schema of existing table from '%s' to '%s'rfre)r5r^z2Can't redefine 'quote' or 'quote_schema' argumentsrhr2cSsg|]
}|j�qSr)r)r�r#rrr�
<listcomp>�sz(Table._init_existing.<locals>.<listcomp>r)rd)rPrrrQr#rro�removerhr2rvr\rur/)
r,r-r0rarbrcrrdrfrer#r"r|rrrrU�sH


zTable._init_existingcKs|�|�dS)N)�_validate_dialect_kwargs)r,r0rrrru�szTable._extra_kwargscCsdS)Nr)r,rrr�_init_collections�szTable._init_collectionscCsdS)Nr)r,rrr�_reset_exported�szTable._reset_exportedcCs|jjS)N)�primary_key�_autoincrement_column)r,rrrr��szTable._autoincrement_columncCst|j|j�S)a_Return the 'key' for this :class:`.Table`.

        This value is used as the dictionary key within the
        :attr:`.MetaData.tables` collection.   It is typically the same
        as that of :attr:`.Table.name` for a table with no
        :attr:`.Table.schema` set; otherwise it is typically of the form
        ``schemaname.tablename``.

        )rrr)r,rrrr"�sz	Table.keycsDdd�t�j�gt�j�gdd��jD��fdd�dD��S)Nz	Table(%s)z, cSsg|]}t|��qSr)�repr)r��xrrrr��sz"Table.__repr__.<locals>.<listcomp>cs"g|]}d|tt�|��f�qS)z%s=%s)r��getattr)r��k)r,rrr��s)r)�joinr�rr\�columns)r,r)r,rr4�szTable.__repr__cCst|j|j�S)N)r�descriptionr)r,rrr�__str__�sz
Table.__str__cCs|jr|jjpdS)z2Return the connectable associated with this Table.N)r\r})r,rrrr}�sz
Table.bindcCs|j�|�dS)a�Add a 'dependency' for this Table.

        This is another Table object which must be created
        first before this one can, or dropped after this one.

        Usually, dependencies between tables are determined via
        ForeignKey objects.   However, for other situations that
        create dependencies outside of foreign keys (rules, inheriting),
        this method can manually establish such a link.

        N)rr�add)r,r!rrr�add_is_dependent_on�szTable.add_is_dependent_oncCs|�|�dS)azAppend a :class:`~.schema.Column` to this :class:`~.schema.Table`.

        The "key" of the newly added :class:`~.schema.Column`, i.e. the
        value of its ``.key`` attribute, will then be available
        in the ``.c`` collection of this :class:`~.schema.Table`, and the
        column definition will be included in any CREATE TABLE, SELECT,
        UPDATE, etc. statements generated from this :class:`~.schema.Table`
        construct.

        Note that this does **not** change the definition of the table
        as it exists within any underlying database, assuming that
        table has already been created in the database.   Relational
        databases support the addition of columns to existing tables
        using the SQL ALTER command, which would need to be
        emitted for an already-existing table that doesn't contain
        the newly added column.

        N)r+)r,�columnrrr�
append_column�szTable.append_columncCs|�|�dS)a�Append a :class:`~.schema.Constraint` to this
        :class:`~.schema.Table`.

        This has the effect of the constraint being included in any
        future CREATE TABLE statement, assuming specific DDL creation
        events have not been associated with the given
        :class:`~.schema.Constraint` object.

        Note that this does **not** produce the constraint within the
        relational database automatically, for a table that already exists
        in the database.   To add a constraint to an
        existing relational database table, the SQL ALTER command must
        be used.  SQLAlchemy also provides the
        :class:`.AddConstraint` construct which can produce this SQL when
        invoked as an executable clause.

        N)r+)r,r�rrr�append_constraintszTable.append_constraintz0.7z�the :meth:`.Table.append_ddl_listener` method is deprecated and will be removed in a future release.  Please refer to :class:`.DDLEvents`.cs,��fdd�}t�|d��dd�|�dS)z8Append a DDL event listener to this ``Table``.

        cs��||�dS)Nr)�target�
connectionr[)�
event_name�listenerrr�adapt_listener/sz1Table.append_ddl_listener.<locals>.adapt_listener��-�_N)rrtr')r,r�r�r�r)r�r�r�append_ddl_listener$szTable.append_ddl_listenercCs|�|j|j|�||_dS)N)rVrrr\)r,r\rrr�_set_parent4szTable._set_parentFcKs0|stj|fd|i|��S|r(t|j�SgSdS)N�column_collections)rr1�listr�)r,r��schema_visitorr[rrrr18s
zTable.get_childrencCs(|dkrt|�}|j|jj|j|jd�S)z!Return True if this table exists.N)r)rrzr{Z	has_tablerr)r,r}rrr�existsEszTable.existscCs&|dkrt|�}|jtj||d�dS)z�Issue a ``CREATE`` statement for this
        :class:`.Table`, using the given :class:`.Connectable`
        for connectivity.

        .. seealso::

            :meth:`.MetaData.create_all`.

        N)�
checkfirst)r�_run_visitorr�SchemaGenerator)r,r}r�rrr�createOszTable.createcCs&|dkrt|�}|jtj||d�dS)z�Issue a ``DROP`` statement for this
        :class:`.Table`, using the given :class:`.Connectable`
        for connectivity.

        .. seealso::

            :meth:`.MetaData.drop_all`.

        N)r�)rr�r�
SchemaDropper)r,r}r�rrr�drop^s
z
Table.dropcsz|dkr�j}|tkr�j}n|dkr,|j}t||�}||jkrZt�d�j�|j|Sg}x �jD]}|�	|j
|d��qfWt||f|�|�jd��j
���x~�jD]t}t|t�r�|j}|r�|�|||�}	n|�jkr�|nd}	��|j
|	�d��q�|js�|j�rq���|j
|�d��q�WxN�jD]D}
|
j�r8�q(t|
jf��fdd�|
jD��|
j�d�|
j
���q(W����S)	a`
Return a copy of this :class:`.Table` associated with a different
        :class:`.MetaData`.

        E.g.::

            m1 = MetaData()

            user = Table('user', m1, Column('id', Integer, primary_key=True))

            m2 = MetaData()
            user_copy = user.tometadata(m2)

        :param metadata: Target :class:`.MetaData` object, into which the
         new :class:`.Table` object will be created.

        :param schema: optional string name indicating the target schema.
         Defaults to the special symbol :attr:`.RETAIN_SCHEMA` which indicates
         that no change to the schema name should be made in the new
         :class:`.Table`.  If set to a string name, the new :class:`.Table`
         will have this new name as the ``.schema``.  If set to ``None``, the
         schema will be set to that of the schema set on the target
         :class:`.MetaData`, which is typically ``None`` as well, unless
         set explicitly::

            m2 = MetaData(schema='newschema')

            # user_copy_one will have "newschema" as the schema name
            user_copy_one = user.tometadata(m2, schema=None)

            m3 = MetaData()  # schema defaults to None

            # user_copy_two will have None as the schema name
            user_copy_two = user.tometadata(m3, schema=None)

        :param referred_schema_fn: optional callable which can be supplied
         in order to provide for the schema name that should be assigned
         to the referenced table of a :class:`.ForeignKeyConstraint`.
         The callable accepts this parent :class:`.Table`, the
         target schema that we are changing to, the
         :class:`.ForeignKeyConstraint` object, and the existing
         "target schema" of that constraint.  The function should return the
         string schema name that should be applied.
         E.g.::

                def referred_schema_fn(table, to_schema,
                                                constraint, referred_schema):
                    if referred_schema == 'base_tables':
                        return referred_schema
                    else:
                        return to_schema

                new_table = table.tometadata(m2, schema="alt_schema",
                                        referred_schema_fn=referred_schema_fn)

         .. versionadded:: 0.9.2

        :param name: optional string name indicating the target table name.
         If not specified or None, the table name is retained.  This allows
         a :class:`.Table` to be copied to the same :class:`.MetaData` target
         with a new name.

         .. versionadded:: 1.0.0

        NzBTable '%s' already exists within the given MetaData - not copying.)r)rrh)rr&csg|]}t|����qSr)r()r��expr)r,r!rrr��sz$Table.tometadata.<locals>.<listcomp>)�unique�_table)r�
RETAIN_SCHEMArrrRr�warnr�r��appendr7rFrhr0rnr�ForeignKeyConstraint�_referred_schemar��_type_bound�_column_flagrm�Index�expressionsr�r9)r,r\rZreferred_schema_fnrr"r-r#Zreferred_schemaZfk_constraint_schema�indexr)r,r!r�
tometadatalsXG





zTable.tometadata)rTN)TF)N)NF)NF)%r>r?r@rArBr�deprecated_paramsrLrCrDr^r_rWrvr�r�rUrur�r�r�r"r4r�r}r�r�r�r�r�r1r�r�r�r�r��
__classcell__rr)ryrrF�sP>I

6





rFcs�eZdZdZdZ�fdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zddd�Zddd�Z�ZS)r z(Represents a column in a database table.r�cs*|�dd�}|�dd�}t|�}|rPt|dtj�rP|dk	rFt�d��|�d�}|r�|d}t|d�r�|dk	rxt�d��|�d�}|dk	r�t||�dd��}nd|kr�t�d	��t	t
|��||�|�d
|�|_|�dd�|_
|�d
|j
�|_|�dd�|_|�dd�|_|�dd�|_|�dd�|_|�dd�|_|�dd�|_|�dd�|_|�dd�|_|�dd�|_t�|_t�|_|�dd�|_d|k�r�|�d�|_nt|jt��r�|j�|�|jdk	�r0t|jt t!f��r�|�"|j�nFt#|jdd��r t|jtj$��r t�%d|j|jf�|�"t |j��|jdk	�rnt|jt&��r^|�"|j�'d��n|�"t(|j��|jdk	�r�t|jt t!f��r�|�"|j�n|�"t |jdd��|jdk	�r�t|jt&��r�|�"|j�'d��n|�"t(|jdd��|j)|�t�*|�d|k�r|�d�|_+|j,f|�dS)a#4
        Construct a new ``Column`` object.

        :param name: The name of this column as represented in the database.
          This argument may be the first positional argument, or specified
          via keyword.

          Names which contain no upper case characters
          will be treated as case insensitive names, and will not be quoted
          unless they are a reserved word.  Names with any number of upper
          case characters will be quoted and sent exactly.  Note that this
          behavior applies even for databases which standardize upper
          case names as case insensitive such as Oracle.

          The name field may be omitted at construction time and applied
          later, at any time before the Column is associated with a
          :class:`.Table`.  This is to support convenient
          usage within the :mod:`~sqlalchemy.ext.declarative` extension.

        :param type\_: The column's type, indicated using an instance which
          subclasses :class:`~sqlalchemy.types.TypeEngine`.  If no arguments
          are required for the type, the class of the type can be sent
          as well, e.g.::

            # use a type with arguments
            Column('data', String(50))

            # use no arguments
            Column('level', Integer)

          The ``type`` argument may be the second positional argument
          or specified by keyword.

          If the ``type`` is ``None`` or is omitted, it will first default to
          the special type :class:`.NullType`.  If and when this
          :class:`.Column` is made to refer to another column using
          :class:`.ForeignKey` and/or :class:`.ForeignKeyConstraint`, the type
          of the remote-referenced column will be copied to this column as
          well, at the moment that the foreign key is resolved against that
          remote :class:`.Column` object.

          .. versionchanged:: 0.9.0
            Support for propagation of type to a :class:`.Column` from its
            :class:`.ForeignKey` object has been improved and should be
            more reliable and timely.

        :param \*args: Additional positional arguments include various
          :class:`.SchemaItem` derived constructs which will be applied
          as options to the column.  These include instances of
          :class:`.Constraint`, :class:`.ForeignKey`, :class:`.ColumnDefault`,
          and :class:`.Sequence`.  In some cases an equivalent keyword
          argument is available such as ``server_default``, ``default``
          and ``unique``.

        :param autoincrement: Set up "auto increment" semantics for an integer
          primary key column.  The default value is the string ``"auto"``
          which indicates that a single-column primary key that is of
          an INTEGER type with no stated client-side or python-side defaults
          should receive auto increment semantics automatically;
          all other varieties of primary key columns will not.  This
          includes that :term:`DDL` such as PostgreSQL SERIAL or MySQL
          AUTO_INCREMENT will be emitted for this column during a table
          create, as well as that the column is assumed to generate new
          integer primary key values when an INSERT statement invokes which
          will be retrieved by the dialect.

          The flag may be set to ``True`` to indicate that a column which
          is part of a composite (e.g. multi-column) primary key should
          have autoincrement semantics, though note that only one column
          within a primary key may have this setting.    It can also
          be set to ``True`` to indicate autoincrement semantics on a
          column that has a client-side or server-side default configured,
          however note that not all dialects can accommodate all styles
          of default as an "autoincrement".  It can also be
          set to ``False`` on a single-column primary key that has a
          datatype of INTEGER in order to disable auto increment semantics
          for that column.

          .. versionchanged:: 1.1 The autoincrement flag now defaults to
             ``"auto"`` which indicates autoincrement semantics by default
             for single-column integer primary keys only; for composite
             (multi-column) primary keys, autoincrement is never implicitly
             enabled; as always, ``autoincrement=True`` will allow for
             at most one of those columns to be an "autoincrement" column.
             ``autoincrement=True`` may also be set on a :class:`.Column`
             that has an explicit client-side or server-side default,
             subject to limitations of the backend database and dialect.


          The setting *only* has an effect for columns which are:

          * Integer derived (i.e. INT, SMALLINT, BIGINT).

          * Part of the primary key

          * Not referring to another column via :class:`.ForeignKey`, unless
            the value is specified as ``'ignore_fk'``::

                # turn on autoincrement for this column despite
                # the ForeignKey()
                Column('id', ForeignKey('other.id'),
                            primary_key=True, autoincrement='ignore_fk')

            It is typically not desirable to have "autoincrement" enabled on a
            column that refers to another via foreign key, as such a column is
            required to refer to a value that originates from elsewhere.

          The setting has these two effects on columns that meet the
          above criteria:

          * DDL issued for the column will include database-specific
            keywords intended to signify this column as an
            "autoincrement" column, such as AUTO INCREMENT on MySQL,
            SERIAL on PostgreSQL, and IDENTITY on MS-SQL.  It does
            *not* issue AUTOINCREMENT for SQLite since this is a
            special SQLite flag that is not required for autoincrementing
            behavior.

            .. seealso::

                :ref:`sqlite_autoincrement`

          * The column will be considered to be available using an
            "autoincrement" method specific to the backend database, such
            as calling upon ``cursor.lastrowid``, using RETURNING in an
            INSERT statement to get at a sequence-generated value, or using
            special functions such as "SELECT scope_identity()".
            These methods are highly specific to the DBAPIs and databases in
            use and vary greatly, so care should be taken when associating
            ``autoincrement=True`` with a custom default generation function.


        :param default: A scalar, Python callable, or
            :class:`.ColumnElement` expression representing the
            *default value* for this column, which will be invoked upon insert
            if this column is otherwise not specified in the VALUES clause of
            the insert. This is a shortcut to using :class:`.ColumnDefault` as
            a positional argument; see that class for full detail on the
            structure of the argument.

            Contrast this argument to :paramref:`.Column.server_default`
            which creates a default generator on the database side.

            .. seealso::

                :ref:`metadata_defaults_toplevel`

        :param doc: optional String that can be used by the ORM or similar
            to document attributes on the Python side.   This attribute does
            **not** render SQL comments; use the :paramref:`.Column.comment`
            parameter for this purpose.

        :param key: An optional string identifier which will identify this
            ``Column`` object on the :class:`.Table`. When a key is provided,
            this is the only identifier referencing the ``Column`` within the
            application, including ORM attribute mapping; the ``name`` field
            is used only when rendering SQL.

        :param index: When ``True``, indicates that the column is indexed.
            This is a shortcut for using a :class:`.Index` construct on the
            table. To specify indexes with explicit names or indexes that
            contain multiple columns, use the :class:`.Index` construct
            instead.

        :param info: Optional data dictionary which will be populated into the
            :attr:`.SchemaItem.info` attribute of this object.

        :param nullable: When set to ``False``, will cause the "NOT NULL"
            phrase to be added when generating DDL for the column.   When
            ``True``, will normally generate nothing (in SQL this defaults to
            "NULL"), except in some very specific backend-specific edge cases
            where "NULL" may render explicitly.   Defaults to ``True`` unless
            :paramref:`~.Column.primary_key` is also ``True``, in which case it
            defaults to ``False``.  This parameter is only used when issuing
            CREATE TABLE statements.

        :param onupdate: A scalar, Python callable, or
            :class:`~sqlalchemy.sql.expression.ClauseElement` representing a
            default value to be applied to the column within UPDATE
            statements, which will be invoked upon update if this column is not
            present in the SET clause of the update. This is a shortcut to
            using :class:`.ColumnDefault` as a positional argument with
            ``for_update=True``.

            .. seealso::

                :ref:`metadata_defaults` - complete discussion of onupdate

        :param primary_key: If ``True``, marks this column as a primary key
            column. Multiple columns can have this flag set to specify
            composite primary keys. As an alternative, the primary key of a
            :class:`.Table` can be specified via an explicit
            :class:`.PrimaryKeyConstraint` object.

        :param server_default: A :class:`.FetchedValue` instance, str, Unicode
            or :func:`~sqlalchemy.sql.expression.text` construct representing
            the DDL DEFAULT value for the column.

            String types will be emitted as-is, surrounded by single quotes::

                Column('x', Text, server_default="val")

                x TEXT DEFAULT 'val'

            A :func:`~sqlalchemy.sql.expression.text` expression will be
            rendered as-is, without quotes::

                Column('y', DateTime, server_default=text('NOW()'))

                y DATETIME DEFAULT NOW()

            Strings and text() will be converted into a
            :class:`.DefaultClause` object upon initialization.

            Use :class:`.FetchedValue` to indicate that an already-existing
            column will generate a default value on the database side which
            will be available to SQLAlchemy for post-fetch after inserts. This
            construct does not specify any DDL and the implementation is left
            to the database, such as via a trigger.

            .. seealso::

                :ref:`server_defaults` - complete discussion of server side
                defaults

        :param server_onupdate:   A :class:`.FetchedValue` instance
             representing a database-side default generation function,
             such as a trigger. This
             indicates to SQLAlchemy that a newly generated value will be
             available after updates. This construct does not actually
             implement any kind of generation function within the database,
             which instead must be specified separately.

            .. seealso::

                :ref:`triggered_columns`

        :param quote: Force quoting of this column's name on or off,
             corresponding to ``True`` or ``False``. When left at its default
             of ``None``, the column identifier will be quoted according to
             whether the name is case sensitive (identifiers with at least one
             upper case character are treated as case sensitive), or if it's a
             reserved word. This flag is only needed to force quoting of a
             reserved word which is not known by the SQLAlchemy dialect.

        :param unique: When ``True``, indicates that this column contains a
             unique constraint, or if ``index`` is ``True`` as well, indicates
             that the :class:`.Index` should be created with the unique flag.
             To specify multiple columns in the constraint/index or to specify
             an explicit name, use the :class:`.UniqueConstraint` or
             :class:`.Index` constructs explicitly.

        :param system: When ``True``, indicates this is a "system" column,
             that is a column which is automatically made available by the
             database, and should not be included in the columns list for a
             ``CREATE TABLE`` statement.

             For more elaborate scenarios where columns should be
             conditionally rendered differently on different backends,
             consider custom compilation rules for :class:`.CreateColumn`.

        :param comment: Optional string that will render an SQL comment on
             table creation.

             .. versionadded:: 1.2 Added the :paramref:`.Column.comment`
                parameter to :class:`.Column`.


        rN�type_rz0May not pass name positionally and as a keyword.Z
_sqla_typez1May not pass type_ positionally and as a keyword.r5z9Explicit 'name' is required when sending 'quote' argumentr"r�F�nullable�default�server_default�server_onupdater�r��system�doc�onupdate�
autoincrement�autorh�_proxiesZ_warn_on_bytestringz?Unicode column '%s' has non-unicode default value %r specified.T)�
for_updater2)-rPr�rr�string_typesrrQ�hasattrrrkr r_r"r�r�r�r�r�r�r�r�r�r�r�rlrnrqrhr��typer
r+�
ColumnDefault�Sequencer�r�Zbinary_typer��FetchedValue�_as_for_update�
DefaultClauser/�set_creation_orderr2ru)r,r-r0rr�Zcoltype)ryrrr_�s�






zColumn.__init__cKs|�|�dS)N)r�)r,r0rrrrujszColumn._extra_kwargscCsD|jdkrdS|jdk	r:|jjr2|jjd|jS|jSn|jSdS)Nz	(no name)r)rr!Znamed_with_columnr�)r,rrrr�qs

zColumn.__str__cCs,x&|jD]}|jj�|j�rdSqWdSdS)zOReturn True if this Column references the given column via foreign
        key.TFN)rqr�Z	proxy_set�intersection)r,r��fkrrr�
references|szColumn.referencescCs|�|�dS)N)r+)r,r�rrr�append_foreign_key�szColumn.append_foreign_keycs�g}�j�jkr|�d��jr*|�d��js:|�d��jrJ|�d��jrZ|�d��jrj|�d�dd�t	�j�gt	�j
�gd	d
��jD�dd
��jD��j
dk	r�d�j
jp�d
g�fdd
�|D��S)Nr"r�r�r�r�r�z
Column(%s)z, cSsg|]}|dk	rt|��qS)N)r�)r�r�rrrr��sz#Column.__repr__.<locals>.<listcomp>cSsg|]}t|��qSr)r�)r�r�rrrr��sz
table=<%s>z
table=Nonecs"g|]}d|tt�|��f�qS)z%s=%s)r�r�)r�r�)r,rrr��s)r"rr�r�r�r�r�r�r�r�r�rqrnr!r�)r,�kwargr)r,rr4�s





zColumn.__repr__csz|jst�d��|jdkr"|j|_t|dd�}|dk	rT|�k	rTt�d|j|jf��|j�jkr��j�|j�}||k	r�x4|jD]*}�j�	|�|j
�jkr~�j�	|j
�q~W�j�|�|j
r̈j
�|�n"|j�j
kr�t�d|j�jf���|_|j�r.t|jtj��rt�d��td|t|j�dd�n6|j�rdt|jtj��rPt�d����t|jdd	��|��fd
d��dS)NzfColumn must be constructed with a non-blank name or assign a non-blank .name before adding to a Table.r!z1Column object '%s' already assigned to Table '%s'zTTrying to redefine primary-key column '%s' as a non-primary-key column on table '%s'z�The 'index' keyword argument on Column is boolean only. To create indexes with a specific name, create an explicit Index object external to the Table.T)r�r�z�The 'unique' keyword argument on Column is boolean only. To create unique constraints or indexes with a specific name, append an explicit UniqueConstraint to the Table's list of elements, or create an explicit Index object external to the Table.)r�cs
|���S)N)�_set_remote_table)r�)r!rrr~�rz$Column._set_parent.<locals>.<lambda>)rrrQr"r�r�ror:rqr�r�rnr'r��_replacersr!r�rrr�r�rSr�r��UniqueConstraint�_setup_on_memoized_fks)r,r!�existingr$r�r)r!rr��sJ
zColumn._set_parentcCsr|jj|jfdf|jj|jfdfg}xH|D]@\}}||jjjkr*x(|jjj|D]}|j|krP||�qPWq*WdS)NFT)r!r"rr\�	_fk_memos�link_to_name)r,rxZfk_keys�fk_keyr�r�rrrr��s
zColumn._setup_on_memoized_fkscCs*|jdk	r|||j�nt�|d|�dS)NrX)r!rrt)r,rxrrr�_on_table_attach�s
zColumn._on_table_attachcs��fdd�|jD��fdd�|jD�}|j}t|t�rD|jf��}|j||j||j|j	|j
|j|j|j
|j|j|j|j|j|j|jd��}|�|�S)ziCreate a copy of this ``Column``, uninitialized.

        This is used in ``Table.tometadata``.

        csg|]}|js|jf���qSr)r�r7)r�r#)r[rrr��szColumn.copy.<locals>.<listcomp>csg|]}|js|jf���qSr)r�r7)r�r#)r[rrr�s)rr�r"r�r�r�r�r�r�r�r�r�r�r�rh)rnrqr�rr
r7�_constructorrr"r�r�r�r�r�r�r�r�r�r�r�rhr9)r,r[r-r�r#r)r[rr7�s	
DzColumn.copyNFcKs�dd�|jD�}|dkr,|jdkr,t�d��yT|j|rDt|p@|j�n|pL|j|jf|�|r^|n|rf|n|j|j|j	|gd��}Wn(t
k
r�t�t
d|j
��YnX||_|j�|�|jdk	r�|jj|j|_|jr�|j�|�|j�||�|S)a$Create a *proxy* for this column.

        This is a copy of this ``Column`` referenced by a different parent
        (such as an alias or select statement).  The column should
        be used only in select scenarios, as its full DDL/default
        information is not transferred.

        cSsg|]}t|j|jd��qS))�_constraint)�
ForeignKeyr�r�)r��frrrr�'sz&Column._make_proxy.<locals>.<listcomp>Nz^Cannot initialize a sub-selectable with this Column object until its 'name' has been assigned.)r"r�r�r�z�Could not create a copy of this %r object.  Ensure the class includes a _constructor() attribute or method which accepts the standard Column constructor arguments, or references the Column class itself.)rqrrrTr�rr�r"r�r�rNrZraise_from_causeryr!ror�Z_is_clone_ofr�r8rX)r,�
selectablerr"Zname_is_truncatabler[r�r#rrr�_make_proxys0
0
zColumn._make_proxycKs@|r.dd�|j|jfD�t|j�t|j�Stj|f|�SdS)NcSsg|]}|dk	r|�qS)Nr)r�r�rrrr�Ssz'Column.get_children.<locals>.<listcomp>)r�r�r�rqrnrr1)r,r�r0rrrr1Ps*zColumn.get_children)NNF)F)r>r?r@rArBr_rur�r�r�r4r�r�r�r7r�r1r�rr)ryrr �s r
?&
4r c
@s�eZdZdZdZd'dd�Zdd�Zd(d	d
�Zd)dd�Ze	d
d��Z
dd�Ze	e�Zdd�Z
dd�Zejdd��Zdd�Zdd�Zdd�Zejdd��Zdd �Zd!d"�Zd#d$�Zd%d&�ZdS)*r�a�Defines a dependency between two columns.

    ``ForeignKey`` is specified as an argument to a :class:`.Column` object,
    e.g.::

        t = Table("remote_table", metadata,
            Column("remote_id", ForeignKey("main_table.id"))
        )

    Note that ``ForeignKey`` is only a marker object that defines
    a dependency between two columns.   The actual constraint
    is in all cases represented by the :class:`.ForeignKeyConstraint`
    object.   This object will be generated automatically when
    a ``ForeignKey`` is associated with a :class:`.Column` which
    in turn is associated with a :class:`.Table`.   Conversely,
    when :class:`.ForeignKeyConstraint` is applied to a :class:`.Table`,
    ``ForeignKey`` markers are automatically generated to be
    present on each associated :class:`.Column`, which are also
    associated with the constraint object.

    Note that you cannot define a "composite" foreign key constraint,
    that is a constraint between a grouping of multiple parent/child
    columns, using ``ForeignKey`` objects.   To define this grouping,
    the :class:`.ForeignKeyConstraint` object must be used, and applied
    to the :class:`.Table`.   The associated ``ForeignKey`` objects
    are created automatically.

    The ``ForeignKey`` objects associated with an individual
    :class:`.Column` object are available in the `foreign_keys` collection
    of that column.

    Further examples of foreign key configuration are in
    :ref:`metadata_foreignkeys`.

    Zforeign_keyNFc
Ks�||_t|jtj�rd|_nft|jd�r6|j��|_n|j|_t|jt�s\t�	d|j��n&t|jj
tjtf�s�t�	d|jj
��||_
d|_||_||_||_||_||_||_|	|_|
|_|r�||_||_dS)a9
        Construct a column-level FOREIGN KEY.

        The :class:`.ForeignKey` object when constructed generates a
        :class:`.ForeignKeyConstraint` which is associated with the parent
        :class:`.Table` object's collection of constraints.

        :param column: A single target column for the key relationship. A
            :class:`.Column` object or a column name as a string:
            ``tablename.columnkey`` or ``schema.tablename.columnkey``.
            ``columnkey`` is the ``key`` which has been assigned to the column
            (defaults to the column name itself), unless ``link_to_name`` is
            ``True`` in which case the rendered name of the column is used.

        :param name: Optional string. An in-database name for the key if
            `constraint` is not provided.

        :param onupdate: Optional string. If set, emit ON UPDATE <value> when
            issuing DDL for this constraint. Typical values include CASCADE,
            DELETE and RESTRICT.

        :param ondelete: Optional string. If set, emit ON DELETE <value> when
            issuing DDL for this constraint. Typical values include CASCADE,
            DELETE and RESTRICT.

        :param deferrable: Optional bool. If set, emit DEFERRABLE or NOT
            DEFERRABLE when issuing DDL for this constraint.

        :param initially: Optional string. If set, emit INITIALLY <value> when
            issuing DDL for this constraint.

        :param link_to_name: if True, the string name given in ``column`` is
            the rendered name of the referenced column, not its locally
            assigned ``key``.

        :param use_alter: passed to the underlying
            :class:`.ForeignKeyConstraint` to indicate the constraint should
            be generated/dropped externally from the CREATE TABLE/ DROP TABLE
            statement.  See :paramref:`.ForeignKeyConstraint.use_alter`
            for further description.

            .. seealso::

                :paramref:`.ForeignKeyConstraint.use_alter`

                :ref:`use_alter`

        :param match: Optional string. If set, emit MATCH <value> when issuing
            DDL for this constraint. Typical values include SIMPLE, PARTIAL
            and FULL.

        :param info: Optional data dictionary which will be populated into the
            :attr:`.SchemaItem.info` attribute of this object.

            .. versionadded:: 1.0.0

        :param \**dialect_kw:  Additional keyword arguments are dialect
            specific, and passed in the form ``<dialectname>_<argname>``.  The
            arguments are ultimately handled by a corresponding
            :class:`.ForeignKeyConstraint`.  See the documentation regarding
            an individual dialect at :ref:`dialect_toplevel` for detail on
            documented arguments.

            .. versionadded:: 0.9.2

        N�__clause_element__z9String, Column, or Column-bound argument expected, got %rz8ForeignKey received Column not bound to a Table, got: %r)�_colspecrrr��
_table_columnr�r�rrrQr!ZNoneTyperr��parent�	use_alterrr��ondelete�
deferrable�	initiallyr��matchr2�_unvalidated_dialect_kw)
r,r�r�r�rr�r�r�r�r�r�r2�
dialect_kwrrrr_�s8RzForeignKey.__init__cCsd|��S)NzForeignKey(%r))�_get_colspec)r,rrrr4�szForeignKey.__repr__cCsFt|j|d�f|j|j|j|j|j|j|j|j	d�|j
��}|�|�S)a�Produce a copy of this :class:`.ForeignKey` object.

        The new :class:`.ForeignKey` will not be bound
        to any :class:`.Column`.

        This method is usually used by the internal
        copy procedures of :class:`.Column`, :class:`.Table`,
        and :class:`.MetaData`.

        :param schema: The returned :class:`.ForeignKey` will
          reference the original table and column name, qualified
          by the given string schema name.

        )r)r�rr�r�r�r�r�r�)r�r�r�rr�r�r�r�r�r�r�r9)r,rr�rrrr7s
zForeignKey.copycCs�|r*|j\}}}|dk	r|}d|||fS|rZ|j\}}}|rLd|||fSd||fSn&|jdk	rzd|jjj|jjfS|jSdS)z�Return a string based 'column specification' for this
        :class:`.ForeignKey`.

        This is usually the equivalent of the string-based "tablename.colname"
        argument first passed to the object's constructor.

        Nz%s.%s.%sz%s.%s)�_column_tokensr�r!rsr"r�)r,r�
table_nameZ_schema�tname�colnamerrrr�s
zForeignKey._get_colspeccCs
|jdS)Nr)r�)r,rrrr�9szForeignKey._referred_schemacCs@|jdk	r&|jjdkrdS|jjjSn|j\}}}t||�SdS)N)r�r!r"r�r)r,rr�r�rrr�
_table_key=s
zForeignKey._table_keycCs|�|j�dk	S)z\Return True if the given :class:`.Table` is referenced by this
        :class:`.ForeignKey`.N)�corresponding_columnr�)r,r!rrrr�IszForeignKey.referencescCs|�|j�S)z�Return the :class:`.Column` in the given :class:`.Table`
        referenced by this :class:`.ForeignKey`.

        Returns None if this :class:`.ForeignKey` does not reference the given
        :class:`.Table`.

        )r�r�)r,r!rrr�get_referentOs	zForeignKey.get_referentcCsv|���d�}|dkr&t�d|j��t|�dkr@|��}d}n|��}|��}t|�dkrhd�|�}nd}|||fS)z7parse a string-based _colspec into its component parts.rNz,Invalid foreign key column specification: %srr)r��splitrrQr��lenrPr�)r,�mr�r�rrrrr�ZszForeignKey._column_tokenscCs�|jdkrt�d��n|jjdkr,t�d��|jj}x2|jjD]}t|t�r>|j|ksZt�Pq>Wdsht�|j\}}}|dkr�|j	j
dk	r�|j	j
}t||�}|||fS)NzLthis ForeignKey object does not yet have a parent Column associated with it.zCthis ForeignKey's parent column is not yet associated with a Table.F)r�rrTr!Zbase_columnsrr �AssertionErrorr�r\rr)r,�parenttabler#rr�r��tablekeyrrr�_resolve_col_tokensys"


zForeignKey._resolve_col_tokenscCs�t|jd�s||j_n|jj|ks&t�d}|dkrL|j}|j�|jjd�}n<|jrv|}x0|jD]}|j	|kr^|}q^Wn|}|j�|d�}|dkr�t
�d|j|j	|j	|f|j	|��|�
|�dS)N�_referred_tableziCould not initialize target column for ForeignKey '%s' on table '%s': table '%s' has no column named '%s')r�r�rr�r�r#r:r"r�rr�NoReferencedColumnErrorr��_set_target_column)r,r�r!r��_columnr"r#rrr�_link_to_col_by_colstring�s*


z$ForeignKey._link_to_col_by_colstringcsD|jjjr�j|j_t|jjt�r:�fdd�}|j�|��|_dS)Ncs|jjjr�j|j_dS)N)r�r��_isnull)r�)r�rr�set_type�s
z/ForeignKey._set_target_column.<locals>.set_type)r�r�rrr!rFr�r�)r,r�rr)r�rr�s

zForeignKey._set_target_columncCs�t|jtj�r||��\}}}||jkr@t�d|j||f|��q�|j	|jkr\t�
d|��q�t�d|j|j||f||��n$t
|jd�r�|j��}|S|j}|SdS)a�Return the target :class:`.Column` referenced by this
        :class:`.ForeignKey`.

        If no target column has been established, an exception
        is raised.

        .. versionchanged:: 0.9.0
            Foreign key target column resolution now occurs as soon as both
            the ForeignKey object and the remote Column to which it refers
            are both associated with the same MetaData object.

        z|Foreign key associated with column '%s' could not find table '%s' with which to generate a foreign key to target column '%s'z9Table %s is no longer associated with its parent MetaDataziCould not initialize target column for ForeignKey '%s' on table '%s': table '%s' has no column named '%s'r�N)rr�rr�rr\rZNoReferencedTableErrorr�r"rTrrr�r�)r,r�rr�rrrrr��s*


zForeignKey.columncCsD|jdk	r|j|k	rt�d��||_|jj�|�|j�|j�dS)Nz&This ForeignKey already has a parent !)r�rrTrqr�r��
_set_table)r,r�rrrr�szForeignKey._set_parentcCs,|��\}}}|�|||�|j�|�dS)N)rrr��_validate_dest_table)r,r!r�rr�rrrr�	szForeignKey._set_remote_tablecCs8|��\}}}||f}||j|kr4|j|�|�dS)N)rr�r�)r,r\r��	table_keyr�r�rrr�_remove_from_metadatasz ForeignKey._remove_from_metadatac
Cs |jdkrbt|t�rbtggf|j|j|j|j|j|j	|j
d�|j��|_|j�||�|j�
|�|j�|�t|jtj�r�|��\}}}||f}||jjkr�|jj|}y|�|||�Wntjk
r�YnX|jj|�|�n4t|jd��r|j��}|�|�n|j}|�|�dS)N)r�rr�r�r�r�r�r�)r�rrFr�r�rr�r�r�r�r�r��_append_elementr+rqr�r�rr�rr\rRrrrr�r�r�r�r)r,r�r!r�rr�r�rrrrr	s<
zForeignKey._set_table)
NFNNNNNFNN)N)NN)r>r?r@rArBr_r4r7r�rCr�r�Ztarget_fullnamer�r�rrEr�rrrr�r�r�rr	rrrrr�[s:#
o


##0	r�c@s,eZdZdd�Zdd�ZZedd��ZdS)�_NotAColumnExprcCst�d|jj��dS)Nz7This %s cannot be used directly as a column expression.)rrTryr>)r,rrr�_not_a_column_expr@sz"_NotAColumnExpr._not_a_column_exprcCs|��S)N)r)r,rrrr~Frz_NotAColumnExpr.<lambda>cCs|��S)N)r)r,rrrr~GrN)r>r?r@rr�Z
self_grouprCZ
_from_objectsrrrrr?src@sPeZdZdZdZdZdZdZddd�Zdd�Z	dd	d
�Z
dd�Zed
d��Z
dS)�DefaultGeneratorz'Base class for column *default* values.Zdefault_generatorFNcCs
||_dS)N)r�)r,r�rrrr_SszDefaultGenerator.__init__cCs"||_|jr||j_n||j_dS)N)r�r�r�r�)r,r�rrrr�Vs
zDefaultGenerator._set_parentcKs|dkrt|�}|j|f|�S)N)r�_execute_default)r,r}r0rrr�execute]szDefaultGenerator.executecCs|�|||�S)N)r)r,r�Zmultiparams�paramsrrr�_execute_on_connectionbsz'DefaultGenerator._execute_on_connectioncCs"t|dd�dk	r|jjjSdSdS)z4Return the connectable associated with this default.r�N)r�r�r!r})r,rrrr}es
zDefaultGenerator.bind)F)N)r>r?r@rArB�is_sequence�is_server_defaultr�r_r�rrrCr}rrrrrJs

rcs�eZdZdZ�fdd�Zejdd��Zejdd��Zejdd	��Z	eje�
d
�dd���Zd
d�Zdd�Z
ee
�Zdd�Z�ZS)r�a�A plain default value on a column.

    This could correspond to a constant, a callable function,
    or a SQL clause.

    :class:`.ColumnDefault` is generated automatically
    whenever the ``default``, ``onupdate`` arguments of
    :class:`.Column` are used.  A :class:`.ColumnDefault`
    can be passed positionally as well.

    For example, the following::

        Column('foo', Integer, default=50)

    Is equivalent to::

        Column('foo', Integer, ColumnDefault(50))


    csDtt|�jf|�t|t�r&t�d��t�|�r:|�	|�}||_
dS)aj"Construct a new :class:`.ColumnDefault`.


        :param arg: argument representing the default value.
         May be one of the following:

         * a plain non-callable Python value, such as a
           string, integer, boolean, or other simple type.
           The default value will be used as is each time.
         * a SQL expression, that is one which derives from
           :class:`.ColumnElement`.  The SQL expression will
           be rendered into the INSERT or UPDATE statement,
           or in the case of a primary key column when
           RETURNING is not used may be
           pre-executed before an INSERT within a SELECT.
         * A Python callable.  The function will be invoked for each
           new row subject to an INSERT or UPDATE.
           The callable must accept exactly
           zero or one positional arguments.  The one-argument form
           will receive an instance of the :class:`.ExecutionContext`,
           which provides contextual information as to the current
           :class:`.Connection` in use as well as the current
           statement and parameters.

        z4ColumnDefault may not be a server-side default type.N)rkr�r_rr�rrQr�callable�_maybe_wrap_callable�arg)r,rr0)ryrrr_�s


zColumnDefault.__init__cCst�|j�S)N)rrr)r,rrr�is_callable�szColumnDefault.is_callablecCst|jt�S)N)rrr)r,rrr�is_clause_element�szColumnDefault.is_clause_elementcCs|jo|jo|jS)N)rrr)r,rrr�	is_scalar�szColumnDefault.is_scalarzsqlalchemy.sql.sqltypescCs |jrt|jj|j�SdSdS)NF)rrrr�ZNullType)r,Zsqltypesrrr�
_arg_is_typed�szColumnDefault._arg_is_typedcs�ytj�dd�}Wn$tk
r6t��fdd���SX|ddk	rPt|d�pRd}t|d�|}|dkr�t��fdd���S|d	kr��St�d
��dS)z�Wrap callables that don't accept a context.

        This is to allow easy compatibility with default callables
        that aren't specific to accepting of a context.

        T)Zno_selfcs��S)Nr)�ctx)rxrrr~�rz4ColumnDefault._maybe_wrap_callable.<locals>.<lambda>�Nrcs��S)Nr)r)rxrrr~�rrzDColumnDefault Python function takes zero or one positional arguments)rZget_callable_argspecrNZ
wrap_callabler�rrQ)r,rxZargspecZ	defaulted�positionalsr)rxrr�sz"ColumnDefault._maybe_wrap_callablecCs|jr
dSdSdS)NZcolumn_onupdateZcolumn_default)r�)r,rrr�_visit_name�szColumnDefault._visit_namecCsd|jfS)NzColumnDefault(%r))r)r,rrrr4�szColumnDefault.__repr__)r>r?r@rAr_rrErrr�dependenciesrrr!rCrBr4r�rr)ryrr�ns#r�cs�eZdZdZdZdZd�fdd�	Zejdd	��Z	ejd
d��Z
e�d�d
d��Z�fdd�Z
dd�Zdd�Zedd��Zddd�Zddd�Zdd�Z�ZS) r�a�Represents a named database sequence.

    The :class:`.Sequence` object represents the name and configurational
    parameters of a database sequence.   It also represents
    a construct that can be "executed" by a SQLAlchemy :class:`.Engine`
    or :class:`.Connection`, rendering the appropriate "next value" function
    for the target database and returning a result.

    The :class:`.Sequence` is typically associated with a primary key column::

        some_table = Table(
            'some_table', metadata,
            Column('id', Integer, Sequence('some_table_seq'),
            primary_key=True)
        )

    When CREATE TABLE is emitted for the above :class:`.Table`, if the
    target platform supports sequences, a CREATE SEQUENCE statement will
    be emitted as well.   For platforms that don't support sequences,
    the :class:`.Sequence` construct is ignored.

    .. seealso::

        :class:`.CreateSequence`

        :class:`.DropSequence`

    �sequenceTNFcs�tt|�j|d�t||
�|_||_||_||_||_||_	||_
||_|
|_||_
||_|	tkrnd|_}	n0|dk	r�|	dkr�|jr�|j|_}	nt|	|�|_||_t||	�|_|r�|�|�dS)a�Construct a :class:`.Sequence` object.

        :param name: The name of the sequence.
        :param start: the starting index of the sequence.  This value is
         used when the CREATE SEQUENCE command is emitted to the database
         as the value of the "START WITH" clause.   If ``None``, the
         clause is omitted, which on most platforms indicates a starting
         value of 1.
        :param increment: the increment value of the sequence.  This
         value is used when the CREATE SEQUENCE command is emitted to
         the database as the value of the "INCREMENT BY" clause.  If ``None``,
         the clause is omitted, which on most platforms indicates an
         increment of 1.
        :param minvalue: the minimum value of the sequence.  This
         value is used when the CREATE SEQUENCE command is emitted to
         the database as the value of the "MINVALUE" clause.  If ``None``,
         the clause is omitted, which on most platforms indicates a
         minvalue of 1 and -2^63-1 for ascending and descending sequences,
         respectively.

         .. versionadded:: 1.0.7

        :param maxvalue: the maximum value of the sequence.  This
         value is used when the CREATE SEQUENCE command is emitted to
         the database as the value of the "MAXVALUE" clause.  If ``None``,
         the clause is omitted, which on most platforms indicates a
         maxvalue of 2^63-1 and -1 for ascending and descending sequences,
         respectively.

         .. versionadded:: 1.0.7

        :param nominvalue: no minimum value of the sequence.  This
         value is used when the CREATE SEQUENCE command is emitted to
         the database as the value of the "NO MINVALUE" clause.  If ``None``,
         the clause is omitted, which on most platforms indicates a
         minvalue of 1 and -2^63-1 for ascending and descending sequences,
         respectively.

         .. versionadded:: 1.0.7

        :param nomaxvalue: no maximum value of the sequence.  This
         value is used when the CREATE SEQUENCE command is emitted to
         the database as the value of the "NO MAXVALUE" clause.  If ``None``,
         the clause is omitted, which on most platforms indicates a
         maxvalue of 2^63-1 and -1 for ascending and descending sequences,
         respectively.

         .. versionadded:: 1.0.7

        :param cycle: allows the sequence to wrap around when the maxvalue
         or minvalue has been reached by an ascending or descending sequence
         respectively.  This value is used when the CREATE SEQUENCE command
         is emitted to the database as the "CYCLE" clause.  If the limit is
         reached, the next number generated will be the minvalue or maxvalue,
         respectively.  If cycle=False (the default) any calls to nextval
         after the sequence has reached its maximum value will return an
         error.

         .. versionadded:: 1.0.7

        :param schema: Optional schema name for the sequence, if located
         in a schema other than the default.  The rules for selecting the
         schema name when a :class:`.MetaData` is also present are the same
         as that of :paramref:`.Table.schema`.

        :param cache: optional integer value; number of future values in the
         sequence which are calculated in advance.  Renders the CACHE keyword
         understood by Oracle and PostgreSQL.

         .. versionadded:: 1.1.12

        :param order: optional boolean value; if true, renders the
         ORDER keyword, understood by Oracle, indicating the sequence is
         definitively ordered.   May be necessary to provide deterministic
         ordering using Oracle RAC.

         .. versionadded:: 1.1.12

        :param optional: boolean value, when ``True``, indicates that this
         :class:`.Sequence` object only needs to be explicitly generated
         on backends that don't provide another way to generate primary
         key identifiers.  Currently, it essentially means, "don't create
         this sequence on the PostgreSQL backend, where the SERIAL keyword
         creates a sequence for us automatically".
        :param quote: boolean value, when ``True`` or ``False``, explicitly
         forces quoting of the schema name on or off.  When left at its
         default of ``None``, normal quoting rules based on casing and
         reserved words take place.
        :param quote_schema: set the quoting preferences for the ``schema``
         name.

        :param metadata: optional :class:`.MetaData` object which this
         :class:`.Sequence` will be associated with.  A :class:`.Sequence`
         that is associated with a :class:`.MetaData` gains the following
         capabilities:

         * The :class:`.Sequence` will inherit the :paramref:`.MetaData.schema`
           parameter specified to the target :class:`.MetaData`, which
           affects the production of CREATE / DROP DDL, if any.

         * The :meth:`.Sequence.create` and :meth:`.Sequence.drop` methods
           automatically use the engine bound to the :class:`.MetaData`
           object, if any.

         * The :meth:`.MetaData.create_all` and :meth:`.MetaData.drop_all`
           methods will emit CREATE / DROP for this :class:`.Sequence`,
           even if the :class:`.Sequence` is not associated with any
           :class:`.Table` / :class:`.Column` that's a member of this
           :class:`.MetaData`.

         The above behaviors can only occur if the :class:`.Sequence` is
         explicitly associated with the :class:`.MetaData` via this parameter.

         .. seealso::

            :ref:`sequence_metadata` - full discussion of the
            :paramref:`.Sequence.metadata` parameter.

        :param for_update: Indicates this :class:`.Sequence`, when associated
         with a :class:`.Column`, should be invoked for UPDATE statements
         on that column's table, rather than for INSERT statements, when
         no value is otherwise present for that column in the statement.

        )r�N)rkr�r_rr�start�	increment�minvalue�maxvalue�
nominvalue�
nomaxvalue�cycle�cache�order�optionalrOrr\r�_key�
_set_metadata)r,rr$r%r&r'r(r)r*rr+r,r-r5r\r^r�)ryrrr_	s,zSequence.__init__cCsdS)NFr)r,rrrr�	szSequence.is_callablecCsdS)NFr)r,rrrr�	szSequence.is_clause_elementzsqlalchemy.sql.functions.funccCs|j||jd�S)z�Return a :class:`.next_value` function element
        which will render the appropriate increment function
        for this :class:`.Sequence` within any SQL expression.

        )r})�
next_valuer})r,�funcrrrr0�	szSequence.next_valuecs tt|��|�|�|j�dS)N)rkr�r�r�r	)r,r�)ryrrr��	szSequence._set_parentcCs|�|j�dS)N)r/r\)r,r�r!rrrr	�	szSequence._set_tablecCs||_||jj|j<dS)N)r\�
_sequencesr.)r,r\rrrr/�	szSequence._set_metadatacCs|jr|jjSdSdS)N)r\r})r,rrrr}�	sz
Sequence.bindcCs&|dkrt|�}|jtj||d�dS)z&Creates this sequence in the database.N)r�)rr�rr�)r,r}r�rrrr��	szSequence.createcCs&|dkrt|�}|jtj||d�dS)z&Drops this sequence from the database.N)r�)rr�rr�)r,r}r�rrrr��	sz
Sequence.dropcCst�d|jj��dS)Nz�This %s cannot be used directly as a column expression.  Use func.next_value(sequence) to produce a 'next value' function that's usable as a column element.)rrTryr>)r,rrrr�	szSequence._not_a_column_expr)NNNNNNNNNNFNNNF)NT)NT)r>r?r@rArBrr_rrErrr"r0r�r	r/rCr}r�r�rr�rr)ryrr��s:	

r�c@sFeZdZdZdZdZdZddd�Zdd�Zdd	�Z	d
d�Z
dd
�ZdS)r�a�A marker for a transparent database-side default.

    Use :class:`.FetchedValue` when the database is configured
    to provide some automatic default for a column.

    E.g.::

        Column('foo', Integer, FetchedValue())

    Would indicate that some trigger or default generator
    will create a new value for the ``foo`` column during an
    INSERT.

    .. seealso::

        :ref:`triggered_columns`

    TFcCs
||_dS)N)r�)r,r�rrrr_
szFetchedValue.__init__cCs||jkr|S|�|�SdS)N)r��_clone)r,r�rrrr�
s
zFetchedValue._as_for_updatecCs4|j�|j�}|j�|j�|j�dd�||_|S)Nr�)ryrLr6�updaterPr�)r,r��nrrrr3	
s
zFetchedValue._clonecCs"||_|jr||j_n||j_dS)N)r�r�r�r�)r,r�rrrr�
s
zFetchedValue._set_parentcCs
t�|�S)N)rr3)r,rrrr4
szFetchedValue.__repr__N)F)r>r?r@rAr�	reflected�has_argumentr_r�r3r�r4rrrrr��	s
r�cs.eZdZdZdZd�fdd�	Zdd�Z�ZS)	r�a7A DDL-specified DEFAULT column value.

    :class:`.DefaultClause` is a :class:`.FetchedValue`
    that also generates a "DEFAULT" clause when
    "CREATE TABLE" is emitted.

    :class:`.DefaultClause` is generated automatically
    whenever the ``server_default``, ``server_onupdate`` arguments of
    :class:`.Column` are used.  A :class:`.DefaultClause`
    can be passed positionally as well.

    For example, the following::

        Column('foo', Integer, server_default="50")

    Is equivalent to::

        Column('foo', Integer, DefaultClause("50"))

    TFcs:t�|tjdttfd�tt|��|�||_||_	dS)Nrr)
rZassert_arg_typer�rrrkr�r_rr6)r,rr�Z
_reflected)ryrrr_3
s
zDefaultClause.__init__cCsd|j|jfS)Nz DefaultClause(%r, for_update=%r))rr�)r,rrrr4;
szDefaultClause.__repr__)FF)r>r?r@rAr7r_r4r�rr)ryrr�
sr�z0.6zy:class:`.PassiveDefault` is deprecated and will be removed in a future release.  Please refer to :class:`.DefaultClause`.c@seZdZdZdd�ZdS)�PassiveDefaultz*A DDL-specified DEFAULT column value.
    cOstj|f|�|�dS)N)r�r_)r,rr[rrrr_H
szPassiveDefault.__init__N)r>r?r@rAr_rrrrr8?
sr8c@s:eZdZdZdZd
dd�Zedd��Zd	d
�Zdd�Z	dS)�
ConstraintzA table-level SQL constraint.r�NFcKs@||_||_||_|r||_||_||_t�|�|�|�dS)a�Create a SQL constraint.

        :param name:
          Optional, the in-database name of this ``Constraint``.

        :param deferrable:
          Optional bool.  If set, emit DEFERRABLE or NOT DEFERRABLE when
          issuing DDL for this constraint.

        :param initially:
          Optional string.  If set, emit INITIALLY <value> when issuing DDL
          for this constraint.

        :param info: Optional data dictionary which will be populated into the
            :attr:`.SchemaItem.info` attribute of this object.

            .. versionadded:: 1.0.0

        :param _create_rule:
          a callable which is passed the DDLCompiler object during
          compilation. Returns True or False to signal inline generation of
          this Constraint.

          The AddConstraint and DropConstraint DDL constructs provide
          DDLElement's more comprehensive "conditional DDL" approach that is
          passed a database connection when DDL is being issued. _create_rule
          is instead called during any CREATE TABLE compilation, where there
          may not be any transaction/connection in progress. However, it
          allows conditional compilation of the constraint even for backends
          which do not support addition of constraints through ALTER TABLE,
          which currently includes SQLite.

          _create_rule is used by some types to create constraints.
          Currently, its call signature is subject to change at any time.

        :param \**dialect_kw:  Additional keyword arguments are dialect
            specific, and passed in the form ``<dialectname>_<argname>``.  See
            the documentation regarding an individual dialect at
            :ref:`dialect_toplevel` for detail on documented arguments.

        N)	rr�r�r2�_create_ruler�rr�r�)r,rr�r�r:r2r�r�rrrr_Q
s4
zConstraint.__init__cCs:yt|jt�r|jSWntk
r*YnXt�d��dS)NzdThis constraint is not bound to a table.  Did you mean to call table.append_constraint(constraint) ?)rr�rF�AttributeErrorrrT)r,rrrr!�
s
zConstraint.tablecCs||_|j�|�dS)N)r�rnr�)r,r�rrrr��
szConstraint._set_parentcKs
t��dS)N)�NotImplementedError)r,r[rrrr7�
szConstraint.copy)NNNNNF)
r>r?r@rArBr_rCr!r�r7rrrrr9L
s
7r9cCs*t|d�r|��}t|t�s&t�d��|S)Nr�zschema.Column object expected)r�r�rr rrQ)�elementrrr�_to_schema_column�
s



r>cCs:t|d�r|��}t|tjtf�s6d}t�||��|S)Nr�z1Element %r is not a string name or column element)r�r�rrr�rrrQ)r=r]rrr�_to_schema_column_or_string�
s
r?c@s:eZdZdZdZdd�Zedd��Zddd�Zd	d
�Z	dS)�ColumnCollectionMixinNFcOsH|�dd�}|�dd�|_t�|_dd�|D�|_|rD|jrD|��dS)N�_autoattachTr�FcSsg|]}t|��qSr)r?)r�r#rrrr��
sz2ColumnCollectionMixin.__init__.<locals>.<listcomp>)rPr�rr��_pending_colargs�
_check_attach)r,r�r[rArrrr_�
s
zColumnCollectionMixin.__init__ccs�x||D]t}d}d}t|d�r$|��}t|ttf�s8|}n$g}t�|id|ji�|r\|d}|dk	rh|n|}||||fVqWdS)Nr�r�r)r�r�rrrr�traverser�)rZr�r��strnamer��cols�add_elementrrr�"_extract_col_expression_collection�
s

z8ColumnCollectionMixin._extract_col_expression_collectionc
sdd��jD�}dd�|D�}t|��|���r�|r<td��t�j��|�}|s���fdd�}��_x�D]}|�|�qjWdS|}dd�|D�}t|�d	kr���|���ndt|�d	k�r�j	�s|d
j
��fdd�|d	d�D�}	|	�rt�dd
�
dd�|	D���jf��dS)NcSsg|]}t|t�r|�qSr)rr )r�r#rrrr��
sz7ColumnCollectionMixin._check_attach.<locals>.<listcomp>cSsg|]}t|jt�r|�qSr)rr!rF)r�r#rrrr��
sz#Should not reach here on event callcs(t|t�r$��|��s$�jdd�dS)NT)rw)rrF�discardrC)r�r!)�
cols_wo_tabler,rr�
_col_attached�
s

z:ColumnCollectionMixin._check_attach.<locals>._col_attachedcSsh|]
}|j�qSr)r!)r�r#rrr�	<setcomp>�
sz6ColumnCollectionMixin._check_attach.<locals>.<setcomp>rrcsg|]}|j�k	r|�qSr)r!)r�r#)r!rrr�sz(Column(s) %s are not part of table '%s'.z, css|]}d|VqdS)z'%s'Nr)r�r#rrrr�sz6ColumnCollectionMixin._check_attach.<locals>.<genexpr>)rBrl�
differencer�Z_cols_wo_tabler�r�r+rP�_allow_multiple_tablesr!rrQr�r�)
r,rwZcol_objsZcols_w_tableZhas_string_colsrKr$r�rRZothersr)rJr,r!rrC�
s0	

z#ColumnCollectionMixin._check_attachcCs6x0|jD]&}t|tj�r"|j|}|j�|�qWdS)N)rBrrr�r#r�r�)r,r!r$rrrr�
s
z!ColumnCollectionMixin._set_parent)F)
r>r?r@r�rNr_�classmethodrHrCr�rrrrr@�
s

0r@c@sLeZdZdZdd�ZdZdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�ZdS)�ColumnCollectionConstraintz-A constraint that proxies a ColumnCollection.cOsB|�dd�}|�dd�}tj|f|�tj|f|�||d��dS)aZ
        :param \*columns:
          A sequence of column names or Column objects.

        :param name:
          Optional, the in-database name of this constraint.

        :param deferrable:
          Optional bool.  If set, emit DEFERRABLE or NOT DEFERRABLE when
          issuing DDL for this constraint.

        :param initially:
          Optional string.  If set, emit INITIALLY <value> when issuing DDL
          for this constraint.

        :param \**kw: other keyword arguments including dialect-specific
          arguments are propagated to the :class:`.Constraint` superclass.

        rATr�F)rAr�N)rPr9r_r@)r,r�r[rAr�rrrr_s
z#ColumnCollectionConstraint.__init__NcCst�||�t�||�dS)N)r9r�r@)r,r!rrrr�8sz&ColumnCollectionConstraint._set_parentcCs
||jkS)N)r�)r,r�rrr�__contains__<sz'ColumnCollectionConstraint.__contains__cKs*|j|j��|j|j|jd��}|�|�S)N)rr�r�)ryr��keysrr�r�r9)r,r[r#rrrr7?szColumnCollectionConstraint.copycCs|j�|�S)z�Return True if this constraint contains the given column.

        Note that this object also contains an attribute ``.columns``
        which is a :class:`.ColumnCollection` of :class:`.Column` objects.

        )r��contains_column)r,r$rrrrSHsz*ColumnCollectionConstraint.contains_columncs|jj��fdd��jD�S)Nc3s|]}�|VqdS)Nr)r�r")�ordered_dictrrr�Wsz6ColumnCollectionConstraint.__iter__.<locals>.<genexpr>)r��_dataZ_list)r,r)rTr�__iter__Rsz#ColumnCollectionConstraint.__iter__cCst|jj�S)N)r�r�rU)r,rrr�__len__Ysz"ColumnCollectionConstraint.__len__)r>r?r@rAr_r�r�rQr7rSrVrWrrrrrPs	
rPc	sLeZdZdZdZeddd�d�fdd	�	�Zd
d�Zee�Zddd
�Z	�Z
S)�CheckConstraintzlA table- or column-level CHECK constraint.

    Can be included in the definition of a Table or Column.
    T�sqltextz:class:`.CheckConstraint`z$:paramref:`.CheckConstraint.sqltext`NFc

sdt|dd�|_g}t�|jid|ji�tt|�j|||||||	|d�|
��|dk	r`|�|�dS)a�Construct a CHECK constraint.

        :param sqltext:
         A string containing the constraint definition, which will be used
         verbatim, or a SQL expression construct.   If given as a string,
         the object is converted to a :func:`.text` object. If the textual
         string includes a colon character, escape this using a backslash::

           CheckConstraint(r"foo ~ E'a(?\:b|c)d")

        :param name:
          Optional, the in-database name of the constraint.

        :param deferrable:
          Optional bool.  If set, emit DEFERRABLE or NOT DEFERRABLE when
          issuing DDL for this constraint.

        :param initially:
          Optional string.  If set, emit INITIALLY <value> when issuing DDL
          for this constraint.

        :param info: Optional data dictionary which will be populated into the
            :attr:`.SchemaItem.info` attribute of this object.

            .. versionadded:: 1.0.0

        T)Zallow_coercion_to_textr�)rr�r�r:r2r�rAN)	r
rYrrDr�rkrXr_r+)r,rYrr�r�r!r2r:rAr�r[r�)ryrrr_es.
zCheckConstraint.__init__cCst|jt�rdSdSdS)NZcheck_constraintZcolumn_check_constraint)rr�rF)r,rrrrB�szCheckConstraint.__visit_name__c
KsL|dk	rt|j|j|�}n|j}t||j|j|j|j|d|jd�}|�	|�S)NF)rr�r�r:r!rAr�)
r(rYr!rXrr�r�r:r�r9)r,r&r[rYr#rrrr7�s
zCheckConstraint.copy)NNNNNNTF)N)r>r?r@rArNrr_rBrCr7r�rr)ryrrX]s"2rXc
@s�eZdZdZdZddd�Zdd�ZdZdZe	d	d
��Z
e	dd��Ze	d
d��Zdd�Z
e	dd��Ze	dd��Zdd�Zddd�ZdS)r�a�A table-level FOREIGN KEY constraint.

    Defines a single column or composite FOREIGN KEY ... REFERENCES
    constraint. For a no-frills, single column foreign key, adding a
    :class:`.ForeignKey` to the definition of a :class:`.Column` is a
    shorthand equivalent for an unnamed, single column
    :class:`.ForeignKeyConstraint`.

    Examples of foreign key configuration are in :ref:`metadata_foreignkeys`.

    Zforeign_key_constraintNFc
s�tj�f||||d�|
��|�_|�_|	�_|�_|
�_tt|��t|�krxtt|��t|�krnt	�
d��n
t	�
d���fdd�|D��_tj�f|��|dk	r�t
�d�r�|�jks�t���|�dS)aConstruct a composite-capable FOREIGN KEY.

        :param columns: A sequence of local column names. The named columns
          must be defined and present in the parent Table. The names should
          match the ``key`` given to each column (defaults to the name) unless
          ``link_to_name`` is True.

        :param refcolumns: A sequence of foreign column names or Column
          objects. The columns must all be located within the same Table.

        :param name: Optional, the in-database name of the key.

        :param onupdate: Optional string. If set, emit ON UPDATE <value> when
          issuing DDL for this constraint. Typical values include CASCADE,
          DELETE and RESTRICT.

        :param ondelete: Optional string. If set, emit ON DELETE <value> when
          issuing DDL for this constraint. Typical values include CASCADE,
          DELETE and RESTRICT.

        :param deferrable: Optional bool. If set, emit DEFERRABLE or NOT
          DEFERRABLE when issuing DDL for this constraint.

        :param initially: Optional string. If set, emit INITIALLY <value> when
          issuing DDL for this constraint.

        :param link_to_name: if True, the string name given in ``column`` is
          the rendered name of the referenced column, not its locally assigned
          ``key``.

        :param use_alter: If True, do not emit the DDL for this constraint as
          part of the CREATE TABLE definition. Instead, generate it via an
          ALTER TABLE statement issued after the full collection of tables
          have been created, and drop it via an ALTER TABLE statement before
          the full collection of tables are dropped.

          The use of :paramref:`.ForeignKeyConstraint.use_alter` is
          particularly geared towards the case where two or more tables
          are established within a mutually-dependent foreign key constraint
          relationship; however, the :meth:`.MetaData.create_all` and
          :meth:`.MetaData.drop_all` methods will perform this resolution
          automatically, so the flag is normally not needed.

          .. versionchanged:: 1.0.0  Automatic resolution of foreign key
             cycles has been added, removing the need to use the
             :paramref:`.ForeignKeyConstraint.use_alter` in typical use
             cases.

          .. seealso::

                :ref:`use_alter`

        :param match: Optional string. If set, emit MATCH <value> when issuing
          DDL for this constraint. Typical values include SIMPLE, PARTIAL
          and FULL.

        :param info: Optional data dictionary which will be populated into the
            :attr:`.SchemaItem.info` attribute of this object.

            .. versionadded:: 1.0.0

        :param \**dialect_kw:  Additional keyword arguments are dialect
          specific, and passed in the form ``<dialectname>_<argname>``.  See
          the documentation regarding an individual dialect at
          :ref:`dialect_toplevel` for detail on documented arguments.

            .. versionadded:: 0.9.2

        )rr�r�r2zOForeignKeyConstraint with duplicate source column references are not supported.z_ForeignKeyConstraint number of constrained columns must match the number of referenced columns.csBg|]:}t|f��j�j�j�j�j�j�j�jd�	�j	���qS))	r�rr�r�r�r�r�r�r�)
r�rr�r�r�r�r�r�r��dialect_kwargs)r�Zrefcol)r,rrr�Is
z1ForeignKeyConstraint.__init__.<locals>.<listcomp>Nr�)r9r_r�r�r�r�r�r�rlrrQ�elementsr@r�r�r�r+)r,r�Z
refcolumnsrr�r�r�r�r�r�r�r!r2r�r)r,rr_�s2V



zForeignKeyConstraint.__init__cCs|j�|�|j�|�dS)N)r�r�r[r�)r,r�r�rrrr
_sz$ForeignKeyConstraint._append_elementcCst�t|j|j��S)N)r�OrderedDict�zip�column_keysr[)r,rrr�	_elementssszForeignKeyConstraint._elementscCsx|jD]}|jSWdSdS)N)r[r�)r,�elemrrrr�xsz%ForeignKeyConstraint._referred_schemacCs|jdjjS)a^The :class:`.Table` object to which this
        :class:`.ForeignKeyConstraint` references.

        This is a dynamically calculated attribute which may not be available
        if the constraint and/or parent table is not yet associated with
        a metadata collection that contains the referred table.

        .. versionadded:: 1.0.0

        r)r[r�r!)r,rrr�referred_tablesz#ForeignKeyConstraint.referred_tablecCsZtdd�|jD��}d|krVt|�dkrVt|�dd�\}}t�d|j|j||f��dS)NcSsg|]}|���qSr)r�)r�r`rrrr��sz=ForeignKeyConstraint._validate_dest_table.<locals>.<listcomp>rrrzJForeignKeyConstraint on %s(%s) refers to multiple remote tables: %s and %s)rlr[r�r�rrQrs�_col_description)r,r!Z
table_keysZelem0Zelem1rrrr
�sz)ForeignKeyConstraint._validate_dest_tablecCs(t|d�r|j��Sdd�|jD�SdS)a�Return a list of string keys representing the local
        columns in this :class:`.ForeignKeyConstraint`.

        This list is either the original string arguments sent
        to the constructor of the :class:`.ForeignKeyConstraint`,
        or if the constraint has been initialized with :class:`.Column`
        objects, is the string .key of each element.

        .. versionadded:: 1.0.0

        r�cSs$g|]}t|t�r|jnt|��qSr)rrr"�str)r�r$rrrr��sz4ForeignKeyConstraint.column_keys.<locals>.<listcomp>N)r�r�rRrB)r,rrrr^�s

z ForeignKeyConstraint.column_keyscCsd�|j�S)Nz, )r�r^)r,rrrrb�sz%ForeignKeyConstraint._col_descriptionc
Cs�t�||�yt�||�Wn<tk
rX}zt�d|j|jdf��Wdd}~XYnXx8t|j	|j
�D]&\}}t|d�r�|j|k	rj|�
|�qjW|�|�dS)NzQCan't create ForeignKeyConstraint on table '%s': no column named '%s' is present.rr�)r9r�rP�KeyErrorrrQr�r-r]r�r[r�r�r+r
)r,r!Zker$r�rrrr��s&z ForeignKeyConstraint._set_parentcsztdd�|jD���fdd�|jD�|j|j|j|j|j|j|j|j	d�
}x$t
|j|j�D]\}}|�|�qZW|�|�S)NcSsg|]}|jj�qSr)r�r")r�r�rrrr��sz-ForeignKeyConstraint.copy.<locals>.<listcomp>cs:g|]2}|j��dk	r.|��|jjjkr.�jndd��qS)N)rr�)r�r�r�r!r"r)r�r�)rr&rrr��s)rr�r�r�r�r�r�r�)r�r[rr�r�r�r�r�r�r�r]r9)r,rr&r[r�Zself_fkZother_fkr)rr&rr7�s
zForeignKeyConstraint.copy)
NNNNNFFNNN)NN)r>r?r@rArBr_r
r�r[rCr_r�rar
r^rbr�r7rrrrr��s0


r�csZeZdZdZdZ�fdd�Z�fdd�Zdd�Zd	d
�Ze	dd��Z
ejd
d��Z
�ZS)rpa�
A table-level PRIMARY KEY constraint.

    The :class:`.PrimaryKeyConstraint` object is present automatically
    on any :class:`.Table` object; it is assigned a set of
    :class:`.Column` objects corresponding to those marked with
    the :paramref:`.Column.primary_key` flag::

        >>> my_table = Table('mytable', metadata,
        ...                 Column('id', Integer, primary_key=True),
        ...                 Column('version_id', Integer, primary_key=True),
        ...                 Column('data', String(50))
        ...     )
        >>> my_table.primary_key
        PrimaryKeyConstraint(
            Column('id', Integer(), table=<mytable>,
                   primary_key=True, nullable=False),
            Column('version_id', Integer(), table=<mytable>,
                   primary_key=True, nullable=False)
        )

    The primary key of a :class:`.Table` can also be specified by using
    a :class:`.PrimaryKeyConstraint` object explicitly; in this mode of usage,
    the "name" of the constraint can also be specified, as well as other
    options which may be recognized by dialects::

        my_table = Table('mytable', metadata,
                    Column('id', Integer),
                    Column('version_id', Integer),
                    Column('data', String(50)),
                    PrimaryKeyConstraint('id', 'version_id',
                                         name='mytable_pk')
                )

    The two styles of column-specification should generally not be mixed.
    An warning is emitted if the columns present in the
    :class:`.PrimaryKeyConstraint`
    don't match the columns that were marked as ``primary_key=True``, if both
    are present; in this case, the columns are taken strictly from the
    :class:`.PrimaryKeyConstraint` declaration, and those columns otherwise
    marked as ``primary_key=True`` are ignored.  This behavior is intended to
    be backwards compatible with previous behavior.

    .. versionchanged:: 0.9.2  Using a mixture of columns within a
       :class:`.PrimaryKeyConstraint` in addition to columns marked as
       ``primary_key=True`` now emits a warning if the lists don't match.
       The ultimate behavior of ignoring those columns marked with the flag
       only is currently maintained for backwards compatibility; this warning
       may raise an exception in a future release.

    For the use case where specific options are to be specified on the
    :class:`.PrimaryKeyConstraint`, but the usual style of using
    ``primary_key=True`` flags is still desirable, an empty
    :class:`.PrimaryKeyConstraint` may be specified, which will take on the
    primary key column collection from the :class:`.Table` based on the
    flags::

        my_table = Table('mytable', metadata,
                    Column('id', Integer, primary_key=True),
                    Column('version_id', Integer, primary_key=True),
                    Column('data', String(50)),
                    PrimaryKeyConstraint(name='mytable_pk',
                                         mssql_clustered=True)
                )

    .. versionadded:: 0.9.2 an empty :class:`.PrimaryKeyConstraint` may now
       be specified for the purposes of establishing keyword arguments with
       the constraint, independently of the specification of "primary key"
       columns within the :class:`.Table` itself; columns marked as
       ``primary_key=True`` will be gathered into the empty constraint's
       column collection.

    Zprimary_key_constraintcs$|�dd�|_tt|�j||�dS)Nr`F)rPr`rkrpr_)r,r�r[)ryrrr_)
szPrimaryKeyConstraint.__init__c
s�tt|��|�|j|k	r:|j�|j�||_|j�|�dd�|jD�}|jr�|r�t	|�t	|j�
��kr�t�d|j
d�dd�|D��d�dd�|jD��d�dd�|jD��f�g|dd�<x|jD]}d	|_d
|_q�W|j�|�dS)NcSsg|]}|jr|�qSr)r�)r�r#rrrr�5
sz4PrimaryKeyConstraint._set_parent.<locals>.<listcomp>z�Table '%s' specifies columns %s as primary_key=True, not matching locally specified columns %s; setting the current primary key columns to %s. This warning may become an exception in a future releasez, css|]}d|jVqdS)z'%s'N)r)r�r#rrrr�B
sz3PrimaryKeyConstraint._set_parent.<locals>.<genexpr>css|]}d|jVqdS)z'%s'N)r)r�r#rrrr�C
scss|]}d|jVqdS)z'%s'N)r)r�r#rrrr�D
sTF)rkrpr�r�rnrIr�r#r�rl�valuesrr�rr�r��extend)r,r!Z	table_pksr#)ryrrr�-
s(

z PrimaryKeyConstraint._set_parentcCs<x|D]
}d|_qW|j�|�tj�|�|�|j�dS)aDrepopulate this :class:`.PrimaryKeyConstraint` given
        a set of columns.

        Existing columns in the table that are marked as primary_key=True
        are maintained.

        Also fires a new event.

        This is basically like putting a whole new
        :class:`.PrimaryKeyConstraint` object on the parent
        :class:`.Table` object without actually replacing the object.

        The ordering of the given list of columns is also maintained; these
        columns will be appended to the list of columns after any which
        are already present.

        TN)r�r�rfrpr��_resetr+r!)r,r�r$rrr�_reloadN
s


zPrimaryKeyConstraint._reloadcCstj�|�|j�|�dS)N)rpr�rgr�r')r,r$rrrr�l
szPrimaryKeyConstraint._replacecs6|j��dk	r(�g�fdd�|jD�St|j�SdS)Ncsg|]}|�k	r|�qSrr)r�r#)�autoincrrr�u
sz>PrimaryKeyConstraint.columns_autoinc_first.<locals>.<listcomp>)r�r�r�)r,r)rir�columns_autoinc_firstp
sz*PrimaryKeyConstraint.columns_autoinc_firstcCs�dd�}t|j�dkrVt|j�d}|jdkr<||d�|S|jdkr�||d�r�|SnPd}xF|jD]<}|jdkrb||d�|dk	r�t�d|j|jf��qb|}qbW|SdS)	NcSs�|jjdkst|jjtjj�s>|r8t�d|j|f��q�dSnBt|jtd�t	f�sZ|sZdS|j
dk	rl|sldS|jr�|jdkr�dSdS)NzGColumn type %s on column '%s' is not compatible with autoincrement=TrueF)T�	ignore_fkT)
r�Z_type_affinity�
issubclassrZINTEGERTYPErrQrr�r�r�rqr�)r$Zautoinc_truerrr�_validate_autoinc{
s 
zEPrimaryKeyConstraint._autoincrement_column.<locals>._validate_autoincrrT)r�rkFzGOnly one Column may be marked autoincrement=True, found both %s and %s.)r�r�r�r�rrQr)r,rmr$rirrrr�y
s(




z*PrimaryKeyConstraint._autoincrement_column)r>r?r@rArBr_r�rhr�rCrjrrEr�r�rr)ryrrp�sH!	rpc@seZdZdZdZdS)r�aA table-level UNIQUE constraint.

    Defines a single column or composite UNIQUE constraint. For a no-frills,
    single column constraint, adding ``unique=True`` to the ``Column``
    definition is a shorthand equivalent for an unnamed, single column
    UniqueConstraint.
    Zunique_constraintN)r>r?r@rArBrrrrr��
sr�c@sLeZdZdZdZdd�Zdd�Zedd��Zdd
d�Z	ddd
�Z
dd�Zd	S)r�ad	A table-level INDEX.

    Defines a composite (one or more column) INDEX.

    E.g.::

        sometable = Table("sometable", metadata,
                        Column("name", String(50)),
                        Column("address", String(100))
                    )

        Index("some_index", sometable.c.name)

    For a no-frills, single column index, adding
    :class:`.Column` also supports ``index=True``::

        sometable = Table("sometable", metadata,
                        Column("name", String(50), index=True)
                    )

    For a composite index, multiple columns can be specified::

        Index("some_index", sometable.c.name, sometable.c.address)

    Functional indexes are supported as well, typically by using the
    :data:`.func` construct in conjunction with table-bound
    :class:`.Column` objects::

        Index("some_index", func.lower(sometable.c.name))

    An :class:`.Index` can also be manually associated with a :class:`.Table`,
    either through inline declaration or using
    :meth:`.Table.append_constraint`.  When this approach is used, the names
    of the indexed columns can be specified as strings::

        Table("sometable", metadata,
                        Column("name", String(50)),
                        Column("address", String(100)),
                        Index("some_index", "name", "address")
                )

    To support functional or expression-based indexes in this form, the
    :func:`.text` construct may be used::

        from sqlalchemy import text

        Table("sometable", metadata,
                        Column("name", String(50)),
                        Column("address", String(100)),
                        Index("some_index", text("lower(name)"))
                )

    .. versionadded:: 0.9.5 the :func:`.text` construct may be used to
       specify :class:`.Index` expressions, provided the :class:`.Index`
       is explicitly associated with the :class:`.Table`.


    .. seealso::

        :ref:`schema_indexes` - General information on :class:`.Index`.

        :ref:`postgresql_indexes` - PostgreSQL-specific options available for
        the :class:`.Index` construct.

        :ref:`mysql_indexes` - MySQL-specific options available for the
        :class:`.Index` construct.

        :ref:`mssql_indexes` - MSSQL-specific options available for the
        :class:`.Index` construct.

    r�cOs�d|_}g}g}x6|�|�D](\}}}	}
|
dk	r<|�|
�|�|�qW||_t||�dd��|_|�dd�|_|�dd�}d|kr�|�d�|_d|kr�|�d�}|�	|�t
j|f|�d|i�|dk	r�|�|�dS)a~Construct an index object.

        :param name:
          The name of the index

        :param \*expressions:
          Column expressions to include in the index.   The expressions
          are normally instances of :class:`.Column`, but may also
          be arbitrary SQL expressions which ultimately refer to a
          :class:`.Column`.

        :param unique=False:
            Keyword only argument; if True, create a unique index.

        :param quote=None:
            Keyword only argument; whether to apply quoting to the name of
            the index.  Works in the same manner as that of
            :paramref:`.Column.quote`.

        :param info=None: Optional data dictionary which will be populated
            into the :attr:`.SchemaItem.info` attribute of this object.

            .. versionadded:: 1.0.0

        :param \**kw: Additional keyword arguments not mentioned above are
            dialect specific, and passed in the form
            ``<dialectname>_<argname>``. See the documentation regarding an
            individual dialect at :ref:`dialect_toplevel` for detail on
            documented arguments.

        Nr5r�Fr�r2r�)
r!rHr�r�rrPrr�r2r�r@r_r�)r,rr�r[r!r�Zprocessed_expressionsr�r�rErGr�rrrr_s* 



zIndex.__init__cCsnt�||�|jdk	r<||jk	r<t�d|j|jj|jf��||_|j�|�dd�t	�
|j|j�D�|_dS)NzKIndex '%s' is against table '%s', and cannot be associated with table '%s'.cSs"g|]\}}t|t�r|n|�qSr)rr)r�r�Zcolexprrrrr�Zsz%Index._set_parent.<locals>.<listcomp>)
r@r�r!rrQrr�rmr�r�zip_longestr�r�)r,r!rrrr�MszIndex._set_parentcCs|jjS)z2Return the connectable associated with this Index.)r!r})r,rrrr}`sz
Index.bindNcCs"|dkrt|�}|�tj|�|S)z�Issue a ``CREATE`` statement for this
        :class:`.Index`, using the given :class:`.Connectable`
        for connectivity.

        .. seealso::

            :meth:`.MetaData.create_all`.

        N)rr�rr�)r,r}rrrr�fs
zIndex.createcCs"|dkrt|�}|�tj|�dS)z�Issue a ``DROP`` statement for this
        :class:`.Index`, using the given :class:`.Connectable`
        for connectivity.

        .. seealso::

            :meth:`.MetaData.drop_all`.

        N)rr�rr�)r,r}rrrr�us
z
Index.dropcCs6dd�t|j�gdd�|jD�|jr,dgp.g�S)Nz	Index(%s)z, cSsg|]}t|��qSr)r�)r��errrr��sz"Index.__repr__.<locals>.<listcomp>zunique=True)r�r�rr�r�)r,rrrr4�szIndex.__repr__)N)N)r>r?r@rArBr_r�rCr}r�r�r4rrrrr��
sGE

r�Zixzix_%(column_0_label)sc@s�eZdZdZdZejdd�d-dd��ZdZd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Ze�d�dd��Zeee�Zdd�Zdd�Zed d!��Zd.d#d$�Ze�d%d&�d'd(��Zd/d)d*�Zd0d+d,�ZdS)1�MetaDataa�A collection of :class:`.Table` objects and their associated schema
    constructs.

    Holds a collection of :class:`.Table` objects as well as
    an optional binding to an :class:`.Engine` or
    :class:`.Connection`.  If bound, the :class:`.Table` objects
    in the collection and their columns may participate in implicit SQL
    execution.

    The :class:`.Table` objects themselves are stored in the
    :attr:`.MetaData.tables` dictionary.

    :class:`.MetaData` is a thread-safe object for read operations.
    Construction of new tables within a single :class:`.MetaData` object,
    either explicitly or via reflection, may not be completely thread-safe.

    .. seealso::

        :ref:`metadata_describing` - Introduction to database metadata

    r\)z0.8z�The :paramref:`.MetaData.reflect` flag is deprecated and will be removed in a future release.   Please use the :meth:`.MetaData.reflect` method.)�reflectNFcCslt��|_t||�|_|r|nt|_|r.||_t�|_	i|_
t�t
�|_||_|rh|s`t�d��|��dS)a�Create a new MetaData object.

        :param bind:
          An Engine or Connection to bind to.  May also be a string or URL
          instance, these are passed to create_engine() and this MetaData will
          be bound to the resulting engine.

        :param reflect:
          Optional, automatically load all tables from the bound database.
          Defaults to False. ``bind`` is required when this option is set.

        :param schema:
           The default schema to use for the :class:`.Table`,
           :class:`.Sequence`, and potentially other objects associated with
           this :class:`.MetaData`. Defaults to ``None``.

           When this value is set, any :class:`.Table` or :class:`.Sequence`
           which specifies ``None`` for the schema parameter will instead
           have this schema name defined.  To build a :class:`.Table`
           or :class:`.Sequence` that still has ``None`` for the schema
           even when this parameter is present, use the :attr:`.BLANK_SCHEMA`
           symbol.

           .. note::

                As referred above, the :paramref:`.MetaData.schema` parameter
                only refers to the **default value** that will be applied to
                the :paramref:`.Table.schema` parameter of an incoming
                :class:`.Table` object.   It does not refer to how the
                :class:`.Table` is catalogued within the :class:`.MetaData`,
                which remains consistent vs. a :class:`.MetaData` collection
                that does not define this parameter.  The :class:`.Table`
                within the :class:`.MetaData` will still be keyed based on its
                schema-qualified name, e.g.
                ``my_metadata.tables["some_schema.my_table"]``.

                The current behavior of the :class:`.ForeignKey` object is to
                circumvent this restriction, where it can locate a table given
                the table name alone, where the schema will be assumed to be
                present from this value as specified on the owning
                :class:`.MetaData` collection.  However, this implies  that a
                table qualified with BLANK_SCHEMA cannot currently be referred
                to by string name from :class:`.ForeignKey`.    Other parts of
                SQLAlchemy such as Declarative may not have similar behaviors
                built in, however may do so in a future release, along with a
                consistent method of referring to a table in BLANK_SCHEMA.


           .. seealso::

                :paramref:`.Table.schema`

                :paramref:`.Sequence.schema`

        :param quote_schema:
            Sets the ``quote_schema`` flag for those :class:`.Table`,
            :class:`.Sequence`, and other objects which make usage of the
            local ``schema`` name.

        :param info: Optional data dictionary which will be populated into the
            :attr:`.SchemaItem.info` attribute of this object.

            .. versionadded:: 1.0.0

        :param naming_convention: a dictionary referring to values which
          will establish default naming conventions for :class:`.Constraint`
          and :class:`.Index` objects, for those objects which are not given
          a name explicitly.

          The keys of this dictionary may be:

          * a constraint or Index class, e.g. the :class:`.UniqueConstraint`,
            :class:`.ForeignKeyConstraint` class, the :class:`.Index` class

          * a string mnemonic for one of the known constraint classes;
            ``"fk"``, ``"pk"``, ``"ix"``, ``"ck"``, ``"uq"`` for foreign key,
            primary key, index, check, and unique constraint, respectively.

          * the string name of a user-defined "token" that can be used
            to define new naming tokens.

          The values associated with each "constraint class" or "constraint
          mnemonic" key are string naming templates, such as
          ``"uq_%(table_name)s_%(column_0_name)s"``,
          which describe how the name should be composed.  The values
          associated with user-defined "token" keys should be callables of the
          form ``fn(constraint, table)``, which accepts the constraint/index
          object and :class:`.Table` as arguments, returning a string
          result.

          The built-in names are as follows, some of which may only be
          available for certain types of constraint:

            * ``%(table_name)s`` - the name of the :class:`.Table` object
              associated with the constraint.

            * ``%(referred_table_name)s`` - the name of the :class:`.Table`
              object associated with the referencing target of a
              :class:`.ForeignKeyConstraint`.

            * ``%(column_0_name)s`` - the name of the :class:`.Column` at
              index position "0" within the constraint.

            * ``%(column_0N_name)s`` - the name of all :class:`.Column`
              objects in order within the constraint, joined without a
              separator.

            * ``%(column_0_N_name)s`` - the name of all :class:`.Column`
              objects in order within the constraint, joined with an
              underscore as a separator.

            * ``%(column_0_label)s``, ``%(column_0N_label)s``,
              ``%(column_0_N_label)s`` - the label of either the zeroth
              :class:`.Column` or all :class:`.Columns`, separated with
              or without an underscore

            * ``%(column_0_key)s``, ``%(column_0N_key)s``,
              ``%(column_0_N_key)s`` - the key of either the zeroth
              :class:`.Column` or all :class:`.Columns`, separated with
              or without an underscore

            * ``%(referred_column_0_name)s``, ``%(referred_column_0N_name)s``
              ``%(referred_column_0_N_name)s``,  ``%(referred_column_0_key)s``,
              ``%(referred_column_0N_key)s``, ...  column tokens which
              render the names/keys/labels of columns that are referenced
              by a  :class:`.ForeignKeyConstraint`.

            * ``%(constraint_name)s`` - a special key that refers to the
              existing name given to the constraint.  When this key is
              present, the :class:`.Constraint` object's existing name will be
              replaced with one that is composed from template string that
              uses this token. When this token is present, it is required that
              the :class:`.Constraint` is given an explicit name ahead of time.

            * user-defined: any additional token may be implemented by passing
              it along with a ``fn(constraint, table)`` callable to the
              naming_convention dictionary.

          .. versionadded:: 1.3.0 - added new ``%(column_0N_name)s``,
             ``%(column_0_N_name)s``, and related tokens that produce
             concatenations of names, keys, or labels for all columns referred
             to by a given constraint.

          .. seealso::

                :ref:`constraint_naming_conventions` - for detailed usage
                examples.

        z8A bind must be supplied in conjunction with reflect=TrueN)r�
immutabledictrRrr�DEFAULT_NAMING_CONVENTION�naming_conventionr2rl�_schemasr2�collections�defaultdictr�r�r}rrQrq)r,r}rqrr^rtr2rrrr_�s '
zMetaData.__init__cCs
d|jS)NzMetaData(bind=%r))r})r,rrrr4sszMetaData.__repr__cCst|tj�s|j}||jkS)N)rrr�r"rR)r,Ztable_or_keyrrrrQvszMetaData.__contains__cCs.t||�}t�|j||�|r*|j�|�dS)N)r�dict�__setitem__rRrur�)r,rrr!r"rrrrV{s
zMetaData._add_tablecCs`t||�}t�|j|d�}|dk	r<x|jD]}|�|�q*W|jr\tdd�|j��D��|_dS)NcSsg|]}|jdk	r|j�qS)N)r)r��trrrr��sz*MetaData._remove_table.<locals>.<listcomp>)	rrxrPrRrqrrurlre)r,rrr"�removedr�rrrrY�s
zMetaData._remove_tablecCs|j|j|j|j|j|jd�S)N)rRr�schemas�	sequences�fk_memosrt)rRrrur2r�rt)r,rrr�__getstate__�szMetaData.__getstate__cCsF|d|_|d|_|d|_d|_|d|_|d|_|d|_dS)NrRrrtr}r|r~)rRrrt�_bindr2rur�)r,�staterrr�__setstate__�s




zMetaData.__setstate__cCs
|jdk	S)z:True if this MetaData is bound to an Engine or Connection.N)r�)r,rrr�is_bound�szMetaData.is_boundcCs|jS)a	An :class:`.Engine` or :class:`.Connection` to which this
        :class:`.MetaData` is bound.

        Typically, a :class:`.Engine` is assigned to this attribute
        so that "implicit execution" may be used, or alternatively
        as a means of providing engine binding information to an
        ORM :class:`.Session` object::

            engine = create_engine("someurl://")
            metadata.bind = engine

        .. seealso::

           :ref:`dbengine_implicit` - background on "bound metadata"

        )r�)r,rrrr}�sz
MetaData.bindzsqlalchemy.engine.urlcCs,t|tj|jf�r"t�|�|_n||_dS)z;Bind this MetaData to an Engine, Connection, string or URL.N)rrr��URL�
sqlalchemy�
create_enginer�)r,�urlr}rrr�_bind_to�szMetaData._bind_tocCs$t�|j�|j��|j��dS)z+Clear all Table objects from this MetaData.N)rx�clearrRrur�)r,rrrr��s
zMetaData.clearcCs|�|j|j�dS)z1Remove the given Table object from this MetaData.N)rYrr)r,r!rrrr��szMetaData.removecCst�t|j��dd�d��S)a�Returns a list of :class:`.Table` objects sorted in order of
        foreign key dependency.

        The sorting will place :class:`.Table` objects that have dependencies
        first, before the dependencies themselves, representing the
        order in which they can be created.   To get the order in which
        the tables would be dropped, use the ``reversed()`` Python built-in.

        .. warning::

            The :attr:`.sorted_tables` accessor cannot by itself accommodate
            automatic resolution of dependency cycles between tables, which
            are usually caused by mutually dependent foreign key constraints.
            To resolve these cycles, either the
            :paramref:`.ForeignKeyConstraint.use_alter` parameter may be
            applied to those constraints, or use the
            :func:`.schema.sort_tables_and_constraints` function which will
            break out foreign key constraints involved in cycles separately.

        .. seealso::

            :func:`.schema.sort_tables`

            :func:`.schema.sort_tables_and_constraints`

            :attr:`.MetaData.tables`

            :meth:`.Inspector.get_table_names`

            :meth:`.Inspector.get_sorted_table_and_fkc_names`


        cSs|jS)N)r")rzrrrr~�rz(MetaData.sorted_tables.<locals>.<lambda>)r")rZsort_tablesr�rRre)r,rrr�
sorted_tables�s#zMetaData.sorted_tablesTcs�|dkrt��}|�����}	d|	�||t�d�}
|
�|��dkrH�j��dk	rX�|
d<t�|jj�|	d���|r���|j	�
|	����dk	r�t��fdd��D��}n�}t�j���dkrڇ�fdd�t�|�D�}n�t�
���r����fd	d�t�|�D�}n\�fd
d��D�}
|
�rN��r.d��p0d}t�d
|j|d�|
�f����fdd��D�}xZ|D]R}yt|�f|
�Wn8tjk
�r�}zt�d||f�Wdd}~XYnX�qhWWdQRXdS)a,
Load all available table definitions from the database.

        Automatically creates ``Table`` entries in this ``MetaData`` for any
        table available in the database but not yet present in the
        ``MetaData``.  May be called multiple times to pick up tables recently
        added to the database, however no special action is taken if a table
        in this ``MetaData`` no longer exists in the database.

        :param bind:
          A :class:`.Connectable` used to access the database; if None, uses
          the existing bind on this ``MetaData``, if any.

        :param schema:
          Optional, query and reflect tables from an alternate schema.
          If None, the schema associated with this :class:`.MetaData`
          is used, if any.

        :param views:
          If True, also reflect views.

        :param only:
          Optional.  Load only a sub-set of available named tables.  May be
          specified as a sequence of names or a callable.

          If a sequence of names is provided, only those tables will be
          reflected.  An error is raised if a table is requested but not
          available.  Named tables already present in this ``MetaData`` are
          ignored.

          If a callable is provided, it will be used as a boolean predicate to
          filter the list of potential table names.  The callable is called
          with a table name and this ``MetaData`` instance as positional
          arguments and should return a true value for any table to reflect.

        :param extend_existing: Passed along to each :class:`.Table` as
          :paramref:`.Table.extend_existing`.

          .. versionadded:: 0.9.1

        :param autoload_replace: Passed along to each :class:`.Table` as
          :paramref:`.Table.autoload_replace`.

          .. versionadded:: 0.9.1

        :param resolve_fks: if True, reflect :class:`.Table` objects linked
         to :class:`.ForeignKey` objects located in each :class:`.Table`.
         For :meth:`.MetaData.reflect`, this has the effect of reflecting
         related tables that might otherwise not be in the list of tables
         being reflected, for example if the referenced table is in a
         different schema or is omitted via the
         :paramref:`.MetaData.reflect.only` parameter.  When False,
         :class:`.ForeignKey` objects are not followed to the :class:`.Table`
         in which they link, however if the related table is also part of the
         list of tables that would be reflected in any case, the
         :class:`.ForeignKey` object will still resolve to its related
         :class:`.Table` after the :meth:`.MetaData.reflect` operation is
         complete.   Defaults to True.

         .. versionadded:: 1.3.0

         .. seealso::

            :paramref:`.Table.resolve_fks`

        :param \**dialect_kwargs: Additional keyword arguments not mentioned
         above are dialect specific, and passed in the form
         ``<dialectname>_<argname>``.  See the documentation regarding an
         individual dialect at :ref:`dialect_toplevel` for detail on
         documented arguments.

          .. versionadded:: 0.9.2 - Added
             :paramref:`.MetaData.reflect.**dialect_kwargs` to support
             dialect-level reflection options for all :class:`.Table`
             objects reflected.

        NT)rbrarIrcrerdr)r�csg|]}d�|f�qS)z%s.%sr)r�r)rrrr�nsz$MetaData.reflect.<locals>.<listcomp>cs g|]\}}�s|�kr|�qSrr)r�r�schname)�currentrIrrr�wscs*g|]"\}}�s|�kr�|��r|�qSrr)r�rr�)r�rI�onlyr,rrr�}scsg|]}|�kr|�qSrr)r�r)�	availablerrr��sz schema '%s'r�zACould not reflect: requested table(s) not available in %r%s: (%s)z, csg|]}�s|�kr|�qSrr)r�r)r�rIrrr��szSkipping table %s: %s)r�connectrlr4rr�
OrderedSetZengineZtable_namesr{Zget_view_namesrRr]rrrTr�rFZUnreflectableTableErrorr�)r,r}rZviewsr�rIrcrerZZconnZreflect_optsZavailable_w_schema�load�missing�srZuerrr)r�r�rIr�rr,rrq�sTW



zMetaData.reflectz0.7z�the :meth:`.MetaData.append_ddl_listener` method is deprecated and will be removed in a future release.  Please refer to :class:`.DDLEvents`.cs*�fdd�}t�|d|�dd�|�dS)z<Append a DDL event listener to this ``MetaData``.


        cs|d}�t|||d�dS)NrR)rR)r)r�r�r[rR)r�rrr��sz4MetaData.append_ddl_listener.<locals>.adapt_listenerr�r�r�N)rrtr')r,r�r�r�r)r�rr��szMetaData.append_ddl_listenercCs(|dkrt|�}|jtj|||d�dS)ayCreate all tables stored in this metadata.

        Conditional by default, will not attempt to recreate tables already
        present in the target database.

        :param bind:
          A :class:`.Connectable` used to access the
          database; if None, uses the existing bind on this ``MetaData``, if
          any.

        :param tables:
          Optional list of ``Table`` objects, which is a subset of the total
          tables in the ``MetaData`` (others are ignored).

        :param checkfirst:
          Defaults to True, don't issue CREATEs for tables already present
          in the target database.

        N)r�rR)rr�rr�)r,r}rRr�rrr�
create_all�szMetaData.create_allcCs(|dkrt|�}|jtj|||d�dS)atDrop all tables stored in this metadata.

        Conditional by default, will not attempt to drop tables not present in
        the target database.

        :param bind:
          A :class:`.Connectable` used to access the
          database; if None, uses the existing bind on this ``MetaData``, if
          any.

        :param tables:
          Optional list of ``Table`` objects, which is a subset of the
          total tables in the ``MetaData`` (others are ignored).

        :param checkfirst:
          Defaults to True, only issue DROPs for tables confirmed to be
          present in the target database.

        N)r�rR)rr�rr�)r,r}rRr�rrr�drop_all�szMetaData.drop_all)NFNNNN)NNFNFTT)NNT)NNT)r>r?r@rArBrr�r_rRr4rQrVrYrr�r�r}r"r�rCr�r�r�rqrDr�r�r�rrrrrp�sL.
		
)

rpcsXeZdZdZdZ�fdd�Zdd�Ze�d�dd	��Z	e
ee	�Zd
d�Zdd
�Z�Z
S)�ThreadLocalMetaDataaA MetaData variant that presents a different ``bind`` in every thread.

    Makes the ``bind`` property of the MetaData a thread-local value, allowing
    this collection of tables to be bound to different ``Engine``
    implementations or connections in each thread.

    The ThreadLocalMetaData starts off bound to None in each thread.  Binds
    must be made explicitly by assigning to the ``bind`` property or using
    ``connect()``.  You can also re-bind dynamically multiple times per
    thread, just like a regular ``MetaData``.

    r\cs$tj��|_i|_tt|���dS)z Construct a ThreadLocalMetaData.N)r�	threading�local�context�_ThreadLocalMetaData__enginesrkr�r_)r,)ryrrr_�szThreadLocalMetaData.__init__cCst|jdd�S)z�The bound Engine or Connection for this thread.

        This property may be assigned an Engine or Connection, or assigned a
        string or URL to automatically create a basic Engine for this bind
        with ``create_engine()``.�_engineN)r�r�)r,rrrr}�szThreadLocalMetaData.bindzsqlalchemy.engine.urlcCszt|tj|jf�rZy|j||j_Wqvtk
rVt�	|�}||j|<||j_YqvXn||jkrn||j|<||j_dS)z-Bind to a Connectable in the caller's thread.N)
rrr�r�r�r�r�rdr�r�)r,r�r}rorrrr��s



zThreadLocalMetaData._bind_tocCst|jd�o|jjdk	S)z(True if there is a bind for this thread.r�N)r�r�r�)r,rrrr�szThreadLocalMetaData.is_boundcCs*x$|j��D]}t|d�r|��qWdS)z2Dispose all bound engines, in all thread contexts.�disposeN)r�rer�r�)r,rorrrr�s
zThreadLocalMetaData.dispose)r>r?r@rArBr_r}rr"r�rCr�r�r�rr)ryrr��s	
r�c@s2eZdZdZdZe�d�Zdd�Ze	dd��Z
dS)	�_SchemaTranslateMapaProvide translation of schema names based on a mapping.

    Also provides helpers for producing cache keys and optimized
    access when no mapping is present.

    Used by the :paramref:`.Connection.execution_options.schema_translate_map`
    feature.

    .. versionadded:: 1.1


    )r<�__call__�hash_key�
is_defaultrcsd��_�dk	rL��fdd�}|�_d��fdd�t�td�D���_d�_nd�_�j�_d	�_dS)
Ncs��|�}|�|��}|S)N)�_default_schema_getterr=)�objr;)r<r,rr�schema_for_object6s
z7_SchemaTranslateMap.__init__.<locals>.schema_for_object�;c3s|]}d|�|fVqdS)z%s=%sNr)r�r�)r<rrr�?sz/_SchemaTranslateMap.__init__.<locals>.<genexpr>)r"FrT)r<r�r�r�rcr�r�r�)r,r<r�r)r<r,rr_2sz_SchemaTranslateMap.__init__cCs&|dkrtSt|t�r|St|�SdS)N)�_default_schema_maprr�)rZr<rrr�_schema_getterGs

z"_SchemaTranslateMap._schema_getterN)r>r?r@rA�	__slots__�operator�
attrgetterr�r_rOr�rrrrr� s

r�)CrA�
__future__rrvr�r�r�rrr�baserrr	r
r[rrr
rrrrrr�rrrrr�symbolr�rOrr(Z_self_inspectsZ	Visitabler)rFr r�rKrrr�r�r�r�Zdeprecated_clsr8r9r>r?r@rPrXr�rpr�r�rrrsrpr�r�r�r�rrrr�<module>s�
	:`jg$w
3$W	`IcUQQC1

Youez - 2016 - github.com/yon3zu
LinuXploit