|L ic(ddlmZddlZddlmZddlZddlmZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZddlmZddlmZddlmZdd lmZdd lmZd d lmZd d ddZddZ ddZ ddZ ddZddZy)) annotationsN) ExitStack) resources) ModuleType)Any)Optional)Union) exceptions)Template) CommandErrorF)append_with_newlinesc :tt|} |jd i|j|}t ||rdnd5}|r |j dj||j |dddy#1swYyxYw#t jdd5}|j tjjj||j} dddn #1swYnxYwtd zxYw) N)filenameabwbz z.txtF)suffixdeletezDTemplate rendering failed; see %s for a template-oriented traceback.) r _preserving_path_as_strrender_unicodeencodeopenwritetempfileNamedTemporaryFiler text_error_templatenamer ) template_filedestoutput_encodingrkwtemplateoutputfntffnames Z/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/alembic/util/pyfiles.pytemplate_to_filer)s!8!GHH(((.2.55oF$ 4$ ? 1# o67 GGFO      ( (u E  II..0!(  HHE     +-2 3  s0!B4BBD*A D7 DD Dc|tjj|sd|vr|jd}t }t j |jtj|d}|ddD]}||z } |jtj|}tj|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. :rr N)ospathisabssplitratexitregistercloserfiles enter_contextas_filepathlibPath)fname_or_resourcetokens file_managerreftoks r(coerce_resource_to_filenamer=6s 77==* +7H0H"((-!{  **+oofQi(!": C)C (66   c "  <<) **ctj|}tjtjj |j }|j r|S|j}tjjD]4}|j|j s#|j|cSy)z,Given a python source path, locate the .pyc.N) r6r7 importlibutilcache_from_sourceas_posixexistsr machineryBYTECODE_SUFFIXES with_suffix)r-pathpath candidateexts r(pyc_file_from_pathrKPs ||D!H (():):)<=I //C""44    $ + + -'', ,r>c~tj|}tj|}|j}tjdd|}||z }|j }|dk(rG|j rt||}|St|}|td|zt||}|S|dvrt||}|SJ)z3Load a file from the given path as a Python module.z\W_z.pyzCan't find Python file %s)z.pycz.pyo) r6r7rresubrrDload_module_pyrK ImportError)dir_rfilename_as_path module_idr-rJmodulepyc_paths r(load_python_filerWfs << D||H-$$Huc8,I (?D ++C e| ;;=#It4F M*$/H!"="DEE' 8< M   40 M ur>ctjj||}|sJtjj|}|jj ||S)N)r@rAspec_from_file_locationmodule_from_specloader exec_module)rTr-specrUs r(rPrPsL >> 1 1)T BD K4 ^^ , ,T 2FKKF# Mr>ct|tr|St|tjr t|Sttj|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. ) isinstancestrr6PurePathr7)r-s r(rrsA$ D'** +4y7<<%&&r>) rUnion[str, os.PathLike[str]]r rbr!r`rboolr"rreturnNone)r8r`rdz pathlib.Path)r-rbrdzOptional[pathlib.Path])rRrbrrbrdr)rTr`r-rbrdr)r-rbrdr`) __future__rr0 contextlibrr@rimportlib.machineryimportlib.utilr,r6rNrtypesrtypingrrr makor mako.templater excr r)r=rKrWrPrrr>r(ros"   ""' / &     <+4 &, &2N86 'r>