bg. ddlmZddlZddlmZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl mZddlmZddlmZdd lmZddZddZddZddZddZdS) ) annotationsN) ExitStack)Optional) exceptions)Template)compat) CommandError template_filestrdestoutput_encodingreturnNonec t|} |jdi||}t|d5}||ddddS#1swxYwYdS#t jdd5}|tj||j }dddn #1swxYwYtd|zxYw)N)filenamewbz.txtF)suffixdeletezDTemplate rendering failed; see %s for a template-oriented traceback.) rrender_unicodeencodeopenwritetempfileNamedTemporaryFilertext_error_templatenamer ) r r rkwtemplateoutputfntffnames K/opt/cloudlinux/venv/lib64/python3.11/site-packages/alembic/util/pyfiles.pytemplate_to_filer&s///H((..2..55oFF$    GGFOOO                     (u E E E  II.00!!((    HE                 +-2 3   sB A2A%%A),A)2D AC) D)C- -D0C- 1Dr$ctj|sd|vr|d}t }t j|jtj |d}|ddD]}||z }| 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. :rrN) ospathisabssplitratexitregistercloser importlib_resourcesfiles enter_contextas_file)r$tokens file_managerreftoks r%coerce_resource_to_filenamer8+s 7==   C5LLS!!!{{  *+++(..vay99!"":  C)CC**  & . .s 3 3   Lr* Optional[str]cDtj|}tj|r|Stj|\}}tjjD]+}tj||zr||zcS,dS)z,Given a python source path, locate the .pyc.N) importlibutilcache_from_sourcer)r*existssplitext machineryBYTECODE_SUFFIXES)r* candidatefilepathexts r%pyc_file_from_pathrFEs0066I w~~i  G$$T**MHc"4 7>>(S. ) ) "c> ! ! ! "tr9dir_rctjdd|}tj||}tj|\}}|dkrdtj|rt||}nHt|}|td|zt||}n|dvrt||}|S)z3Load a file from the given path as a Python module.z\W_z.pyNzCan't find Python file %s)z.pycz.pyo) resubr)r*joinr@r?load_module_pyrF ImportError)rGr module_idr*rIrEmodulepyc_paths r%load_python_filerRVsuc8,,I 7<<h ' 'D W  h ' 'FAs e|| 7>>$   =#It44FF)$//H!"="DEEE' 8<<   400 Mr9rOctj||}|sJtj|}|j||S)N)r<r=spec_from_file_locationmodule_from_specloader exec_module)rOr*specrPs r%rMrMjsR > 1 1)T B BD KK4 ^ , ,T 2 2FKF### Mr9)r r r r rr rr)r$r rr )r*r rr:)rGr rr )rOr r*r ) __future__rr- contextlibrr<importlib.machineryimportlib.utilr)rJrtypingrmakor mako.templaterr excr r&r8rFrRrMrr9r%rbs9""""""  """""".4"(r9