관리-도구
편집 파일: command.cpython-37.opt-1.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 �status�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( r) )r* r r r+ d s ziUsing --sql with the revision command when revision_environment is not configured does not make any sense)�fn�as_sql� template_argsr* Nc S s g | ]}|�qS r r )�.0r r r r � <listcomp>x s zrevision.<locals>.<listcomp>r r )r �from_config�dict�autogenZRevisionContextr ZasboolZget_main_optionr r r. �run_envZgenerate_scripts�len)r r! r r"