
    Ehz                    6   S SK Jr  S SKr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
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.           SS jjrSS jr    SS jr      SS jr      SS jrSS jrg)    )annotationsN)	ExitStack)
ModuleType)Any)Optional)Union)
exceptions)Template   )compat)CommandErrorF)append_with_newlinesc               X   [        [        U 5      S9n UR                  " S	0 UD6R                  U5      n[	        X(       a  SOS5       nU(       a   UR                  SR                  U5      5        UR                  U5        S S S 5        g ! , (       d  f       g = f!   [        R                  " SSS9 nUR                  [        R                  " 5       R                  5       R                  U5      5        UR                  n	S S S 5        O! , (       d  f       O= f[        SW	-  5      e= f)
N)filenameabwbz

z.txtF)suffixdeletezDTemplate rendering failed; see %s for a template-oriented traceback. )r
   _preserving_path_as_strrender_unicodeencodeopenwritetempfileNamedTemporaryFiler	   text_error_templatenamer   )
template_filedestoutput_encodingr   kwtemplateoutputfntffnames
             W/home/kali/devsecops-assessor/venv/lib/python3.13/site-packages/alembic/util/pyfiles.pytemplate_to_filer)      s     !8!GHH((.2.55oF $ 4$?1#o67GGFO @??
((uEII..0!(
 HHE FEE +-23
 	
s0   !B 	9B
BD)3AD
	D)

D	D)c                   [         R                  R                  U 5      (       d  SU ;   a  U R                  S5      n[	        5       n[
        R                  " UR                  5        [        R                  R                  US   5      nUSS  H  nX4-  nM	     UR                  [        R                  R                  U5      5      n [        R                  " U 5      $ )zInterpret a filename as either a filesystem location or as a package
resource.

Names that are non absolute paths and contain a colon
are interpreted as resources and coerced to a file location.

:r   r   N)ospathisabssplitr   atexitregistercloser   importlib_resourcesfilesenter_contextas_filepathlibPath)fname_or_resourcetokensfile_managerreftoks        r(   coerce_resource_to_filenamer>   6   s     77==*++7H0H"((- !{**+((..vay9!":C)C (66&&..s3
 <<)**    c                   [         R                  " U 5      n[         R                  " [        R                  R	                  UR                  5       5      5      nUR                  5       (       a  U$ UR                  n[        R                  R                   H:  nUR                  U5      R                  5       (       d  M)  UR                  U5      s  $    g)z,Given a python source path, locate the .pyc.N)r7   r8   	importlibutilcache_from_sourceas_posixexistsr   	machineryBYTECODE_SUFFIXESwith_suffix)r-   pathpath	candidateexts       r(   pyc_file_from_pathrL   P   s    
 ||D!H(():):)<=I  //C""44$++--'',, 5 r?   c                   [         R                  " U 5      n [         R                  " U5      nUR                  n[        R                  " SSU5      nX-  nUR
                  nUS:X  aL  UR                  5       (       a  [        X45      nU$ [        U5      nUc  [        SU-  5      e[        X75      n U$ US;   a  [        X45      nU$  e)z3Load a file from the given path as a Python module.z\W_z.pyzCan't find Python file %s)z.pycz.pyo)
r7   r8   r   resubr   rE   load_module_pyrL   ImportError)dir_r   filename_as_path	module_idr-   rK   modulepyc_paths           r(   load_python_filerX   f   s    
 <<D||H-$$Huc8,I?D
++C
e|;;==#I4F M *$/H!"="DEE'	<
 M	 
 	 	0 M 	ur?   c                    [         R                  R                  X5      nU(       d   e[         R                  R                  U5      nUR                  R                  U5        U$ )N)rA   rB   spec_from_file_locationmodule_from_specloaderexec_module)rU   r-   specrV   s       r(   rQ   rQ      sJ     >>11)BDK4^^,,T2FKKF#Mr?   c                    [        U [        5      (       a  U $ [        U [        R                  5      (       a  [        U 5      $ [        [        R                  " U 5      5      $ )zreceive str/pathlike and return a string.

Does not convert an incoming string path to a Path first, to help with
unit tests that are doing string path round trips without OS-specific
processing if not necessary.

)
isinstancestrr7   PurePathr8   )r-   s    r(   r   r      sG     $	D'**	+	+4y7<<%&&r?   )r   Union[str, os.PathLike[str]]r    rc   r!   ra   r   boolr"   r   returnNone)r9   ra   re   zpathlib.Path)r-   rc   re   zOptional[pathlib.Path])rS   rc   r   rc   re   r   )rU   ra   r-   rc   re   r   )r-   rc   re   ra   ) 
__future__r   r0   
contextlibr   rA   importlib.machineryimportlib.utilr,   r7   rO   r   typesr   typingr   r   r   makor	   mako.templater
    r   excr   r)   r>   rL   rX   rQ   r   r   r?   r(   <module>rq      s    "       	  	       "   "'/
& 
   
<+4
&,
&2N86'r?   