
    Eh                       % 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  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)Dict)List)Optional)TYPE_CHECKING)Union   )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    ]/home/kali/devsecops-assessor/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$   2   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-   J   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_optionsr9   _   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_optionr<   t   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)getr9   
subprocessDEVNULLrun)r*   r!   ignore_outputcommandr>   r6   r7   kws           r   	_run_hookrI   ~   ss     !UD1C!++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
entrypointrJ   z*Could not find entrypoint console_scripts.z-czimport z; r;   z())r<   r   importlib_metadata_getr   r   r   sys
executablemoduleattrrI   )r*   r!   rF   entrypoint_nameentryimplrG   s          r   rJ   rJ      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 )NrO   )rG   )r<   rI   )r*   r!   rF   rO   s       r   exec_rW      s    %g|<Jd]LAr   rP   c                    [        US5      n[        R                  R                  U5      c  [        R                  " SU 35      e[
        R                  SU/n[        XX$5        g )NrP   zCould not find module z-m)r<   	importlibr   	find_specr   rN   rO   rI   )r*   r!   rF   module_namerG   s        r   rP   rP      sV    &w9K~~,4"8 FGG~~t[1Gd]4r   )r   strreturnr   )r   r\   r    Union[str, os.PathLike[str]]r!   r   r]   r   )r*   r^   r+   zlist[PostWriteHookConfig]r]   None)r6   r\   r*   r\   r]   	List[str])r!   r   r   r\   r]   r\   )
r*   r\   r!   r   rF   boolrG   r`   r]   r_   )F)r*   r\   r!   r   rF   ra   r]   r_   )#
__future__r   importlib.utilrY   osr2   rC   rN   typingr   r   r   r   r   r	   r
   r?   r   r   util.pyfilesr   configr   r1   r   __annotations__r   r$   r-   r9   r<   rI   rJ   rW   rP   r   r   r   <module>ri      sF   #  	   
           2,2 	4 &,
,/, !, 		,0+
&+/H+	+* *E
EE-1E<EE	E 

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