
    -ji                       % 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    T/home/james-whalen/.local/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U(       aK  SUR                   SUR                   SU SU SUR                   S	UR                   S
UR                   S3nO*SUR                   SUR                   S
UR                   S3n[        R                  SU/n[        XX(5        g )N
entrypointrF   z*Could not find entrypoint console_scripts.zimport z; assert tuple(int(x) for x in z.__version__.split('.')) >= z, 'need exactly version z of z'; r7   z()z; z-c)r8   r	   importlib_metadata_getr   r   r   moduleattrsys
executablerE   )	r&   r   rB   verify_versionentrypoint_nameentryimplpyscriptrC   s	            r   rF   rF      s     +7LAO../@A::(D B
 88IJ
 	
 dkk] #,,0KK=8TUcTd e%%3$4D3{{m1TYYKr+ 	 T[[MDKK=$))BG~~tX.Gd]4r   execc                2    [        US5      n[        XX#/S9  g )NrM   )rC   )r8   rE   )r&   r   rB   rM   s       r   exec_rU      s    %g|<Jd]LAr   rJ   c                    [        US5      n[        R                  R                  U5      c  [        R                  " SU 35      e[
        R                  SU/n[        XX$5        g )NrJ   zCould not find module z-m)r8   	importlibr   	find_specr   rL   rM   rE   )r&   r   rB   module_namerC   s        r   rJ   rJ      sV    &w9K~~,4"8 FGG~~t[1Gd]4r   )r   strreturnr   )r   rZ   r   str | os.PathLike[str]r   r   r[   r   )r&   r\   r'   zlist[PostWriteHookConfig]r[   None)r2   rZ   r&   rZ   r[   	list[str])r   r   r   rZ   r[   rZ   )
r&   rZ   r   r   rB   boolrC   r^   r[   r]   )FN)
r&   rZ   r   r   rB   r_   rN   ztuple[int, ...] | Noner[   r]   )F)r&   rZ   r   r   rB   r_   r[   r]   )
__future__r   importlib.utilrW   osr.   r?   rL   typingr   r   r   r;   r   r	   util.pyfilesr
   configr   r-   r   __annotations__r   r    r)   r5   r8   rE   rF   rU   rJ   r   r   r   <module>rg      sM   #  	   
       2,2 	4 &,
,), !, 		,0+
 +)B+	+* *E
EE-1E<EE	E 

  -1	5
55 5 +	5
 
5 5< 
&B B
 
(5 5r   