Ë
    ýÿæiK  ã                  óê   — d dl mZ d dlmZ d dlZd dlZd dlmZ d dlm	Z	 d dlm
Z
 d dlmZ dd	lmZ dd
lmZ ddlmZ erddlmZ i Z ej$                  e«      Z G d„ d«      Zdd„Zdd„Z e«        y)é    )Úannotations)ÚmetadataN)Ú
ModuleType)ÚCallable)ÚPattern)ÚTYPE_CHECKINGé   )Úutil)ÚDispatchPriority)ÚPriorityDispatcher)ÚPriorityDispatchResultc                  óŽ   — e Zd ZdZd
d„Zdd„Z	 ddej                  dœ	 	 	 	 	 	 	 	 	 	 	 dd„Ze		 	 	 	 	 	 dd„«       Z
e	dd	„«       Zy)ÚPlugina  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                óœ   — || _         t        j                  d|«       |t        v rt	        d|› d�«      ‚| t        |<   t        «       | _        y )Nzsetup plugin %szA plugin named z is already registered)ÚnameÚlogÚinfoÚ_all_pluginsÚ
ValueErrorr   Úautogenerate_comparators)Úselfr   s     úl/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/alembic/runtime/plugins.pyÚ__init__zPlugin.__init__#   sJ   € ØˆŒ	Ü�‰Ð" DÔ)Ø”<ÑÜ˜¨t¨fÐ4JÐKÓLÐLØ!Œ�TÑÜ(:Ó(<ˆÕ%ó    c                ó&   — t         | j                  = y)zremove this pluginN)r   r   )r   s    r   ÚremovezPlugin.remove+   s   € ô ˜Ÿ™Ñ#r   NÚdefault)Ú	qualifierÚpriorityc               óN   —  | j                   j                  ||||¬«      |«       y)aU  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_comparatorz"Plugin.add_autogenerate_comparator0   s6   € ðD	
ˆ×%Ñ%×2Ñ2ØØ$ØØð	 	3ó 	
ð
 õ	r   c                ó   ‡
— t        «       }i }t        «       }|D ]?  }|j                  d«      r|j                  t        |dd «      «       Œ2t        |«      ||<   ŒA t        j                  «       D ]”  Š
t        ˆ
fd„|D «       «      rŒ|D �cg c]#  }||   j                  ‰
j                  «      sŒ"|‘Œ% }}|sŒI|j                  |«       t        j                  d‰
j                  «       |j                  ‰
j                  «       Œ– t        |«      j                  |«      }	|	r't        j                   ddj#                  |	«      › �«      ‚yc c}w )z_Populate all current autogenerate comparison functions into
        a given PriorityDispatcher.Ú~é   Nc              3  óT   •K  — | ]  }|j                  ‰j                  «      –— Œ! y ­w©N)Úmatchr   )Ú.0ÚexclÚplugins     €r   Ú	<genexpr>zAPlugin.populate_autogenerate_priority_dispatch.<locals>.<genexpr>l   s   øè ø€ Ð?±w¨t�4—:‘:˜fŸk™k×*±wùs   ƒ%(z!setting up autogenerate plugin %szDid not locate plugins: z, )ÚsetÚ
startswithÚaddÚ_make_rer   ÚvaluesÚanyr,   r   Úupdater   r   Úpopulate_withr   Ú
differencer
   ÚCommandErrorÚjoin)ÚclsÚcomparatorsÚinclude_pluginsÚexcludeÚincludeÚmatched_expressionsr   ÚinclÚinclude_matchesÚnever_matchedr/   s             @r   Ú'populate_autogenerate_priority_dispatchz.Plugin.populate_autogenerate_priority_dispatchY   s4  ø€ ô &)£UˆØ+-ˆä(+«Ðã#ˆDØ�‰˜sÔ#Ø—‘œH T¨!¨" XÓ.Õ/ä (¨£�˜’ð	 $ô #×)Ñ)Ö+ˆFÜÓ?±wÓ?Ô?Øñ ")óÙ!(˜¨G°D©M×,?Ñ,?ÀÇÁÕ,L’ ð ð ñ #Øà#×*Ñ*¨?Ô;ä�H‰HÐ8¸&¿+¹+ÔFØ×%Ñ% f×&EÑ&EÕFð ,ô ˜G›×/Ñ/Ð0CÓDˆÙÜ×#Ñ#Ø*¨4¯9©9°]Ó+CÐ*DÐEóð ð ùòs   Â#EÂ0Ec                ó8   — |j                  t        |«      «       y)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   )r<   Úmoduler   s      r   Úsetup_plugin_from_modulezPlugin.setup_plugin_from_module€   s   € ð2 	�‰”V˜D“\Õ"r   )r   Ústr©ÚreturnÚNoner+   )r#   z%Callable[..., PriorityDispatchResult]r$   rJ   r%   z
str | Noner   rJ   r   r   rL   rM   )r=   r   r>   z	list[str]rL   rM   )rH   r   r   rJ   rL   rM   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   ÚMEDIUMr&   ÚclassmethodrE   rI   © r   r   r   r      sª   „ ñó=ó$ð '+ð	'ð #Ø%5×%<Ñ%<ñ'à1ð'ð ð'ð $ð	'ð ð'ð #ð'ð 
ó'ðR ð$Ø,ð$Ø?Hð$à	ò$ó ð$ðL ò#ó ñ#r   r   c                óÐ   — | j                  d«      }d}|D ]3  }|dk(  r|dz  }Œ|j                  «       r	|d|z   z  }Œ't        d| ›�«      ‚ t        j                  d|dd  › d	�«      S )
NÚ.Ú Ú*z\..+?z\.zInvalid plugin expression Ú^r	   Ú$)ÚsplitÚisidentifierr   ÚreÚcompile)r   ÚtokensÚregÚtokens       r   r4   r4   œ   sz   € Ø�Z‰Z˜‹_€Fà
€CÛˆØ�CŠ<Ø�8‰O‰CØ×ÑÔ!Ø�5˜5‘=Ñ ‰CäÐ9¸$¸ÐBÓCÐCð ô �:‰:˜˜#˜a˜b˜'˜ !�nÓ%Ð%r   c                 ó¤   — t        j                  d¬«      D ]7  } | j                  «       D ]"  }t        j	                  || j
                  «       Œ$ Œ9 y )Nzalembic.plugins)Úgroup)r   Úentry_pointsÚloadr   rI   r   )Ú
entrypointÚmods     r   Ú_setuprh   ¬   s>   € ä×+Ñ+Ð2C×Dˆ
Ø—?‘?Ö$ˆCÜ×+Ñ+¨C°·±ÕAñ %ñ Er   )r   rJ   rL   zPattern[str]rK   )Ú
__future__r   Ú	importlibr   Úloggingr]   Útypesr   Útypingr   r   r   rW   r
   r   r   r   r   Ú	getLoggerrN   r   r   r4   rh   rT   r   r   Ú<module>ro      sd   ðÝ "å Û Û 	Ý Ý Ý Ý  å Ý #Ý %áÝ-à€ð €g×Ñ˜Ó!€÷A#ñ A#óH&ó Bñ …r   