관리-도구
편집 파일: pyfiles.cpython-38.pyc
U 0?�f� � @ s d dl mZ d dlZd dlmZ d dlZd dlZd dlZd dlZd dl Z d dl Z d dlmZ d dl mZ d dl mZ d dlmZ d dlmZ d d lmZ d dlmZ dddd dd�dd�Zddd�dd�Zddd�dd�Zdddd�dd�Zdddd�dd�ZdS ) � )�annotationsN)� ExitStack)� ModuleType)�Any)�Optional)� exceptions)�Template� )�compat)�CommandError�strr �None)� template_file�dest�output_encoding�kw�returnc K s� t | d�}z|jf |��|�}W nP tjddd��$}|�t�� �� �|�� |j}W 5 Q R X t d| ��Y n"X t |d��}|�|� W 5 Q R X d S )N)�filenamez.txtF)�suffix�deletezDTemplate rendering failed; see %s for a template-oriented traceback.�wb)r Zrender_unicode�encode�tempfile�NamedTemporaryFile�writer Ztext_error_template�namer �open) r r r r �template�outputZntf�fname�f� r! �B/opt/hc_python/lib/python3.8/site-packages/alembic/util/pyfiles.py�template_to_file s$ ���� r# )r r c C sp t j�| �sld| krl| �d�}t� }t�|j� tj � |d �}|dd� D ]}|| }qL|�tj �|��} | S )z�Interpret 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 Zimportlib_resources�files� enter_contextZas_file)r �tokensZfile_manager�ref�tokr! r! r"