%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python27/lib/python2.7/site-packages/alembic/autogenerate/
Upload File :
Create Path :
Current File : //opt/alt/python27/lib/python2.7/site-packages/alembic/autogenerate/rewriter.pyc

�
�M!Vc@s:ddlmZddlmZdefd��YZdS(i����(tutil(topstRewritercBs�eZdZej�ZdZd�Zd�Z	d�Z
d�Zd�Zej
ej�d��Zej
ej�d��Zej
ej�d��Zd	�Zd
�Zd�ZRS(
sPA helper object that allows easy 'rewriting' of ops streams.

    The :class:`.Rewriter` object is intended to be passed along
    to the
    :paramref:`.EnvironmentContext.configure.process_revision_directives`
    parameter in an ``env.py`` script.    Once constructed, any number
    of "rewrites" functions can be associated with it, which will be given
    the opportunity to modify the structure without having to have explicit
    knowledge of the overall structure.

    The function is passed the :class:`.MigrationContext` object and
    ``revision`` tuple that are passed to the  :paramref:`.Environment
    Context.configure.process_revision_directives` function normally,
    and the third argument is an individual directive of the type
    noted in the decorator.  The function has the choice of  returning
    a single op directive, which normally can be the directive that
    was actually passed, or a new directive to replace it, or a list
    of zero or more directives to replace it.

    .. seealso::

        :ref:`autogen_rewriter` - usage example

    .. versionadded:: 0.8

    cCstj�|_dS(N(Rt
Dispatchertdispatch(tself((sN/opt/alt/python27/lib/python2.7/site-packages/alembic/autogenerate/rewriter.pyt__init__%scCs5|jj|j�}|jj|j�||_|S(s�Produce a "chain" of this :class:`.Rewriter` to another.

        This allows two rewriters to operate serially on a stream,
        e.g.::

            writer1 = autogenerate.Rewriter()
            writer2 = autogenerate.Rewriter()

            @writer1.rewrites(ops.AddColumnOp)
            def add_column_nullable(context, revision, op):
                op.column.nullable = True
                return op

            @writer2.rewrites(ops.AddColumnOp)
            def add_column_idx(context, revision, op):
                idx_op = ops.CreateIndexOp(
                    'ixc', op.table_name, [op.column.name])
                return [
                    op,
                    idx_op
                ]

            writer = writer1.chain(writer2)

        :param other: a :class:`.Rewriter` instance
        :return: a new :class:`.Rewriter` that will run the operations
         of this writer, then the "other" writer, in succession.

        (t	__class__t__new__t__dict__tupdatet_chained(Rtothertwr((sN/opt/alt/python27/lib/python2.7/site-packages/alembic/autogenerate/rewriter.pytchain(s	cCs|jj|�S(s�Register a function as rewriter for a given type.

        The function should receive three arguments, which are
        the :class:`.MigrationContext`, a ``revision`` tuple, and
        an op directive of the type indicated.  E.g.::

            @writer1.rewrites(ops.AddColumnOp)
            def add_column_nullable(context, revision, op):
                op.column.nullable = True
                return op

        (Rtdispatch_for(Rtoperator((sN/opt/alt/python27/lib/python2.7/site-packages/alembic/autogenerate/rewriter.pytrewritesKs
ccsdy|jj|�}Wntk
r4d}|Vn,Xx(tj||||��D]}|VqQWdS(N(Rt
ValueErrortNoneRtto_list(Rtcontexttrevisiont	directivet	_rewritertr_directive((sN/opt/alt/python27/lib/python2.7/site-packages/alembic/autogenerate/rewriter.pyt_rewriteZs
		cCs6|j|||�|jr2|j|||�ndS(N(tprocess_revision_directivesR(RRRt
directives((sN/opt/alt/python27/lib/python2.7/site-packages/alembic/autogenerate/rewriter.pyt__call__es	c	Cs�g}x[|jD]P}|j|||j�}t|�dkrOtd��n|j|d�qW||_g}x[|jD]P}|j|||j�}t|�dkr�td��n|j|d�q}W||_dS(Nis5Can only return single object for UpgradeOps traverseis7Can only return single object for DowngradeOps traverse(tupgrade_ops_listt
_traverse_fortupgrade_opstlenRtappendtdowngrade_ops_listt
downgrade_ops(	RRRRRR tretR#R$((sN/opt/alt/python27/lib/python2.7/site-packages/alembic/autogenerate/rewriter.pyt_traverse_scriptjs"	cCs|j|||j�dS(N(t_traverse_listR(RRRR((sN/opt/alt/python27/lib/python2.7/site-packages/alembic/autogenerate/rewriter.pyt_traverse_op_containerscCsdS(N((RRRR((sN/opt/alt/python27/lib/python2.7/site-packages/alembic/autogenerate/rewriter.pyt_traverse_any_directive�scCsUt|j|||��}x3|D]+}|jj|�}|||||�q"W|S(N(tlistRt	_traverseR(RRRRRt	traverser((sN/opt/alt/python27/lib/python2.7/site-packages/alembic/autogenerate/rewriter.pyR�s

cCs>g}x*|D]"}|j|j|||��q
W||(dS(N(textendR(RRRRtdestR((sN/opt/alt/python27/lib/python2.7/site-packages/alembic/autogenerate/rewriter.pyR'�s
 cCs|j|||�dS(N(R'(RRRR((sN/opt/alt/python27/lib/python2.7/site-packages/alembic/autogenerate/rewriter.pyR�sN(t__name__t
__module__t__doc__RRR+RRRRRRRRRtMigrationScriptR&tOpContainerR(tMigrateOperationR)RR'R(((sN/opt/alt/python27/lib/python2.7/site-packages/alembic/autogenerate/rewriter.pyRs		#					N(talembicRtalembic.operationsRtobjectR(((sN/opt/alt/python27/lib/python2.7/site-packages/alembic/autogenerate/rewriter.pyt<module>s

Zerion Mini Shell 1.0