ó
    úÞ jü  ã                  ó  • S SK Jr  S SKJr  S SKJr  S SKJr  S SKJr  SSKJ	r	  SSK
Jr  \(       aB  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  \SS\S   /S4   r " S S5      rg)é    )Úannotations)ÚIterator)ÚAny)ÚCallable)ÚTYPE_CHECKINGé   )Úutil)Úops)ÚAddColumnOp)ÚAlterColumnOp)ÚCreateTableOp)ÚDowngradeOps)ÚMigrateOperation)ÚMigrationScript)ÚModifyTableOps)ÚOpContainer)Ú
UpgradeOps)ÚMigrationContext)Ú
_GetRevArgr   r   r   Nc                  óü  • \ rS rSr% Sr\R                  " 5       rSrS\	S'   SS jr
    SS jr    SS jr        SS	 jr        SS
 jr\R                  \R"                  5              SS j5       r\R                  \R&                  5              SS j5       r\R                  \R*                  5              SS j5       r        SS jr        SS jr        SS jrSrg)ÚRewriteré   aí  A 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

© z1tuple[ProcessRevisionDirectiveFn | Rewriter, ...]Ú_chainedc                ó8   • [         R                  " 5       U l        g ©N)r	   Ú
DispatcherÚdispatch)Úselfs    ÚW/var/www/html/gaurav/venv/lib/python3.13/site-packages/alembic/autogenerate/rewriter.pyÚ__init__ÚRewriter.__init__;   s   € ÜŸšÓ)ˆ�ó    c                óÆ   • U R                   R                  U R                   5      nUR                  R                  U R                  5        U=R                  U4-  sl        U$ )a  Produce a "chain" of this :class:`.Rewriter` to another.

This allows two or more 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.

)Ú	__class__Ú__new__Ú__dict__Úupdater   )r   ÚotherÚwrs      r    ÚchainÚRewriter.chain>   sH   € ðB �^‰^×#Ñ# D§N¡NÓ3ˆØ
�‰×Ñ˜4Ÿ=™=Ô)Ø
�Š˜�xÑ�Øˆ	r#   c                ó8   • U R                   R                  U5      $ )ad  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

)r   Údispatch_for)r   Úoperators     r    ÚrewritesÚRewriter.rewritesd   s   € ð, �}‰}×)Ñ)¨(Ó3Ð3r#   c              #  ó,  #   •  U R                   R                  U5      nXR                  ;   a  Uv •  g [        R                  " U" XU5      / 5       H(  nUR                  R	                  U /5      Ul        Uv •  M*     g ! [
         a	    S nUv •   g f = f7fr   )r   Ú
_mutationsr	   Úto_listÚunionÚ
ValueError)r   ÚcontextÚrevisionÚ	directiveÚ	_rewriterÚr_directives         r    Ú_rewriteÚRewriter._rewrite|   s’   é € ð	&ØŸ™×.Ñ.¨yÓ9ˆIð
 ×+Ñ+Ó+Ø“ä#'§<¢<Ù˜g°Ó;¸Rö$�Kð .9×-CÑ-C×-IÑ-IØ˜ó.�KÔ*ð &Ô%ò$øô ó 	ØˆIØŒOð	üs(   ‚B„A> ŸABÁ>BÂBÂBÂBc                ó`   • U R                  XU5        U R                   H  nU" XU5        M     g r   )Úprocess_revision_directivesr   )r   r7   r8   Ú
