
    g                    8   % S SK J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r0 rS\S'   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g)    )annotationsN)Any)Callable)Dict)List)Mapping)Optional)Union   )util)compat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    b/Users/Alptekin/Desktop/izin_takip/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    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: A :class:`.MigrationRevision` instance
:param options: A dict containing kwargs passed to the
    specified formatter.
:raises: :class:`alembic.util.CommandError`
zNo formatter with name 'z' registeredN)r   KeyErrorr   CommandError)r   revisionoptionshookkes        r   _invoker"   -   sQ    ' H&&  &tfL9
	s   	 
=8=c                   SSK Jn  UR                  UR                  SS5      5      nU H  nU(       d  M  U Vs0 s H2  nUR	                  US-   5      (       d  M  U[        U5      S-   S X   _M4     nnXFS'    US   n[        R                  " S	U< 3S
S9   [        XpU5        SSS5        M     gs  snf ! , (       d  f       M  = 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.   )_split_on_space_commahooks .N
_hook_nametypezRunning post write hook T)newlineKey z&.type is required for post write hook )baser%   splitget
startswithlenr   statusr"   r   r   )	pathhook_configr%   namesr   keyoptstype_r!   s	            r   
_run_hooksr9   B   s    ,!''(DEE #
"~~dSj) 3CD	A +"22" 	 

 "\
	+LE *4(3T T* ! 
   	##tfB4(K	s/   B2B2:C	B77
C		
C6C11C6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shlexr.   r   is_posixreplace)cmdline_options_strr3   cmdline_options_listoptions       r   _parse_cmdline_optionsrD   _   sq     $773c9<OO ;;6??
 +*F 	,d3*    	s    A"console_scriptsc                Z    US   n[        R                  " S5       H  nUR
                  U:X  d  M  Un  O   [        R                  " SU 35      eUR                  SS 5      nUR                  SS	5      n[        X5      n	0 n
U(       a  [        R                  =U
S
'   U
S'   [        R                  " [        R                  SSUR                   SUR                   SUR                   S3/U	-   4SU0U
D6  g ! [          a)  n[        R                  " SUS    SUS   < 35      UeS nAff = f)N
entrypointr,   r)   z,.entrypoint is required for post write hook rE   z*Could not find entrypoint console_scripts.cwdr   r'   stdoutstderrz-czimport z; r(   z())r   r   r   r   importlib_metadata_getr   r/   rD   
subprocessDEVNULLrunsys
executablemoduleattr)r3   r   ignore_outputentrypoint_namer!   entryimplrH   rA   rB   kws              r   rE   rE   t   sV   !,/ ../@A::(D B
 88IJ
 	
 !UD1C!++i412ELB&0&8&888r(|NNNNdkk]"T[[M499+R@	

 		 	 	+  7<() *!,/24
 	s   C7 7
D*$D%%D*execc                T    US   nUR                  SS 5      nUR                  SS5      n[	        X`5      n0 nU(       a  [
        R                  =US'   US	'   [
        R                  " U/UQ4SU0UD6  g ! [          a)  n[        R                  " SUS    SUS   < 35      UeS nAff = f)
NrP   r,   r)   z,.executable is required for post write hook rH   r   r'   rI   rJ   )r   r   r   r/   rD   rL   rM   rN   )	r3   r   rS   rP   r!   rH   rA   rB   rW   s	            r   exec_rZ      s    \*
 !UD1C!++i412ELB&0&8&888r(|NN	
!	

    7<() *!,/24
 	s   A4 4
B'>$B""B')r   strreturnr   )r   r[   r   r[   r   zMapping[str, Union[str, int]]r\   r   )r3   r[   r4   zMapping[str, str]r\   None)rA   r[   r3   r[   r\   z	List[str])F)r3   r[   r   r   rS   boolr\   r]   )
__future__r   r>   rL   rO   typingr   r   r   r   r   r	   r
   r'   r   r   r=   r   __annotations__r   r"   r9   rD   rE   rZ   r   r   r   <module>rb      s    #   
          3 	4 &'
'''D''*+: * 

49#
##-1#	# #L 
& r   