Files
aitsc/.venv/Lib/site-packages/alembic/autogenerate/__pycache__/rewriter.cpython-312.pyc

130 lines
9.2 KiB
Plaintext
Raw Normal View History

2025-02-23 09:07:52 +08:00
<EFBFBD>
2025-08-16 19:28:45 +08:00
<00><18>h<EFBFBD><00><01>><00>ddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z dd lm
2025-02-23 09:07:52 +08:00
Z
d
d l m Z d
d l mZe rBd
d lmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZeddedgdfZGd<1C>d<1D>Zy)<1E>)<01> annotations)<01>Any)<01>Callable)<01>Iterator)<01>List)<01>Tuple)<01>Type)<01> TYPE_CHECKING)<01>Union<6F>)<01>util)<01>ops)<01> AddColumnOp)<01> AlterColumnOp)<01> CreateTableOp)<01> DowngradeOps)<01>MigrateOperation)<01>MigrationScript)<01>ModifyTableOps)<01> OpContainer)<01>
UpgradeOps)<01>MigrationContext)<01>
_GetRevArgrrrNc<01><><00>eZdZUdZej
<00>ZdZded<dd<05>Z dd<06>Z
dd<07>Z dd<08>Z dd <09>Z ejej <00> dd
<EFBFBD><04>Zejej$<00> dd <0B><04>Zejej(<00> dd <0C><04>Z dd <0A>Z dd<0E>Z dd<0F>Zy)<1B>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
<20>z7Tuple[Union[ProcessRevisionDirectiveFn, Rewriter], ...]<5D>_chainedc<01>6<00>tj<00>|_y<00>N)r <00>
2025-08-16 19:28:45 +08:00
Dispatcher<EFBFBD>dispatch)<01>selfs <20>AD:\aitsc\.venv\Lib\site-packages\alembic\autogenerate\rewriter.py<70>__init__zRewriter.__init__?s<00><00><1C><0F><0F>)<29><04> <0A>c<01><><00>|jj|j<00>}|jj|j<00>|xj|fz c_|S)a<>Produce a "chain" of this :class:`.Rewriter` to another.
2025-02-23 09:07:52 +08:00
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.
)<05> __class__<5F>__new__<5F>__dict__<5F>updater)r"<00>other<65>wrs r#<00>chainzRewriter.chainBsH<00><00>H<12>^<5E>^<5E> #<23> #<23>D<EFBFBD>N<EFBFBD>N<EFBFBD> 3<><02>
<EFBFBD> <0B> <0B><1A><1A>4<EFBFBD>=<3D>=<3D>)<29>
<EFBFBD> <0B> <0B><05>x<EFBFBD><1F> <0B><11> r%c<01>8<00>|jj|<01>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!<00> dispatch_for)r"<00>operators r#<00>rewriteszRewriter.rewritesks<00><00>,<14>}<7D>}<7D>)<29>)<29>(<28>3<>3r%c#<01>$K<00> |jj|<03>}||jvr|<03><01>ytj||||<03>g<00>D]'}|jj |g<01>|_|<05><01><00>)y#t
$r d}|<03><02>YywxYw<01>wr)r!<00>
_mutationsr <00>to_list<73>union<6F>
ValueError)r"<00>context<78>revision<6F> directive<76> _rewriter<65> r_directives r#<00>_rewritezRewriter._rewrite<74>s<><00><00><><00>  &<26><1C> <0A> <0A>.<2E>.<2E>y<EFBFBD>9<>I<EFBFBD>
<14>y<EFBFBD>+<2B>+<2B>+<2B><1F><0F>#'<27><<3C><<3C><1D>g<EFBFBD>x<EFBFBD><19>;<3B>R<EFBFBD>$<12>K<EFBFBD>.9<EFBFBD>-C<>-C<>-I<>-I<><1D><06>.<16>K<EFBFBD>*<2A>&<26>%<25> $<12><><1A> <1C><1C>I<EFBFBD><1B>O<EFBFBD> <1C>s(<00>B<01>A;<00>AB<01>;B <03>
B<01> B <03> Bc<01>`<00>|j|||<03>|jD] }||||<03><00>yr)<02>process_revision_directivesr)r"r7r8<00>
directivesr>s r#<00>__call__zRewriter.__call__<5F>s1<00><00> <0A>(<28>(<28><17>(<28>J<EFBFBD>G<>+/<2F>=<3D>=<3D> '<27> '<27><07><18>:<3A> F<>,9r%c<01>l<00>g}|jD]B}|j|||<05>}t|<06>dk7r td<02><00>|j |d<00><00>D||_g}|j D]B}|j|||<08>}t|<06>dk7r td<04><00>|j |d<00><00>D||_y)N<>z5Can only return single object for UpgradeOps traverserz7Can only return single object for DowngradeOps traverse)<08>upgrade_ops_list<73> _traverse_for<6F>lenr6<00>append<6E> upgrade_ops<70>downgrade_ops_list<73> downgrade_ops) r"r7r8r9rCrG<00>retrHrIs r#<00>_traverse_scriptzRewriter._traverse_script<70>s<><00><00>.0<EFBFBD><18>$<24>5<>5<>K<EFBFBD><16>$<24>$<24>W<EFBFBD>h<EFBFBD> <0B>D<>C<EFBFBD><12>3<EFBFBD>x<EFBFBD>1<EFBFBD>}<7D> <20>K<><12><12> <1D> #<23> #<23>C<EFBFBD><01>F<EFBFBD> +<2B> 6<>!1<> <09><1D>13<31><1A>&<26>9<>9<>M<EFBFBD><16>$<24>$<24>W<EFBFBD>h<EFBFBD> <0A>F<>C<EFBFBD><12>3<EFBFBD>x<EFBFBD>1<EFBFBD>}<7D> <20>M<><12><12> <1F> %<25> %<25>c<EFBFBD>!<21>f<EFBFBD> -<2D> :<3A>#5<> <09>r%c<01>><00>|j|||j<00>yr)<02>_traverse_listr<00>r"r7r8r9s r#<00>_traverse_op_containerzRewriter._traverse_op_container<65>s<00><00> <0A><1B><1B>G<EFBFBD>X<EFBFBD>y<EFBFBD>}<7D>}<7D>=r%c<01><00>yrrrNs r#<00>_traverse_any_directivez Rewriter._traverse_any_directive<76>s<00><00> r%c<01><><00>t|j|||<03><00>}|D](}|jj|<03>}|||||<03><00>*|Sr)<04>listr<<00> _traverser!)r"r7r8r9r?<00> traversers r#rDzRewriter._traverse_for<6F>sO<00><00> <1A>$<24>-<2D>-<2D><07><18>9<EFBFBD>E<>F<>
<EFBFBD>#<23>I<EFBFBD><1C><0E><0E>/<2F>/<2F> <09>:<3A>I<EFBFBD> <15>d<EFBFBD>G<EFBFBD>X<EFBFBD>y<EFBFBD> 9<>$<24><1A>r%c<01>d<00>g}|D]$}|j|j|||<05><00><00>&||ddyr)<02>extendrD)r"r7r8r?<00>destr9s r#rMzRewriter._traverse_list<73>s9<00><00> <12><04>#<23>I<EFBFBD> <10>K<EFBFBD>K<EFBFBD><04>*<2A>*<2A>7<EFBFBD>H<EFBFBD>i<EFBFBD>H<> I<>$<24><1D>
<EFBFBD>1<EFBFBD> r%c<01>*<00>|j|||<03>yr)rM)r"r7r8r?s r#r>z$Rewriter.process_revision_directives<65>s<00><00> <0A><1B><1B>G<EFBFBD>X<EFBFBD>z<EFBFBD>:r%N)<02>return<72>None)r+z+Union[ProcessRevisionDirectiveFn, Rewriter]rZr)r0zpUnion[Type[AddColumnOp], Type[MigrateOperation], Type[AlterColumnOp], Type[CreateTableOp], Type[ModifyTableOps]]rZzCallable[..., Any])r7rr8rr9rrZzIterator[MigrateOperation])r7rr8rr?zList[MigrationScript]rZr[)r7rr8rr9rrZr[)r7rr8rr9rrZr[)r7rr8rr9rrZr[)r7rr8rr9rrZr)r7rr8rr?rrZr[)<19>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__r r rTr<00>__annotations__r$r-r1r<r@r/rrrKrrOrrQrDrMr>rr%r#rr!s<00><00><08>2 <20><04><0F><0F>!<21>I<EFBFBD>HJ<48>H<EFBFBD>E<>J<>*<2A>'<12>
<EFBFBD>'<12>
<12> '<12>R4<>
<EFBFBD>4<>
<1C>4<>0&<26>!<21>&<26><1D>&<26>$<24> &<26>
$<24> &<26>.G<01>!<21>G<01><1D>G<01>*<2A> G<01>
<0E> G<01><0F><1B><1B>C<EFBFBD>/<2F>/<2F>0<>5<>!<21>5<><1D>5<>#<23> 5<>
<0E> 5<>1<>5<>6<0F><1B><1B>C<EFBFBD>O<EFBFBD>O<EFBFBD>,<2C>><3E>!<21>><3E><1D>><3E><1F> ><3E>
<0E> ><3E>-<2D>><3E><0F><1B><1B>C<EFBFBD>0<>0<>1<> <0A>!<21> <0A><1D> <0A>$<24>  <0A>
<0E>  <0A>2<> <0A>
<1A>!<21>
<1A><1D>
<1A>$<24>
<1A>
<0A>
<1A>
<1D>!<21>
<1D><1D>
<1D><18>
<1D>
<0E>
<1D>;<3B>!<21>;<3B><1D>;<3B>*<2A> ;<3B>
<0E> ;r%r)<1F>
__future__r<00>typingrrrrrr r
r <00>r <00>
operationsr<00>operations.opsrrrrrrrrr<00>runtime.migrationr<00>script.revisionr<00>ProcessRevisionDirectiveFnrrr%r#<00><module>risv<00><01>"<22><16><1B><1B><17><18><17> <20><18><13><1C><10>,<2C>.<2E>.<2E>-<2D>1<>0<>/<2F>,<2C>+<2B>4<>,<2C>%<25><17><1C>t<EFBFBD>,=<3D>'><3E>?<3F><14>E<><02><1A>
O;<3B>O;r%