directivesr?   s        r    Ú__call__ÚRewriter.__call__“   s-   € ð 	×(Ñ(¨¸JÔGØ+/¯=¬=Ð'Ù'¨¸:ÖFò ,9r#   c                óp  • / nUR                    HC  nU R                  XU5      n[        U5      S:w  a  [        S5      eUR	                  US   5        ME     XCl        / nUR                   HC  nU R                  XU5      n[        U5      S:w  a  [        S5      eUR	                  US   5        ME     Xsl        g )Né   z5Can only return single object for UpgradeOps traverser   z7Can only return single object for DowngradeOps traverse)Úupgrade_ops_listÚ_traverse_forÚlenr6   ÚappendÚupgrade_opsÚdowngrade_ops_listÚdowngrade_ops)	r   r7   r8   r9   rE   rI   ÚretrJ   rK   s	            r    Ú_traverse_scriptÚRewriter._traverse_script�   sÂ   € ð .0ÐØ$×5Ô5ˆKØ×$Ñ$ W¸ÓDˆCÜ�3‹x˜1‹}Ü ØKóð ð ×#Ñ# C¨¡FÖ+ñ 6ð !1Ôà13ÐØ&×9Ô9ˆMØ×$Ñ$ W¸ÓFˆCÜ�3‹x˜1‹}Ü ØMóð ð ×%Ñ% c¨!¡fÖ-ñ :ð #5Õr#   c                ó<   • U R                  XUR                  5        g r   )Ú_traverse_listr
   ©r   r7   r8   r9   s       r    Ú_traverse_op_containerÚRewriter._traverse_op_container¹   s   € ð 	×Ñ˜G¨y¯}©}Õ=r#   c                ó   • g r   r   rQ   s       r    Ú_traverse_any_directiveÚ Rewriter._traverse_any_directiveÂ   s   € ð 	r#   c                ó–   • [        U R                  XU5      5      nU H'  nU R                  R                  U5      nU" XX#5        M)     U$ r   )Úlistr<   Ú	_traverser   )r   r7   r8   r9   r@   Ú	traversers         r    rF   ÚRewriter._traverse_forË   sI   € ô ˜$Ÿ-™-¨¸9ÓEÓFˆ
Û#ˆIØŸ™×/Ñ/°	Ó:ˆIÙ�d XÖ9ñ $ð Ðr#   c                ód   • / nU H$  nUR                  U R                  XU5      5        M&     XCS S & g r   )ÚextendrF   )r   r7   r8   r@   Údestr9   s         r    rP   ÚRewriter._traverse_list×   s5   € ð ˆÛ#ˆIØ�K‰K˜×*Ñ*¨7¸iÓHÖIñ $ð ‘1‰r#   c                ó(   • U R                  XU5        g r   )rP   )r   r7   r8   r@   s       r    r?   Ú$Rewriter.process_revision_directivesã   s   € ð 	×Ñ˜G¨zÕ:r#   )r   N)ÚreturnÚNone)r)   z%ProcessRevisionDirectiveFn | Rewriterrb   r   )r/   zmtype[AddColumnOp] | type[MigrateOperation] | type[AlterColumnOp] | type[CreateTableOp] | type[ModifyTableOps]rb   zCallable[..., Any])r7   r   r8   r   r9   r   rb   zIterator[MigrateOperation])r7   r   r8   r   r@   zlist[MigrationScript]rb   rc   )r7   r   r8   r   r9   r   rb   rc   )r7   r   r8   r   r9   r   rb   rc   )r7   r   r8   r   r9   r   rb   rc   )r7   r   r8   r   r9   r   rb   r   )r7   r   r8   r   r@   r   rb   rc   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r	   r   rY   r   Ú__annotations__r!   r+   r0   r<   rA   r.   r
   r   rM   r   rR   r   rU   rF   rP   r?   Ú__static_attributes__r   r#   r    r   r      s  ‡ ñð2 —’Ó!€IàBD€HÐ?ÓDô*ð$à4ð$ð 
ô$ðL4ð#ð4ð 
ô4ð0&à!ð&ð ð&ð $ð	&ð
 
$ô&ð.Gà!ðGð ðGð *ð	Gð
 
ôGð ×Ñ˜C×/Ñ/Ó0ð5à!ð5ð ð5ð #ð	5ð
 
ó5ó 1ð5ð6 ×Ñ˜CŸO™OÓ,ð>à!ð>ð ð>ð ð	>ð
 
ó>ó -ð>ð ×Ñ˜C×0Ñ0Ó1ðà!ðð ðð $ð	ð
 
óó 2ðð
à!ð
ð ð
ð $ð	
ð
 
ô
ð
à!ð
ð ð
ð ð	
ð
 
ô
ð;à!ð;ð ð;ð *ð	;ð
 
÷;r#   r   )Ú
__future__r   Úcollections.abcr   Útypingr   r   r   Ú r	   Ú
operationsr
   Úoperations.opsr   r   r   r   r   r   r   r   r   Úruntime.migrationr   Úscript.revisionr   rX   ÚProcessRevisionDirectiveFnr   r   r#   r    Ú<module>rt      sj   ðÝ "å $Ý Ý Ý  å Ý æÝ,Ý.Ý.Ý-Ý1Ý0Ý/Ý,Ý+Ý4Ý,à%Ø˜ tÐ,=Ñ'>Ð?ÀÐEñÐ ÷
L;ò L;r#   