Viewing File: /opt/hc_python/lib/python3.12/site-packages/alembic/script/__pycache__/write_hooks.cpython-312.pyc

�

f��g���(�UddlmZddlZddlZddlZddlmZddlmZddlmZddlm	Z	ddlm
Z
ddlmZdd	lmZd
dl
mZd
dlmZd
ZiZded<dd�Z								dd�Zdd�Zdd�Zed�	d							dd��Zed�ddd��Zy)�)�annotationsN)�Any)�Callable)�Dict)�List)�Mapping)�Optional)�Union�)�util)�compat�REVISION_SCRIPT_FILENAME�dict�	_registryc����fd�}|S)z�A function decorator that will register that function as a write hook.

    See the documentation linked below for an example.

    .. seealso::

        :ref:`post_write_hooks_custom`


    c���|t�<|S)N)r)�fn�names ��I/opt/hc_python/lib/python3.12/site-packages/alembic/script/write_hooks.py�decoratezregister.<locals>.decorate&s����	�$���	��)rrs` r�registerrs�����Orc�~�	t|}|||�S#t$r}tjd|�d��|�d}~wwxYw)a7Invokes the formatter registered for the given name.

    :param name: The name of a formatter in the registry
    :param revision: A :class:`.MigrationRevision` instance
    :param options: A dict containing kwargs passed to the
        specified formatter.
    :raises: :class:`alembic.util.CommandError`
    zNo formatter with name 'z' registeredN)r�KeyErrorr�CommandError)r�revision�options�hook�kes     r�_invoker!-sS��'������H�g�&�&�������&�t�f�L�9�
��	���s�	�	<�7�<c���ddlm}|j|jdd��}|D]v}|s�|D�cic]+}|j	|dz�r|t|�dzd||��-}}||d<	|d}t
jd	|��d
��5t|||�ddd��xycc}w#1swY��xYw#t$r!}t
jd|�d
|���|�d}~wwxYw)z&Invoke hooks for a generated revision.�)�_split_on_space_comma�hooks��.N�
_hook_name�typezRunning post write hook T)�newline�Key z&.type is required for post write hook )�baser$�split�get�
startswith�lenr�statusr!rr)	�path�hook_configr$�namesr�key�opts�type_r s	         r�
_run_hooksr8Bs��,�!�'�'������(D�E�E�����#�
�"���~�~�d�S�j�)�
��D�	�A�
�� �+�c�"2�2�"�	
�
�
"��\��
	+���L�E����*�4�(�3�T����t�T�*���!��
�����	��#�#��t�f�B�4�(�K���
��	�s)�0B$�,B5�B)�)B2	�5	C�>C�Cc���t|vrtdz|z}tj|tj��}|D�cgc]}|jt|���}}|Scc}w)z�Parse options from a string into a list.

    Also substitutes the revision script token with the actual filename of
    the revision script.

    If the revision script token doesn't occur in the options string, it is
    automatically prepended.
    � )�posix)�REVISION_SCRIPT_TOKEN�shlexr-r
�is_posix�replace)�cmdline_options_strr2�cmdline_options_list�options    r�_parse_cmdline_optionsrC_sq���$7�7�3�c�9�<O�O�� �;�;��6�?�?���
+��*�F�	���,�d�3�*��� ���	s�A�console_scriptsc�@�	|d}tjd�D]}|j
|k(s�|}ntjd|����|j
dd�}|j
dd	�}t||�}	i}
|rtjx|
d
<|
d<tjtjdd
|j�d|j�d|j�d�g|	zfd|i|
��y#t$r'}tjd|d�d|d���|�d}~wwxYw)N�
entrypointr+r(z,.entrypoint is required for post write hook rDz*Could not find entrypoint console_scripts.�cwdrr&�stdout�stderrz-czimport z; r'z())rrrr
�importlib_metadata_getrr.rC�
subprocess�DEVNULL�run�sys�
executable�module�attr)r2r�
ignore_output�entrypoint_namer �entry�implrGr@rA�kws           rrDrDtsX���!�,�/���.�.�/@�A���:�:��(��D��B�
���8��8I�J�
�	
�!���U�D�1�C�!�+�+�i��4��1�2E�t�L���B��&0�&8�&8�8��8��r�(�|��N�N��N�N���d�k�k�]�"�T�[�[�M��4�9�9�+�R�@�	
�
�	�	�
�	�
�	��+������7�<�(�)�*�!�,�/�2�
4�
��	���s�C-�-	D�6"D�D�execc�D�	|d}|jdd�}|jdd�}t	||�}i}|rt
jx|d<|d	<tj|g|�fd|i|��y#t$r'}tjd|d�d|d���|�d}~wwxYw)
NrOr+r(z,.executable is required for post write hook rGrr&rHrI)rrrr.rCrKrLrM)	r2rrRrOr rGr@rArVs	         r�exec_rY�s�����\�*�
�!���U�D�1�C�!�+�+�i��4��1�2E�t�L���B��&0�&8�&8�8��8��r�(�|��N�N��	
�
!�	
��

��
�
��������7�<�(�)�*�!�,�/�2�
4�
��	���s�A/�/	B�8"B�B)r�str�returnr)rrZrrZrzMapping[str, Union[str, int]]r[r)r2rZr3zMapping[str, str]r[�None)r@rZr2rZr[z	List[str])F)r2rZrrrR�boolr[r\)�
__future__rr=rKrN�typingrrrrrr	r
r&rr
r<r�__annotations__rr!r8rCrDrYrrr�<module>ras���#���
����������3���	�4���&'�

�'��'�'D�'��'�*+�: �*
�
��49�#�

�#��#�-1�#�	�#��#�L
�&����r
Back to Directory File Manager