
    Ѯhz                    (   d dl mZ d dlZd dlmZ d dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d
dlmZ d
dlmZ dd	 	 	 	 	 	 	 	 	 	 	 ddZddZ	 	 	 	 ddZ	 	 	 	 	 	 ddZ	 	 	 	 	 	 ddZddZy)    )annotationsN)	ExitStack)
ModuleType)Any)Optional)Union)
exceptions)Template   )compat)CommandErrorF)append_with_newlinesc               :   t        t        |             }	  |j                  d	i |j                  |      }t	        ||rdnd      5 }|r |j                  dj                  |             |j                  |       d d d        y # 1 sw Y   y xY w#  t        j                  dd      5 }|j                  t        j                         j                         j                  |             |j                  }	d d d        n# 1 sw Y   nxY wt        d	z        xY w)
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
             f/home/www/academy-backend.kofcorporation.com/venv/lib/python3.12/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	 	 	 +-23
 	
s0   !B 4BBD*AD 7	D D		Dc                   t         j                  j                  |       sd| v r| j                  d      }t	               }t        j                  |j                         t        j                  j                  |d         }|dd D ]  }||z  }	 |j                  t        j                  j                  |            } t        j                  |       S )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                   t        j                  |       }t        j                  t        j                  j	                  |j                                     }|j                         r|S |j                  }t        j                  j                  D ]4  }|j                  |      j                         s#|j                  |      c S  y)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 $++-'',, r?   c                ~   t        j                  |       } t        j                  |      }|j                  }t        j                  dd|      }| |z  }|j
                  }|dk(  rG|j                         rt        ||      }|S t        |      }|t        d|z        t        ||      }|S |dv rt        ||      }|S J )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|;;=#It4F M *$/H!"="DEE'	8<
 M	 
 	 	40 M 	ur?   c                    t         j                  j                  | |      }|sJ t         j                  j                  |      }|j                  j                  |       |S )N)rA   rB   spec_from_file_locationmodule_from_specloaderexec_module)rU   r-   specrV   s       r(   rQ   rQ      sL     >>11)TBDK4^^,,T2FKKF#Mr?   c                    t        | t              r| S t        | t        j                        rt        |       S t        t        j                  |             S )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      sA     $	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?   