σ
H`ΎTc           @   s@  d  Z  d d l m Z d d l m Z d d l m Z d d l m Z m	 Z	 m
 Z
 m Z d d l m Z d d l m Z d d	 l m Z d
 e f d     YZ d e e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d  e f d!     YZ d" e f d#     YZ d$ e f d%     YZ d& e f d'     YZ d( e f d)     YZ d* e
 f d+     YZ d, e f d-     YZ  d. e f d/     YZ! d1 d1 d0  Z# d1 S(2   sq   
Provides the hierarchy of DDL-defining schema items as well as routines
to invoke them for a create/drop call.

i   (   t   utili   (   t   ClauseElement(   t   traverse(   t
   Executablet   _generativet   SchemaVisitort   _bind_or_error(   t   topological(   t   event(   t   exct   _DDLCompilesc           B   s   e  Z d    Z RS(   c         K   s   | j  | |  |  S(   sN   Return a compiler appropriate for this ClauseElement, given a
        Dialect.(   t   ddl_compiler(   t   selft   dialectt   kw(    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyt	   _compiler   s    (   t   __name__t
   __module__R   (    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyR
      s   t
   DDLElementc           B   sη   e  Z d  Z e j j i e d 6 Z d Z d Z	 d Z
 d Z d   Z d d d  Z e j d d  d    Z e d    Z e d d d d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z e e e  Z d   Z RS(   sΪ  Base class for DDL expression constructs.

    This class is the base for the general purpose :class:`.DDL` class,
    as well as the various create/drop clause constructs such as
    :class:`.CreateTable`, :class:`.DropTable`, :class:`.AddConstraint`,
    etc.

    :class:`.DDLElement` integrates closely with SQLAlchemy events,
    introduced in :ref:`event_toplevel`.  An instance of one is
    itself an event receiving callable::

        event.listen(
            users,
            'after_create',
            AddConstraint(constraint).execute_if(dialect='postgresql')
        )

    .. seealso::

        :class:`.DDL`

        :class:`.DDLEvents`

        :ref:`event_toplevel`

        :ref:`schema_ddl_sequences`

    t
   autocommitc         C   s   | j  |  | |  S(   N(   t   _execute_ddl(   R   t
   connectiont   multiparamst   params(    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyt   _execute_on_connectionD   s    c         C   sZ   | d k r t |   } n  |  j | |  rC | j |  j |   S| j j j d  d S(   s   Execute this DDL immediately.

        Executes the DDL statement in isolation using the supplied
        :class:`.Connectable` or
        :class:`.Connectable` assigned to the ``.bind``
        property, if not supplied. If the DDL has a conditional ``on``
        criteria, it will be invoked with None as the event.

        :param bind:
          Optional, an ``Engine`` or ``Connection``. If not supplied, a valid
          :class:`.Connectable` must be present in the
          ``.bind`` property.

        :param target:
          Optional, defaults to None.  The target SchemaItem for the
          execute call.  Will be passed to the ``on`` callable if any,
          and may also provide string expansion data for the
          statement. See ``execute_at`` for more information.

        s(   DDL execution skipped, criteria not met.N(   t   NoneR   t   _should_executet   executet   againstt   enginet   loggert   info(   R   t   bindt   target(    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyR   G   s    s   0.7sC   See :class:`.DDLEvents`, as well as :meth:`.DDLElement.execute_if`.c            s9      f d   } t  j | d   j d d  |  d S(   sQ  Link execution of this DDL to the DDL lifecycle of a SchemaItem.

        Links this ``DDLElement`` to a ``Table`` or ``MetaData`` instance,
        executing it when that schema item is created or dropped. The DDL
        statement will be executed using the same Connection and transactional
        context as the Table create/drop itself. The ``.bind`` property of
        this statement is ignored.

        :param event:
          One of the events defined in the schema item's ``.ddl_events``;
          e.g. 'before-create', 'after-create', 'before-drop' or 'after-drop'

        :param target:
          The Table or MetaData instance for which this DDLElement will
          be associated with.

        A DDLElement instance can be linked to any number of schema items.

        ``execute_at`` builds on the ``append_ddl_listener`` interface of
        :class:`.MetaData` and :class:`.Table` objects.

        Caveat: Creating or dropping a Table in isolation will also trigger
        any DDL set to ``execute_at`` that Table's MetaData.  This may change
        in a future release.

        c            s2    j    |  | |  r. | j  j |    Sd  S(   N(   t   _should_execute_deprecatedR   R   (   R!   R   R   (   t
   event_nameR   (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyt
   call_event   s    	t    t   -t   _N(   R   t   listent   replace(   R   R#   R!   R$   (    (   R#   R   sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyt
   execute_atf   s    c         C   s   | |  _  d S(   s9   Return a copy of this DDL against a specific schema item.N(   R!   (   R   R!   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyR      s    c         C   s   | |  _  | |  _ | |  _ d S(   sω  Return a callable that will execute this
        DDLElement conditionally.

        Used to provide a wrapper for event listening::

            event.listen(
                        metadata,
                        'before_create',
                        DDL("my_ddl").execute_if(dialect='postgresql')
                    )

        :param dialect: May be a string, tuple or a callable
          predicate.  If a string, it will be compared to the name of the
          executing database dialect::

            DDL('something').execute_if(dialect='postgresql')

          If a tuple, specifies multiple dialect names::

            DDL('something').execute_if(dialect=('postgresql', 'mysql'))

        :param callable_: A callable, which will be invoked with
          four positional arguments as well as optional keyword
          arguments:

            :ddl:
              This DDL element.

            :target:
              The :class:`.Table` or :class:`.MetaData` object which is the
              target of this event. May be None if the DDL is executed
              explicitly.

            :bind:
              The :class:`.Connection` being used for DDL execution

            :tables:
              Optional keyword argument - a list of Table objects which are to
              be created/ dropped within a MetaData.create_all() or drop_all()
              method call.

            :state:
              Optional keyword argument - will be the ``state`` argument
              passed to this function.

            :checkfirst:
             Keyword argument, will be True if the 'checkfirst' flag was
             set during the call to ``create()``, ``create_all()``,
             ``drop()``, ``drop_all()``.

          If the callable returns a true value, the DDL statement will be
          executed.

        :param state: any value which will be passed to the callable\_
          as the ``state`` keyword argument.

        .. seealso::

            :class:`.DDLEvents`

            :ref:`event_toplevel`

        N(   R   t	   callable_t   state(   R   R   R+   R,   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyt
   execute_if   s    A		c      	   K   sΝ   |  j  d  k	 r, |  j d  | | |  r, t St |  j t j  r] |  j | j j	 k r t Sn7 t |  j t
 t t f  r | j j	 |  j k r t Sn  |  j d  k	 rΙ |  j |  | | d |  j | rΙ t St S(   NR,   (   t   onR   R"   t   Falset
   isinstanceR   R    t   string_typesR   t   namet   tuplet   listt   setR+   R,   t   True(   R   R!   R    R   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyR   Φ   s    c         K   s   |  j  d  k r t St |  j  t j  r; |  j  | j j k St |  j  t t	 t
 f  ri | j j |  j  k S|  j  |  | | | |  Sd  S(   N(   R.   R   R6   R0   R    R1   R   R2   R3   R4   R5   (   R   R   R!   R    R   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyR"   θ   s    c         K   s/   |  j  | | |  r+ | j |  j |   Sd S(   s"   Execute the DDL as a ddl_listener.N(   R   R   R   (   R   R!   R    R   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyt   __call__ς   s    c         C   s_   | d  k	 r[ t | t j t t t f  r[ t j |  r[ t j	 d t
 |  j   n  d  S(   Nsj   Expected the name of a database dialect, a tuple of names, or a callable for 'on' criteria, got type '%s'.(   R   R0   R    R1   R3   R4   R5   t   callableR	   t   ArgumentErrort   typeR   (   R   R.   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyt   _check_ddl_onψ   s     c         C   s   |  j  r |  j  Sd  S(   N(   t   _bind(   R   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyR      s    	c         C   s   | |  _  d  S(   N(   R<   (   R   R    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyt	   _set_bind  s    c         C   s+   |  j  j |  j   } |  j j   | _ | S(   N(   t	   __class__t   __new__t   __dict__t   copy(   R   t   s(    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyt	   _generate	  s    N(   R   R   t   __doc__R   t   _execution_optionst   unionR6   R   R!   R.   R   R+   R   R   R    t
   deprecatedR*   R   R   R-   R   R"   R7   R;   R    R=   t   propertyRC   (    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyR      s*   		%D		
					t   DDLc           B   s/   e  Z d  Z d Z d d d d  Z d   Z RS(   s/  A literal DDL statement.

    Specifies literal SQL DDL to be executed by the database.  DDL objects
    function as DDL event listeners, and can be subscribed to those events
    listed in :class:`.DDLEvents`, using either :class:`.Table` or
    :class:`.MetaData` objects as targets.   Basic templating support allows
    a single DDL instance to handle repetitive tasks for multiple tables.

    Examples::

      from sqlalchemy import event, DDL

      tbl = Table('users', metadata, Column('uid', Integer))
      event.listen(tbl, 'before_create', DDL('DROP TRIGGER users_trigger'))

      spow = DDL('ALTER TABLE %(table)s SET secretpowers TRUE')
      event.listen(tbl, 'after_create', spow.execute_if(dialect='somedb'))

      drop_spow = DDL('ALTER TABLE users SET secretpowers FALSE')
      connection.execute(drop_spow)

    When operating on Table events, the following ``statement``
    string substitions are available::

      %(table)s  - the Table name, with any required quoting applied
      %(schema)s - the schema name, with any required quoting applied
      %(fullname)s - the Table name including schema, quoted if needed

    The DDL's "context", if any, will be combined with the standard
    substitutions noted above.  Keys present in the context will override
    the standard substitutions.

    t   ddlc         C   sc   t  | t j  s( t j d |   n  | |  _ | p: i  |  _ |  j |  | |  _ | |  _	 d S(   sy  Create a DDL statement.

        :param statement:
          A string or unicode string to be executed.  Statements will be
          processed with Python's string formatting operator.  See the
          ``context`` argument and the ``execute_at`` method.

          A literal '%' in a statement must be escaped as '%%'.

          SQL bind parameters are not available in DDL statements.

        :param on:
          .. deprecated:: 0.7
            See :meth:`.DDLElement.execute_if`.

          Optional filtering criteria.  May be a string, tuple or a callable
          predicate.  If a string, it will be compared to the name of the
          executing database dialect::

            DDL('something', on='postgresql')

          If a tuple, specifies multiple dialect names::

            DDL('something', on=('postgresql', 'mysql'))

          If a callable, it will be invoked with four positional arguments
          as well as optional keyword arguments:

            :ddl:
              This DDL element.

            :event:
              The name of the event that has triggered this DDL, such as
              'after-create' Will be None if the DDL is executed explicitly.

            :target:
              The ``Table`` or ``MetaData`` object which is the target of
              this event. May be None if the DDL is executed explicitly.

            :connection:
              The ``Connection`` being used for DDL execution

            :tables:
              Optional keyword argument - a list of Table objects which are to
              be created/ dropped within a MetaData.create_all() or drop_all()
              method call.


          If the callable returns a true value, the DDL statement will be
          executed.

        :param context:
          Optional dictionary, defaults to None.  These values will be
          available for use in string substitutions on the DDL statement.

        :param bind:
          Optional. A :class:`.Connectable`, used by
          default when ``execute()`` is invoked without a bind argument.


        .. seealso::

            :class:`.DDLEvents`

            :mod:`sqlalchemy.event`

        s4   Expected a string or unicode SQL statement, got '%r'N(
   R0   R    R1   R	   R9   t	   statementt   contextR;   R.   R<   (   R   RK   R.   RL   R    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyt   __init__4  s    E		c         C   sn   d t  |   j t |   d j t |  j  g g  d D]. } t |  |  r4 d | t |  |  f ^ q4  f S(   Ns   <%s@%s; %s>s   , R.   RL   s   %s=%r(   s   ons   context(   R:   R   t   idt   joint   reprRK   t   getattr(   R   t   key(    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyt   __repr__  s    
N(   R   R   RD   t   __visit_name__R   RM   RS   (    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRI     s   !Qt   _CreateDropBasec           B   s&   e  Z d  Z d d d  Z d   Z RS(   sί   Base class for DDL constructs that represent CREATE and DROP or
    equivalents.

    The common theme of _CreateDropBase is a single
    ``element`` attribute which refers to the element
    to be created or dropped.

    c         C   s,   | |  _  |  j |  | |  _ | |  _ d  S(   N(   t   elementR;   R.   R    (   R   RV   R.   R    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRM     s    		c         C   s   t  S(   sΐ   Allow disable of _create_rule using a callable.

        Pass to _create_rule using
        util.portable_instancemethod(self._create_rule_disable)
        to retain serializability.

        (   R/   (   R   t   compiler(    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyt   _create_rule_disable  s    N(   R   R   RD   R   RM   RX   (    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRU     s   t   CreateSchemac           B   s    e  Z d  Z d Z d d  Z RS(   s   Represent a CREATE SCHEMA statement.

    .. versionadded:: 0.7.4

    The argument here is the string name of the schema.

    t   create_schemac         K   s&   | |  _  t t |   j | |  d S(   s.   Create a new :class:`.CreateSchema` construct.N(   t   quotet   superRY   RM   (   R   R2   R[   R   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRM   ΄  s    	N(   R   R   RD   RT   R   RM   (    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRY   ©  s   t
   DropSchemac           B   s#   e  Z d  Z d Z d e d  Z RS(   s~   Represent a DROP SCHEMA statement.

    The argument here is the string name of the schema.

    .. versionadded:: 0.7.4

    t   drop_schemac         K   s/   | |  _  | |  _ t t |   j | |  d S(   s,   Create a new :class:`.DropSchema` construct.N(   R[   t   cascadeR\   R]   RM   (   R   R2   R[   R_   R   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRM   Ζ  s    		N(   R   R   RD   RT   R   R/   RM   (    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyR]   »  s   t   CreateTablec           B   s#   e  Z d  Z d Z d d d  Z RS(   s#   Represent a CREATE TABLE statement.t   create_tablec         C   sK   t  t |   j | d | d | g  | j D] } t |  ^ q, |  _ d S(   s  Create a :class:`.CreateTable` construct.

        :param element: a :class:`.Table` that's the subject
         of the CREATE
        :param on: See the description for 'on' in :class:`.DDL`.
        :param bind: See the description for 'bind' in :class:`.DDL`.

        R.   R    N(   R\   R`   RM   t   columnst   CreateColumn(   R   RV   R.   R    t   column(    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRM   Σ  s    	"N(   R   R   RD   RT   R   RM   (    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyR`   Ξ  s   t	   _DropViewc           B   s   e  Z d  Z d Z RS(   s©   Semi-public 'DROP VIEW' construct.

    Used by the test suite for dialect-agnostic drops of views.
    This object will eventually be part of a public "view" API.

    t	   drop_view(   R   R   RD   RT   (    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRe   β  s   Rc   c           B   s   e  Z d  Z d Z d   Z RS(   sz  Represent a :class:`.Column` as rendered in a CREATE TABLE statement,
    via the :class:`.CreateTable` construct.

    This is provided to support custom column DDL within the generation
    of CREATE TABLE statements, by using the
    compiler extension documented in :ref:`sqlalchemy.ext.compiler_toplevel`
    to extend :class:`.CreateColumn`.

    Typical integration is to examine the incoming :class:`.Column`
    object, and to redirect compilation if a particular flag or condition
    is found::

        from sqlalchemy import schema
        from sqlalchemy.ext.compiler import compiles

        @compiles(schema.CreateColumn)
        def compile(element, compiler, **kw):
            column = element.element

            if "special" not in column.info:
                return compiler.visit_create_column(element, **kw)

            text = "%s SPECIAL DIRECTIVE %s" % (
                    column.name,
                    compiler.type_compiler.process(column.type)
                )
            default = compiler.get_column_default_string(column)
            if default is not None:
                text += " DEFAULT " + default

            if not column.nullable:
                text += " NOT NULL"

            if column.constraints:
                text += " ".join(
                            compiler.process(const)
                            for const in column.constraints)
            return text

    The above construct can be applied to a :class:`.Table` as follows::

        from sqlalchemy import Table, Metadata, Column, Integer, String
        from sqlalchemy import schema

        metadata = MetaData()

        table = Table('mytable', MetaData(),
                Column('x', Integer, info={"special":True}, primary_key=True),
                Column('y', String(50)),
                Column('z', String(20), info={"special":True})
            )

        metadata.create_all(conn)

    Above, the directives we've added to the :attr:`.Column.info` collection
    will be detected by our custom compilation scheme::

        CREATE TABLE mytable (
                x SPECIAL DIRECTIVE INTEGER NOT NULL,
                y VARCHAR(50),
                z SPECIAL DIRECTIVE VARCHAR(20),
            PRIMARY KEY (x)
        )

    The :class:`.CreateColumn` construct can also be used to skip certain
    columns when producing a ``CREATE TABLE``.  This is accomplished by
    creating a compilation rule that conditionally returns ``None``.
    This is essentially how to produce the same effect as using the
    ``system=True`` argument on :class:`.Column`, which marks a column
    as an implicitly-present "system" column.

    For example, suppose we wish to produce a :class:`.Table` which skips
    rendering of the Postgresql ``xmin`` column against the Postgresql
    backend, but on other backends does render it, in anticipation of a
    triggered rule.  A conditional compilation rule could skip this name only
    on Postgresql::

        from sqlalchemy.schema import CreateColumn

        @compiles(CreateColumn, "postgresql")
        def skip_xmin(element, compiler, **kw):
            if element.element.name == 'xmin':
                return None
            else:
                return compiler.visit_create_column(element, **kw)


        my_table = Table('mytable', metadata,
                    Column('id', Integer, primary_key=True),
                    Column('xmin', Integer)
                )

    Above, a :class:`.CreateTable` construct will generate a ``CREATE TABLE``
    which only includes the ``id`` column in the string; the ``xmin`` column
    will be omitted, but only against the Postgresql backend.

    .. versionadded:: 0.8.3 The :class:`.CreateColumn` construct supports
       skipping of columns by returning ``None`` from a custom compilation
       rule.

    .. versionadded:: 0.8 The :class:`.CreateColumn` construct was added
       to support custom column creation styles.

    t   create_columnc         C   s   | |  _  d  S(   N(   RV   (   R   RV   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRM   W  s    (   R   R   RD   RT   RM   (    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRc   μ  s   ht	   DropTablec           B   s   e  Z d  Z d Z RS(   s!   Represent a DROP TABLE statement.t
   drop_table(   R   R   RD   RT   (    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRh   [  s   t   CreateSequencec           B   s   e  Z d  Z d Z RS(   s&   Represent a CREATE SEQUENCE statement.t   create_sequence(   R   R   RD   RT   (    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRj   a  s   t   DropSequencec           B   s   e  Z d  Z d Z RS(   s$   Represent a DROP SEQUENCE statement.t   drop_sequence(   R   R   RD   RT   (    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRl   g  s   t   CreateIndexc           B   s   e  Z d  Z d Z RS(   s#   Represent a CREATE INDEX statement.t   create_index(   R   R   RD   RT   (    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRn   m  s   t	   DropIndexc           B   s   e  Z d  Z d Z RS(   s!   Represent a DROP INDEX statement.t
   drop_index(   R   R   RD   RT   (    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRp   s  s   t   AddConstraintc           B   s   e  Z d  Z d Z d   Z RS(   s2   Represent an ALTER TABLE ADD CONSTRAINT statement.t   add_constraintc         O   s5   t  t |   j | | |  t j |  j  | _ d  S(   N(   R\   Rr   RM   R    t   portable_instancemethodRX   t   _create_rule(   R   RV   t   argsR   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRM   ~  s    (   R   R   RD   RT   RM   (    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRr   y  s   t   DropConstraintc           B   s    e  Z d  Z d Z e d  Z RS(   s3   Represent an ALTER TABLE DROP CONSTRAINT statement.t   drop_constraintc         K   s;   | |  _  t t |   j | |  t j |  j  | _ d  S(   N(   R_   R\   Rw   RM   R    Rt   RX   Ru   (   R   RV   R_   R   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRM     s    	(   R   R   RD   RT   R/   RM   (    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRw     s   t   DDLBasec           B   s   e  Z d    Z RS(   c         C   s   | |  _  d  S(   N(   R   (   R   R   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRM     s    (   R   R   RM   (    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRy     s   t   SchemaGeneratorc           B   sS   e  Z e d d   Z d   Z d   Z d   Z e d  Z e d  Z	 d   Z
 RS(   c         K   sM   t  t |   j | |  | |  _ | |  _ | j |  _ | |  _ i  |  _ d  S(   N(	   R\   Rz   RM   t
   checkfirstt   tablest   identifier_preparert   preparerR   t   memo(   R   R   R   R{   R|   t   kwargs(    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRM     s    			c         C   s_   |  j  j | j  | j r2 |  j  j | j  n  |  j p^ |  j  j |  j | j d | j S(   Nt   schema(   R   t   validate_identifierR2   R   R{   t	   has_tableR   (   R   t   table(    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyt   _can_create_table   s    	
c      	   C   sP   |  j  j oO |  j  j s# | j oO |  j pO |  j  j |  j | j d | j S(   NR   (	   R   t   supports_sequencest   sequences_optionalt   optionalR{   t   has_sequenceR   R2   R   (   R   t   sequence(    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyt   _can_create_sequence¨  s    

		c   	   	   C   s@  |  j  d  k	 r |  j  } n t | j  j    } g  t |  D] } |  j |  r= | ^ q= } g  | j j   D]* } | j d  k rn |  j |  rn | ^ qn } | j	 j
 | |  j d | d |  j d |  x! | D] } |  j | d t qΠ Wx! | D] } |  j | d t qτ W| j	 j | |  j d | d |  j d |  d  S(   NR|   R{   t   _ddl_runnert	   create_ok(   R|   R   R4   t   valuest   sort_tablesR   t
   _sequencesRd   R   t   dispatcht   before_createR   R{   t   traverse_singleR6   t   after_create(	   R   t   metadataR|   t   tt
   collectionRB   t   seq_collt   seqR   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyt   visit_metadataΆ  s&    *		c         C   sθ   | r |  j  |  r d  S| j j | |  j d |  j d |  x3 | j D]( } | j d  k	 rJ |  j | j  qJ qJ W|  j j	 t
 |   t | d  rΏ x! | j D] } |  j |  q₯ Wn  | j j | |  j d |  j d |  d  S(   NR{   R   t   indexes(   R   R   R   R   R{   Rb   t   defaultR   R   R   R`   t   hasattrR   R   (   R   R   R   Rd   t   index(    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyt   visit_tableΠ  s    		c         C   s5   | r |  j  |  r d  S|  j j t |   d  S(   N(   R   R   R   Rj   (   R   R   R   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyt   visit_sequenceζ  s    c         C   s   |  j  j t |   d  S(   N(   R   R   Rn   (   R   R   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyt   visit_indexλ  s    N(   R   R   R/   R   RM   R   R   R   R   R    R‘   (    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRz     s   			t   SchemaDropperc           B   sS   e  Z e d d   Z d   Z d   Z d   Z d   Z e d  Z	 e d  Z
 RS(   c         K   sM   t  t |   j | |  | |  _ | |  _ | j |  _ | |  _ i  |  _ d  S(   N(	   R\   R’   RM   R{   R|   R}   R~   R   R   (   R   R   R   R{   R|   R   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyRM   ρ  s    			c   	   	   C   sF  |  j  d  k	 r |  j  } n t | j  j    } g  t t |   D] } |  j |  rC | ^ qC } g  | j j   D]* } | j d  k rt |  j	 |  rt | ^ qt } | j
 j | |  j d | d |  j d |  x! | D] } |  j | d t qΦ Wx! | D] } |  j | d t qϊ W| j
 j | |  j d | d |  j d |  d  S(   NR|   R{   R   t   drop_ok(   R|   R   R4   R   t   reversedR   t   _can_drop_tableR   Rd   t   _can_drop_sequenceR   t   before_dropR   R{   R   R6   t
   after_drop(	   R   R   R|   R   R   RB   R   R   R   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyR   ϊ  s&    *		c         C   s^   |  j  j | j  | j r2 |  j  j | j  n  |  j p] |  j  j |  j | j d | j S(   NR   (   R   R   R2   R   R{   R   R   (   R   R   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyR₯     s
    	c      	   C   sO   |  j  j oN |  j  j s# | j oN |  j pN |  j  j |  j | j d | j S(   NR   (	   R   R   R   R   R{   R   R   R2   R   (   R   R   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyR¦   !  s    

		c         C   s   |  j  j t |   d  S(   N(   R   R   Rp   (   R   R   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyR‘   ,  s    c         C   s΅   | r |  j  |  r d  S| j j | |  j d |  j d |  x3 | j D]( } | j d  k	 rJ |  j | j  qJ qJ W|  j j	 t
 |   | j j | |  j d |  j d |  d  S(   NR{   R   (   R₯   R   R§   R   R{   Rb   R   R   R   R   Rh   R¨   (   R   R   R£   Rd   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyR   /  s    		c         C   s5   | r |  j  |  r d  S|  j j t |   d  S(   N(   R¦   R   R   Rl   (   R   R   R£   (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyR    A  s    N(   R   R   R/   R   RM   R   R₯   R¦   R‘   R   R    (    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyR’   ο  s   	 			c            s¨   t       g   | d k	 r.  j |  n      f d   } xL   D]D  t  i t d 6i | d 6  j  f d    j D  qJ Wt  t j      S(   s\   sort a collection of Table objects in order of
                their foreign-key dependency.c            sp   |  j  r d  S r#  |   r# d  S|  j j } |   k rl |  j j } | | k	 rl  j | | f  ql n  d  S(   N(   t	   use_alterRd   R   t   parentt   append(   t   fkeyt   parent_tablet   child_table(   R|   t   skip_fnt   tuples(    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyt   visit_foreign_keyP  s    	t   schema_visitort   foreign_keyc         3   s   |  ] } |   g Vq d  S(   N(    (   t   .0Rͺ   (   R   (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pys	   <genexpr>a  s    N(   R4   R   t   extendR   R6   t   _extra_dependenciesR   t   sort(   R|   R―   t   extra_dependenciesR±   (    (   R|   R―   R°   R   sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyR   G  s    
N($   RD   R%   R    t   elementsR   t   visitorsR   t   baseR   R   R   R   R   R   R	   R
   R   RI   RU   RY   R]   R`   Re   Rc   Rh   Rj   Rl   Rn   Rp   Rr   Rw   Ry   Rz   R’   R   R   (    (    (    sX   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/sql/ddl.pyt   <module>   s6   "ρ
oZX