
    -jiK                        S SK Jr  S SKJr  S SKrS SK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  \(       a  SSKJr  0 r\R$                  " \5      r " S S5      rSS jrSS jr\" 5         g)    )annotations)metadataN)
ModuleType)Callable)Pattern)TYPE_CHECKING   )util)DispatchPriority)PriorityDispatcher)PriorityDispatchResultc                      \ rS rSrSrSS jrSS jr SS\R                  S.           SS jjjr	\
      SS	 j5       r\
SS
 j5       rSrg)Plugin   a  Describe a series of functions that are pulled in as a plugin.

This is initially to provide for portable lists of autogenerate
comparison functions, however the setup for a plugin can run any
other kinds of global registration as well.

.. versionadded:: 1.18.0

c                    Xl         [        R                  SU5        U[        ;   a  [	        SU S35      eU [        U'   [        5       U l        g )Nzsetup plugin %szA plugin named z is already registered)nameloginfo_all_plugins
ValueErrorr   autogenerate_comparators)selfr   s     Q/home/james-whalen/.local/lib/python3.13/site-packages/alembic/runtime/plugins.py__init__Plugin.__init__#   sH    	"D)<tf4JKLL!T(:(<%    c                &    [         U R                  	 g)zremove this pluginN)r   r   )r   s    r   removePlugin.remove+   s     #r   Ndefault)	qualifierpriorityc               H    U R                   R                  UUUUS9" U5        g)a  Register an autogenerate comparison function.

See the section :ref:`plugins_registering_autogenerate` for detailed
examples on how to use this method.

:param fn: The comparison function to register. The function receives
 arguments specific to the type of comparison being performed and
 should return a :class:`.PriorityDispatchResult` value.

:param compare_target: The type of comparison being performed
 (e.g., ``"table"``, ``"column"``, ``"type"``).

:param compare_element: Optional sub-element being compared within
 the target type.

:param qualifier: Database dialect qualifier. Use ``"default"`` for
 all dialects, or specify a dialect name like ``"postgresql"`` to
 register a dialect-specific handler. Defaults to ``"default"``.

:param priority: Execution priority for this comparison function.
 Functions are executed in priority order from
 :attr:`.DispatchPriority.FIRST` to :attr:`.DispatchPriority.LAST`.
 Defaults to :attr:`.DispatchPriority.MEDIUM`.

)subgroupr"   r!   N)r   dispatch_for)r   fncompare_targetcompare_elementr!   r"   s         r   add_autogenerate_comparator"Plugin.add_autogenerate_comparator0   s4    D 	%%22$	 	3 	

 	r   c                  ^
 [        5       n0 n[        5       nU HE  nUR                  S5      (       a  UR                  [        USS 5      5        M8  [        U5      XF'   MG     [        R                  5        H  m
[        U
4S jU 5       5      (       a  M  U Vs/ s H)  otU   R                  T
R                  5      (       d  M'  UPM+     nnU(       d  M^  UR                  U5        [        R                  ST
R                  5        UR                  T
R                  5        M     [        U5      R                  U5      n	U	(       a(  [        R                   " SSR#                  U	5       35      egs  snf )zWPopulate all current autogenerate comparison functions into
a given PriorityDispatcher.~   Nc              3  X   >#    U  H  oR                  TR                  5      v   M!     g 7fN)matchr   ).0exclplugins     r   	<genexpr>APlugin.populate_autogenerate_priority_dispatch.<locals>.<genexpr>l   s     ?wt::fkk**ws   '*z!setting up autogenerate plugin %szDid not locate plugins: z, )set
startswithadd_make_rer   valuesanyr0   r   updater   r   populate_withr   
differencer
   CommandErrorjoin)clscomparatorsinclude_pluginsexcludeincludematched_expressionsr   inclinclude_matchesnever_matchedr3   s             @r   'populate_autogenerate_priority_dispatch.Plugin.populate_autogenerate_priority_dispatchY   s6    &)U+-(+#Ds##HT!"X./ (	 $ #))+F?w??? ")!(DM,?,?,L   ##**?;HH8&++F%%f&E&EF , G//0CD##*499]+C*DE  s   &E/E/c                8    UR                  [        U5      5        g)a  Call the ``setup()`` function of a plugin module, identified by
passing the module object itself.

E.g.::

    from alembic.runtime.plugins import Plugin
    import myproject.alembic_plugin

    # Register the plugin manually
    Plugin.setup_plugin_from_module(
        myproject.alembic_plugin,
        "myproject.custom_operations"
    )

This will generate a new :class:`.Plugin` object with the given
name, which will register itself in the global list of plugins.
Then the module's ``setup()`` function is invoked, passing that
:class:`.Plugin` object.

This exact process is invoked automatically at import time for any
plugin module that is published via the ``alembic.plugins`` entrypoint.

N)setupr   )rA   moduler   s      r   setup_plugin_from_modulePlugin.setup_plugin_from_module   s    2 	VD\"r   )r   r   )r   strreturnNoner/   )r&   z%Callable[..., PriorityDispatchResult]r'   rQ   r(   z
str | Noner!   rQ   r"   r   rS   rT   )rB   r   rC   z	list[str]rS   rT   )rN   r   r   rQ   rS   rT   )__name__
__module____qualname____firstlineno____doc__r   r   r   MEDIUMr)   classmethodrJ   rO   __static_attributes__ r   r   r   r      s    =$ '+	' #%5%<%<'1' ' $	' ' #' 
'R $,$?H$	$ $L # #r   r   c                    U R                  S5      nSnU H<  nUS:X  a  US-  nM  UR                  5       (       a
  USU-   -  nM/  [        SU < 35      e   [        R                  " SUSS   S	35      $ )
N. *z\..+?z\.zInvalid plugin expression ^r	   $)splitisidentifierr   recompile)r   tokensregtokens       r   r9   r9      s}    ZZ_F
CC<8OC!!55= C9$BCC  ::#ab'!n%%r   c                     [         R                  " SS9 H9  n U R                  5        H"  n[        R	                  XR
                  5        M$     M;     g )Nzalembic.plugins)group)r   entry_pointsloadr   rO   r   )
entrypointmods     r   _setuprq      s<    ++2CD
??$C++CA % Er   )r   rQ   rS   zPattern[str]rR   )
__future__r   	importlibr   loggingrf   typesr   typingr   r   r   r`   r
   r   r   r   r   	getLoggerrU   r   r   r9   rq   r]   r   r   <module>rx      sb    "   	       # %- !A# A#H& B r   