File: //home/arjun/projects/env/lib/python3.10/site-packages/alembic/__pycache__/command.cpython-310.pyc
o
+weTT � @ s� d dl mZ d dlZd dlmZ d dlmZ d dlmZ d dlmZ ddlm Z
dd lmZ dd
lm
Z
ddlmZ erTd dlmZ d d
lmZ d dlmZ ddlmZ dQdd�Z dRdSdd�Z dTdUd-d.�ZdVd0d1�Z dWdXd5d6�Z dYdZd8d9�Z dYdZd:d;�Zd<d=� Z d[d\dAdB�Zd]dCdD�Z d^dEdF�Z!d^d_dGdH�Z" d`dadJdK�Z#dbdMdN�Z$d^dcdOdP�Z%dS )d� )�annotationsN)�List)�Optional)�
TYPE_CHECKING)�Union� )�autogenerate)�util)�EnvironmentContext)�ScriptDirectory)�Config)�Script)�
_RevIdType)�ProcessRevisionDirectiveFn�configr c C s� | � d� t�| �� �D ]+}ttj�| �� |d���}t|��� }W d � n1 s+w Y | � d||� q| � d� | � d� dS )zNList available templates.
:param config: a :class:`.Config` object.
zAvailable templates:
�READMENz%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�rstrip)r �tempname�readme�synopsis� r �H/home/arjun/projects/env/lib/python3.10/site-packages/alembic/command.py�list_templates s
��
r �genericF� directory�str�template�package�bool�return�Nonec
C s� t �|t j�rt �|�rt�d| ��t j�| �� |�}t �|t j�s*t�d| ��t �|t j�sWtj dt j�
|���fi | j���
t �|� W d � n1 sRw Y t j�|d�}tj dt j�
|���fi | j���
t �|� W d � n1 sw Y t
|�}d}t �|�D ]M}t j�||�} |dkr�| jdus�J �t j�
| j�}t �|t j�r�tjd|�d�fi | j�� q�|j| ||d � q�t j�| �r�t j�||�}
|�| |
� q�|�r-t j�t j�
|�d
�t j�t j�
|�d
�fD ]6}tj d|��fi | j��� t|d�� W d � n 1 �sw Y W d � n 1 �s'w Y q�|du�s4J �tjd
|�d�fi | j�� dS )aj 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 N�versionszalembic.ini.makozFile z already exists, skipping)�script_locationz__init__.pyzAdding �wz9Please edit configuration/connection/logging settings in z before proceeding.)r �access�F_OKr r �CommandErrorr r r �status�abspath�messaging_opts�makedirsr �config_file_name�msg�_generate_template�isfile�
_copy_filer )r r"