관리-도구
편집 파일: command.cpython-38.pyc
U 0?�f�V � @ s� d dl mZ d dlZd dlmZ d dlmZ d dlmZ d dlmZ ddlm Z dd lmZ dd lm Z ddlmZ er�d dlmZ d d lmZ d dlmZ ddlmZ ddd�dd�ZdGdddddd�dd�ZdHdddddddddddd d!�d"d#�Zd$dd�d%d&�ZdIdd'dddd(d)�d*d+�ZdJdddddd,�d-d.�ZdKdddddd,�d/d0�Zdddd1�d2d3�ZdLdddddd4�d5d6�ZdMddddd7�d8d9�Z dNdddd:�d;d<�Z!dOdddd:�d=d>�Z"dPdd'ddddd?�d@dA�Z#dddd1�dBdC�Z$dQddddD�dEdF�Z%dS )R� )�annotationsN)�List)�Optional)� TYPE_CHECKING)�Union� )�autogenerate)�util)�EnvironmentContext)�ScriptDirectory)�Config)�Script)� _RevIdType)�ProcessRevisionDirectiveFnr �None)�config�returnc C st | � d� t�| �� �D ]B}ttj�| �� |d���}t|��� }W 5 Q R X | � d||� q| � d� | � d� dS )zNList available templates. :param config: a :class:`.Config` object. zAvailable templates: ZREADMEz%s - %sz1 Templates are used via the 'init' command, e.g.:z, alembic init --template generic ./scriptsN) �print_stdout�os�listdir�get_template_directory�open�path�join�next�rstrip)r �tempnameZreadmeZsynopsis� r �=/opt/hc_python/lib/python3.8/site-packages/alembic/command.py�list_templates s � r �genericF�str�bool)r � directory�template�packager c C s( t �|t j�r&t �|�r&t�d| ��t j�| �� |�}t �|t j�sTt�d| ��t �|t j�s�tj dt j� |���f| j�� t �|� W 5 Q R X t j�|d�}tj dt j� |���f| j�� t �|� W 5 Q R X t |�}d}t �|�D ]�}t j�||�} |dk�rd| jdk �st�t j� | j�}t �|t j��rRtjd|�d�f| j� n|j| ||d � q�t j�| �r�t j�||�} |�| | � q�|�r�t j�t j� |�d �t j�t j� |�d �fD ]>}tj d|��f| j�� t|d�� W 5 Q R X W 5 Q R X �q�|dk �st�tjd |�d�f| j� dS )ak Initialize a new scripts directory. :param config: a :class:`.Config` object. :param directory: string path of the target directory. :param template: string name of the migration environment template to use. :param package: when True, write ``__init__.py`` files into the environment location as well as the versions/ location. z,Directory %s already exists and is not emptyzNo such template %rzCreating directory �versionsNzalembic.ini.makozFile z already exists, skipping)Zscript_locationz__init__.pyzAdding �wz9Please edit configuration/connection/logging settings in z before proceeding.)r �access�F_OKr r �CommandErrorr r r �status�abspathZmessaging_opts�makedirsr Zconfig_file_name�AssertionError�msgZ_generate_template�isfileZ _copy_filer )r r# r$ r% Ztemplate_dirr&