§ ”¢bgãó—ddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd l m Z dd l mZe r6dd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZGd„d¦«ZdS)é)Ú annotations)ÚAny)ÚCallable)ÚIterator)ÚList)ÚOptional)ÚType)Ú TYPE_CHECKING)ÚUnion)Úutil)Úops)Ú AddColumnOp)Ú AlterColumnOp)Ú CreateTableOp)ÚMigrateOperation)ÚMigrationScript)ÚModifyTableOps)Ú OpContainer)ÚMigrationContext)ÚRevisioncóX—eZdZUdZej¦«ZdZded<d"d„Z d#d „Z d$d „Z d%d„Z d&d„Z e ej¦«d'd„¦«Ze ej¦«d(d„¦«Ze ej¦«d)d„¦«Zd*d„Zd+d „Zd&d!„ZdS),ÚRewritera5A 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 NzOptional[Rewriter]Ú_chainedÚreturnÚNonecó6—tj¦«|_dS©N)r Ú DispatcherÚdispatch)Úselfs úT/opt/cloudlinux/venv/lib64/python3.11/site-packages/alembic/autogenerate/rewriter.pyÚ__init__zRewriter.__init__9s€ÝœÑ)Ô)ˆŒ ˆ ˆ óÚothercó—|j |j¦«}|j |j¦«||_|S)a’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. )Ú __class__Ú__new__Ú__dict__Úupdater)r r$Úwrs r!ÚchainzRewriter.chain<s?€ð<Œ^× #Ò # D¤NÑ 3Ô 3ˆØ Œ ×Ò˜4œ=Ñ)Ô)Ð)؈Œ ؈ r#ÚoperatorúpUnion[Type[AddColumnOp], Type[MigrateOperation], Type[AlterColumnOp], Type[CreateTableOp], Type[ModifyTableOps]]rcó6—|j |¦«S)a¤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 r,s r!ÚrewriteszRewriter.rewrites_s€ð,Œ}×)Ò)¨(Ñ3Ô3Ð3r#ÚcontextrÚrevisionrÚ directiverúIterator[MigrateOperation]c#óK— |j |¦«}||jvr|V—dStj||||¦«g¦«D]&}|j |g¦«|_|V—Œ'dS#t $r d}|V—YdSwxYwr)rÚ _mutationsr Úto_listÚunionÚ ValueError)r r1r2r3Ú _rewriterÚ r_directives r!Ú_rewritezRewriter._rewritewsÙèè€ð  &Øœ ×.Ò.¨yÑ9Ô9ˆIð yÔ+Ð+Ð+Øå#'¤<ØI˜g x°Ñ;Ô;¸Rñ$ô$ð&ð&Kð.9Ô-C×-IÒ-Iؘñ.ô.KÔ*ð&Ð%Ð%Ð%Ð%ð &ð&øõð ð ð ؈I؈OˆOˆOˆOˆOˆOð øøøs„A6Á6B  B Ú directivesúList[MigrationScript]cót—| |||¦«|jr| |||¦«dSdSr)Úprocess_revision_directivesr©r r1r2r=s r!Ú__call__zRewriter.__call__ŽsL€ð ×(Ò(¨°(¸JÑGÔGÐGØ Œ=ð 9Ø MŠM˜' 8¨ZÑ 8Ô 8Ð 8Ð 8Ð 8ð 9ð 9r#rcó¢—g}|jD]V}| |||¦«}t|¦«dkrtd¦«‚| |d¦«ŒW||_g}|jD]V}| |||¦«}t|¦«dkrtd¦«‚| |d¦«ŒW||_dS)Néz5Can only return single object for UpgradeOps traverserz7Can only return single object for DowngradeOps traverse)Úupgrade_ops_listÚ _traverse_forÚlenr9ÚappendÚ upgrade_opsÚdowngrade_ops_listÚ downgrade_ops) r r1r2r3rErIÚretrJrKs r!Ú_traverse_scriptzRewriter._traverse_script˜sú€ðÐØ$Ô5ð ,ð ,ˆKØ×$Ò$ W¨h¸ ÑDÔDˆCÝ3‰xŒx˜1Š}ˆ}Ý ØKñôðð × #Ò # C¨¤FÑ +Ô +Ð +Ð +Ø 0ˆ ÔàÐØ&Ô9ð .ð .ˆMØ×$Ò$ W¨h¸ ÑFÔFˆCÝ3‰xŒx˜1Š}ˆ}Ý ØMñôðð × %Ò % c¨!¤fÑ -Ô -Ð -Ð -Ø"4ˆ ÔÐÐr#rcó>—| |||j¦«dSr)Ú_traverse_listr ©r r1r2r3s r!Ú_traverse_op_containerzRewriter._traverse_op_container³s$€ð ×Ò˜G X¨y¬}Ñ=Ô=Ð=Ð=Ð=r#có—dSr©rPs r!Ú_traverse_any_directivez Rewriter._traverse_any_directive¼s €ð ˆr#rcó¨—t| |||¦«¦«}|D]*}|j |¦«}|||||¦«Œ+|Sr)Úlistr<Ú _traverser)r r1r2r3r=Ú traversers r!rFzRewriter._traverse_forÅsd€õ ˜$Ÿ-š-¨°¸9ÑEÔEÑFÔFˆ Ø#ð :ð :ˆIØœ×/Ò/° Ñ:Ô:ˆIØ ˆId˜G X¨yÑ 9Ô 9Ð 9Ð 9ØÐr#cóv—g}|D],}| | |||¦«¦«Œ-||dd…<dSr)ÚextendrF)r r1r2r=Údestr3s r!rOzRewriter._traverse_listÑsR€ð ˆØ#ð Jð JˆIØ KŠK˜×*Ò*¨7°H¸iÑHÔHÑ IÔ IÐ IÐ Iàˆ 111‰ ˆ ˆ r#có4—| |||¦«dSr)rOrAs r!r@z$Rewriter.process_revision_directivesÝs"€ð ×Ò˜G X¨zÑ:Ô:Ð:Ð:Ð:r#)rr)r$rrr)r,r-rr)r1rr2rr3rrr4)r1rr2rr=r>rr)r1rr2rr3rrr)r1rr2rr3rrr)r1rr2rr3rrr)r1rr2rr3rrr)r1rr2rr=rrr)Ú__name__Ú __module__Ú __qualname__Ú__doc__r rrWrÚ__annotations__r"r+r0r<rBr/r rrMrrQrrTrFrOr@rSr#r!rrsx€€€€€€ððð2 ”Ñ!Ô!€Ià#'€HÐ'Ð'Ð'Ñ'ð*ð*ð*ð*ð!ð!ð!ð!ðF4ð4ð4ð4ð0&ð&ð&ð&ð.9ð9ð9ð9ð×Ò˜CÔ/Ñ0Ô0ð5ð5ð5ñ1Ô0ð5ð4×Ò˜CœOÑ,Ô,ð>ð>ð>ñ-Ô,ð>ð×Ò˜CÔ0Ñ1Ô1ð ð ð ñ2Ô1ð ð ð ð ð ð ð ð ð ð;ð;ð;ð;ð;ð;r#rN)Ú __future__rÚtypingrrrrrr r r Úalembicr Úalembic.operationsr Úalembic.operations.opsrrrrrrrÚalembic.runtime.migrationrÚalembic.script.revisionrrrSr#r!úris±ðØ"Ð"Ð"Ð"Ð"Ð"àÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØ Ð Ð Ð Ð Ð ØÐÐÐÐÐàÐÐÐÐÐØ"Ð"Ð"Ð"Ð"Ð"àð 1Ø2Ð2Ð2Ð2Ð2Ð2Ø4Ð4Ð4Ð4Ð4Ð4Ø4Ð4Ð4Ð4Ð4Ð4Ø7Ð7Ð7Ð7Ð7Ð7Ø6Ð6Ð6Ð6Ð6Ð6Ø5Ð5Ð5Ð5Ð5Ð5Ø2Ð2Ð2Ð2Ð2Ð2Ø:Ð:Ð:Ð:Ð:Ð:Ø0Ð0Ð0Ð0Ð0Ð0ðH;ðH;ðH;ðH;ðH;ñH;ôH;ðH;ðH;ðH;r#