File: //opt/alt/python37/lib/python3.7/site-packages/alembic/__pycache__/command.cpython-37.pyc
B
�M!V - � @ s� d dl Z ddlmZ ddlmZ ddlmZ ddlmZ dd� Z d$d
d�Z
d%dd�Zd&dd�Zd'dd�Z
d(dd�Zdd� Zd)dd�Zd*dd�Zd+dd�Zd,dd�Zd-d d!�Zd"d#� ZdS ).� N� )�ScriptDirectory)�EnvironmentContext)�util)�autogeneratec
C st | � d� xPt�| �� �D ]>}ttj�| �� |d���}t|�}W dQ R X | � d||� qW | � d� | � d� dS )zList available templateszAvailable templates:
ZREADMENz%s - %sz1
Templates are used via the 'init' command, e.g.:z,
alembic init --template generic ./scripts)�print_stdout�os�listdir�get_template_directory�open�path�join�next)�configZtempnameZreadmeZsynopsis� r �@/opt/alt/python37/lib/python3.7/site-packages/alembic/command.py�list_templates s
r �genericc
C s8 t �|t j�rt�d| ��t j�| �� |�}t �|t j�sJt�d| ��t�dt j� |� t j
|� t j�|d�}t�dt j� |� t j
|� t|�}x�t �|�D ]~}t j�||�}|dkr�t j� | j
�}t �|t j�r�t�d| � n|j|||d� q�t j�|�r�t j�||�} |�|| � q�W t�d| � d S )
z#Initialize a new scripts directory.zDirectory %s already existszNo such template %rzCreating directory %s�versionszalembic.ini.makoz File %s already exists, skipping)Zscript_locationzNPlease edit configuration/connection/logging settings in %r before proceeding.N)r �access�F_OKr �CommandErrorr r
r
Zstatus�abspath�makedirsr r Zconfig_file_name�msgZ_generate_template�isfileZ
_copy_file)
r Z directory�templateZtemplate_dirr �scriptZfile_Z file_pathZconfig_fileZoutput_filer r r �init s:
r F�headc
s� t �| �}
t||||||||| d� }t�| |
|�� t�| �d��}|rfd}|rXt�d��� fdd�}
n |rx� fdd�}
n|r�t�d��|r�t | |
|
|� j
� d �� |
�� W d
Q R X dd� � �� D �}t
|�d
kr�|d S |S d
S )zCreate a new revision file.) �messager �sqlr �splice�branch_label�version_path�rev_id�
depends_onZrevision_environmentTz7Using --sql with --autogenerate does not make any sensec s � � | |� g S )N)Zrun_autogenerate)�rev�context)�revision_contextr r �retrieve_migrations` s z%revision.<locals>.retrieve_migrationsc s � � | |� g S )N)Zrun_no_autogenerate)r'