
    c?ip                       % S SK Jr  S SKrS SKrS SK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  \(       a  SS
KJr  Sr0 rS\S'   SS jr        SS jr      SS jrSS jrSS jr          SS jr\" S5       S        S!S jj5       r\" S5      S S!S jj5       r\" S5      S S!S jj5       rg)"    )annotationsN)Any)Callable)TYPE_CHECKING   )util)compat)_preserving_path_as_str)PostWriteHookConfigREVISION_SCRIPT_FILENAMEdict	_registryc                   ^  U 4S jnU$ )zA 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                   > U [         T'   U $ )N)r   )fnnames    ^/var/www/html/livechat/backend/venv/lib/python3.13/site-packages/alembic/script/write_hooks.pydecorateregister.<locals>.decorate'   s    	$	     )r   r   s   ` r   registerr      s     Or   c                    [        U5      n [        U    nU" X5      $ ! [         a   n[        R                  " SU  S35      UeSnAff = f)a  Invokes the formatter registered for the given name.

:param name: The name of a formatter in the registry
:param revision: string path to the revision file
:param options: A dict containing kwargs passed to the
    specified formatter.
:raises: :class:`alembic.util.CommandError`
zNo formatter with name 'z' registeredN)r
   r   KeyErrorr   CommandError)r   revision_pathoptionshookkes        r   _invoker    .   s]     ,M:M, M++  &tfL9
	s   	 
AAAc                   U H<  nUS   n US   n[         R                  " SU< 3SS9   [        X@U5        SSS5        M>     g! , (       d  f       MP  = f! [         a#  n[         R                  " SU SU< 35      UeSnAff = f)	z&Invoke hooks for a generated revision.
_hook_nametypezRunning post write hook T)newlineNzKey 'z;.type' (or 'type' in toml) is required for post write hook )r   statusr    r   r   )pathhooksr   r   type_r   s         r   
_run_hooksr)   F   s    
 L!	+LE *4(3T T*     	##v ''+h0 	s"   AA
A	
B A>>Bc                    [         U ;  a  [         S-   U -   n [        R                  " U [        R                  S9nU Vs/ s H  nUR                  [         U5      PM     nnU$ s  snf )zParse 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shlexsplitr	   is_posixreplace)cmdline_options_strr&   cmdline_options_listoptions       r   _parse_cmdline_optionsr5   [   sq     $773c9<OO ;;6??
 +*F 	,d3*    	s    A"c           
     ~     X   $ ! [          a,  n[        R                  " SU S    SU SU S   < 35      UeS nAff = f)NzKey r"   .z! is required for post write hook )r   r   r   )r   r   r   s      r   _get_required_optionr8   p   s_    } 7<()4& 1!,/24
 	s    
<'7<c                    UR                  SS 5      nUR                  SS5      n[        XP5      n0 nU(       a  [        R                  =US'   US'   [        R                  " / UQUQ4SU0UD6  g )Ncwdr    stdoutstderr)getr5   
subprocessDEVNULLrun)r&   r   ignore_outputcommandr:   r2   r3   kws           r   	_run_hookrE   z   ss     kk%.C!++i412ELB&0&8&888r(|NN4W434D#DDr   console_scriptsc           	     >   [        US5      n[        R                  " S5       H  nUR                  U:X  d  M  Un  O   [        R
                  " SU 35      e[        R                  SSUR                   SUR                   SUR                   S3/n[        XX&5        g )	N
entrypointrF   z*Could not find entrypoint console_scripts.z-czimport z; r7   z())r8   r	   importlib_metadata_getr   r   r   sys
executablemoduleattrrE   )r&   r   rB   entrypoint_nameentryimplrC   s          r   rF   rF      s     +7LAO../@A::(D B
 88IJ
 	

 	
$++bQtyyk<G
 d]4r   execc                2    [        US5      n[        XX#/S9  g )NrK   )rC   )r8   rE   )r&   r   rB   rK   s       r   exec_rS      s    %g|<Jd]LAr   rL   c                    [        US5      n[        R                  R                  U5      c  [        R                  " SU 35      e[
        R                  SU/n[        XX$5        g )NrL   zCould not find module z-m)r8   	importlibr   	find_specr   rJ   rK   rE   )r&   r   rB   module_namerC   s        r   rL   rL      sV    &w9K~~,4"8 FGG~~t[1Gd]4r   )r   strreturnr   )r   rX   r   str | os.PathLike[str]r   r   rY   r   )r&   rZ   r'   zlist[PostWriteHookConfig]rY   None)r2   rX   r&   rX   rY   	list[str])r   r   r   rX   rY   rX   )
r&   rX   r   r   rB   boolrC   r\   rY   r[   )F)r&   rX   r   r   rB   r]   rY   r[   )
__future__r   importlib.utilrU   osr.   r?   rJ   typingr   r   r   r;   r   r	   util.pyfilesr
   configr   r-   r   __annotations__r   r    r)   r5   r8   rE   rF   rS   rL   r   r   r   <module>re      s:   #  	   
       2,2 	4 &,
,), !, 		,0+
 +)B+	+* *E
EE-1E<EE	E 

495
55-15	5 5* 
&B B
 
(5 5r   