AlkantarClanX12

Your IP : 18.116.40.53


Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/alembic/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/alembic/__pycache__/command.cpython-311.pyc

�

�܋f`S��\�ddlmZddlZddlmZddlmZddlmZddlmZddlm	Z
dd	lmZdd
lm
Z
ddlmZerddlmZdd
lmZddlmZd@d�Z		dAdBd�Z										dCdDd)�ZdEd+�Z			dFdGd.�Z		dHdId1�Z		dHdId2�Zd3�Z			dJdKd7�ZdLd8�ZdMd9�ZdMdNd:�Z 			dOdPd<�Z!dQd>�Z"dMdRd?�Z#dS)S�)�annotationsN)�List)�Optional)�
TYPE_CHECKING)�Union�)�autogenerate)�util)�EnvironmentContext)�ScriptDirectory)�Config)�Script)�ProcessRevisionDirectiveFn�configr
c��|�d��tj|�����D]�}t	tj�|���|d����5}t|�����}ddd��n#1swxYwY|�d||����|�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�synopsiss    �F/opt/cloudlinux/venv/lib64/python3.11/site-packages/alembic/command.py�list_templatesr s&�����0�1�1�1��J�v�<�<�>�>�?�?�;�;��
��G�L�L��6�6�8�8�(�H�M�M�
�
�	-�
��F�|�|�*�*�,�,�H�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	���I�x��:�:�:�:�
���L�M�M�M�
���G�H�H�H�H�Hs�>"B,�,B0	�3B0	�genericF�	directory�str�template�package�bool�return�Nonec��tj|tj��r+tj|��rt	jd|z���tj�|���|��}tj|tj��st	jd|z���tj|tj��sct	j	dtj�
|����fi|j��5tj|��ddd��n#1swxYwYtj�|d��}t	j	dtj�
|����fi|j��5tj|��ddd��n#1swxYwYt|��}d}tj|��D]�}tj�||��}	|dkr�|j�J�tj�
|j��}tj|tj��rt	jd|�d�fi|j����|�|	||�	����tj�|	��r6tj�||��}
|�|	|
����|r�tj�tj�
|��d
��tj�tj�
|��d
��fD]Y}t	j	di|j��5t'|d��5	ddd��n#1swxYwYddd��n#1swxYwY�Z|�J�t	jd
|�d�fi|j��dS)a�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.

     .. versionadded:: 1.2


    z,Directory %s already exists and is not emptyzNo such template %rzCreating directory N�versionszalembic.ini.makozFile z already exists, skipping)�script_locationz__init__.py�Adding {path!r}�wz9Please edit configuration/connection/logging settings in z before proceeding.)r,)r�access�F_OKrr
�CommandErrorrrr�status�abspath�messaging_opts�makedirsr�config_file_name�msg�_generate_template�isfile�
_copy_filer)rr"r$r%�template_dirr*�script�config_file�file_�	file_path�output_filers            r�initr@'s���.
�y��B�G�$�$�
���I�)>�)>�
���:�Y�F�
�
�	
��7�<�<�� =� =� ?� ?��J�J�L�
�9�\�2�7�+�+�B��� 5�� @�A�A�A�
�9�Y���(�(�#�
�[�@�"�'�/�/�)�"<�"<�@�@�
�
��#�
�
�	#�	#�
�K�	�"�"�"�		#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#����	#�	#�	#�	#��w�|�|�I�z�2�2�H�	
��;�b�g�o�o�h�7�7�;�;�
�
�
�
�
�
���	��H����	�������������������Y�
'�
'�F�"�K���L�)�)�6�6���G�L�L��u�5�5�	��&�&�&��*�6�6�6��'�/�/�&�*A�B�B�K��y��b�g�.�.�
���D�K�D�D�D����+�����
�)�)��{�I�*������W�^�^�I�
&�
&�	6��'�,�,�y�%�8�8�K����i��5�5�5�����G�L�L������3�3�]�C�C��G�L�L������2�2�M�B�B�
�	�	�D���H�H�&�2G�H�H�
�
��$��_�_����������������������
�
�
�
�
�
�
�
�
�
�
����
�
�
�
���"�"�"��H�	:�"�	:�	:�	:����
�����sZ�	D*�*D.�1D.�F-�-F1�4F1�0N&�N�N&�N�N&�N�N&�&N*	�-N*	�head�message�
Optional[str]r	�sql�splice�branch_label�version_path�rev_id�
depends_on�process_revision_directives�$Optional[ProcessRevisionDirectiveFn]�/Union[Optional[Script], List[Optional[Script]]]c�\��tj|��}t|||||||||	��	�	}tj||||
����tj|�d����}
|rd}
|rtjd����fd�}n|
r�fd�}n|rtjd���|
rFt||||�j
��	��5|���d
d
d
��n#1swxYwYd�����D��}t|��dkr|d
S|S)a�Create a new revision file.

    :param config: a :class:`.Config` object.

    :param message: string message to apply to the revision; this is the
     ``-m`` option to ``alembic revision``.

    :param autogenerate: whether or not to autogenerate the script from
     the database; this is the ``--autogenerate`` option to
     ``alembic revision``.

    :param sql: whether to dump the script out as a SQL string; when specified,
     the script is dumped to stdout.  This is the ``--sql`` option to
     ``alembic revision``.

    :param head: head revision to build the new revision upon as a parent;
     this is the ``--head`` option to ``alembic revision``.

    :param splice: whether or not the new revision should be made into a
     new head of its own; is required when the given ``head`` is not itself
     a head.  This is the ``--splice`` option to ``alembic revision``.

    :param branch_label: string label to apply to the branch; this is the
     ``--branch-label`` option to ``alembic revision``.

    :param version_path: string symbol identifying a specific version path
     from the configuration; this is the ``--version-path`` option to
     ``alembic revision``.

    :param rev_id: optional revision identifier to use instead of having
     one generated; this is the ``--rev-id`` option to ``alembic revision``.

    :param depends_on: optional list of "depends on" identifiers; this is the
     ``--depends-on`` option to ``alembic revision``.

    :param process_revision_directives: this is a callable that takes the
     same form as the callable described at
     :paramref:`.EnvironmentContext.configure.process_revision_directives`;
     will be applied to the structure generated by the revision process
     where it can be altered programmatically.   Note that unlike all
     the other parameters, this option is only available via programmatic
     use of :func:`.command.revision`

    �	rBr	rDrArErFrGrHrI)rJ�revision_environmentTz7Using --sql with --autogenerate does not make any sensec�4����||��gS�N��run_autogenerate��rev�context�revision_contexts  �r�retrieve_migrationsz%revision.<locals>.retrieve_migrations�s����-�-�c�7�;�;�;��I�c�4����||��gSrQ)�run_no_autogeneraterTs  �rrXz%revision.<locals>.retrieve_migrations�s����0�0��g�>�>�>��IrYziUsing --sql with the revision command when revision_environment is not configured does not make any sense��fn�as_sql�
template_argsrWNc��g|]}|��S�ra)�.0r;s  r�
<listcomp>zrevision.<locals>.<listcomp>�s��H�H�H�&�v�H�H�HrYrr)r�from_config�dict�autogen�RevisionContextr
�asbool�get_main_optionr0rr_�run_env�generate_scripts�len)rrBr	rDrArErFrGrHrIrJ�script_directory�command_args�environmentrX�scriptsrWs                @r�revisionrq{s���t'�2�6�:�:����!��
��!�!���
�
�
�L��.����$?�	�����+�f�4�4�5K�L�L�M�M�K��
����	��#�I���
�	�	�	�	�	�	�
�

�	�	�	�	�	�	�

�
���
M�
�
�	
�
�	'�
���"��*�8�-�

�
�
�	'�	'�
�$�$�&�&�&�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'����	'�	'�	'�	'�I�H�$4�$E�$E�$G�$G�H�H�H�G�
�7�|�|�q����q�z���s�C(�(C,�/C,�'Config'c����tj|��}tddddddddd��	�	}tj|||����fd�}t|||d�j����5|���ddd��n#1swxYwY�jd}|j	�
��}|rtjd	|�����|�
d
��dS)z�Check if revision command with autogenerate has pending upgrade ops.

    :param config: a :class:`.Config` object.

    .. versionadded:: 1.9.0

    NTFrArNc�4����||��gSrQrRrTs  �rrXz"check.<locals>.retrieve_migrationss����)�)�#�w�7�7�7��	rYr\���z!New upgrade operations detected: z#No new upgrade operations detected.)rrdrerfrgrr_rj�generated_revisions�upgrade_ops�as_diffsr
�AutogenerateDiffsDetectedr)rrmrnrX�migration_script�diffsrWs      @r�checkr|�s{���'�2�6�:�:������
������
�
�
�L��.������������
�����&�4�)�

�
�
�#�#�	� � �"�"�"�#�#�#�#�#�#�#�#�#�#�#����#�#�#�#�(�;�B�?���(�1�1�3�3�E��C��,�7��7�7�
�
�	
�	���A�B�B�B�B�Bs�#B�B�B�	revisions�Optional[Script]c�~�tj|��}d|i}|j|ptj��|fd||d�|��S)a{Merge two revisions together.  Creates a new migration file.

    :param config: a :class:`.Config` instance

    :param message: string message to apply to the revision

    :param branch_label: string label name to apply to the new revision

    :param rev_id: hardcoded revision identifier instead of generating a new
     one.

    .. seealso::

        :ref:`branches`

    rT)�refreshrA�
branch_labels)rrd�generate_revisionr
rH)rr}rBrFrHr;r_s       r�merger�2si��0�
(��
0�
0�F��&��M�$�6�#���$�+�-�-����
�"����
��rYrq�tagc	�.���tj|���d}d�vr/|stjd�����dd��\}���fd�}t|�|||�|���5����ddd��dS#1swxYwYdS)adUpgrade to a later version.

    :param config: a :class:`.Config` instance.

    :param revision: string revision target or range for --sql mode

    :param sql: if True, use ``--sql`` mode

    :param tag: an arbitrary "tag" that can be intercepted by custom
     ``env.py`` scripts via the :meth:`.EnvironmentContext.get_tag_argument`
     method.

    N�:�Range revision not allowed�c�0�����|��SrQ)�
_upgrade_revs�rUrVrqr;s  ��r�upgradezupgrade.<locals>.upgradeus����#�#�H�c�2�2�2rY�r]r^�starting_rev�destination_revr��rrdr
r0�splitrrj)rrqrDr�r�r�r;s `    @rr�r�Ys����(�
(��
0�
0�F��L�
�h����	B��#�$@�A�A�A�!)����Q�!7�!7���h�3�3�3�3�3�3�
�����!� ��
�
�
�	�	�	������	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�(B
�
B�Bc	�\���tj|���d}d�vr0|stjd�����dd��\}�n|rtjd�����fd�}t|�|||�|���5����ddd��dS#1swxYwYdS)afRevert to a previous version.

    :param config: a :class:`.Config` instance.

    :param revision: string revision target or range for --sql mode

    :param sql: if True, use ``--sql`` mode

    :param tag: an arbitrary "tag" that can be intercepted by custom
     ``env.py`` scripts via the :meth:`.EnvironmentContext.get_tag_argument`
     method.

    Nr�r�r�z/downgrade with --sql requires <fromrev>:<torev>c�0�����|��SrQ)�_downgrade_revsr�s  ��r�	downgradezdowngrade.<locals>.downgrade�s����%�%�h��4�4�4rYr�r�)rrqrDr�r�r�r;s `    @rr�r��s9����(�
(��
0�
0�F��L�
�h����	B��#�$@�A�A�A�!)����Q�!7�!7���h�h�	�
���=�
�
�	
�5�5�5�5�5�5�
�����!� ��
�
�
�	�	�	������	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�?B!�!B%�(B%c�0���tj����|dkrG��fd�}t��|���5����ddd��dS#1swxYwYdS��|��D]}��|j���dS)z�Show the revision(s) denoted by the given symbol.

    :param config: a :class:`.Config` instance.

    :param revision: string revision target

    �currentc�l����|��D]}��|j���gSrQ)�
get_revisionsr�	log_entry)rUrV�scrr;s   ��r�show_currentzshow.<locals>.show_current�s>����*�*�3�/�/�
2�
2���#�#�B�L�1�1�1�1��IrY�r]N)rrdrrjr�rr�)rrUr�r�r;s`   @r�showr��s�����
(��
0�
0�F�
�i���	�	�	�	�	�	�
 ���<�
@�
@�
@�	�	��N�N����	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	��&�&�s�+�+�	.�	.�B������-�-�-�-�	.�	.s�A�A�A�	rev_range�verbose�indicate_currentc����	�tj|��}|�Cd|vrtjd���|����d��\}}ndx}}tj|�d����p�}d	��fd�	�	�	fd�}|dks|dks|r|||||��dS�	||||��dS)
z�List changeset scripts in chronological order.

    :param config: a :class:`.Config` instance.

    :param rev_range: string revision range

    :param verbose: output in verbose mode.

    :param indicate_current: indicate current revision.

    Nr�z9History range requires [start]:[end], [start]:, or :[end]rOrac	���|�|pd|pd���D]>}�r|j|v|_|�|��ddd������?dS)N�base�heads)r�rAT)r��include_branches�include_doc�include_parents)�walk_revisionsrq�_db_current_indicatorr�
cmd_format)rr;r�rA�currentsr�r�r�s      ��r�_display_historyz!history.<locals>._display_history�s�����'�'����d�o�g�(�
�
�	�	�B� �
C�+-�;�(�+B��(�����
�
�#�%)� $�$(�	���
�
�
�
�	�	rYc������������fd�}t��|���5����ddd��dS#1swxYwYdS)Nc�~���dkr����||��n%�dkr���|�|��n�����|��gS)Nr�ra)rUrVr�r�rrAr;s  �����r�_display_current_historyzMhistory.<locals>._display_history_w_current.<locals>._display_current_history�so����y� � � � ����s�C�@�@�@�@���"�"� � ����d�C�@�@�@�@� � ����t�S�A�A�A��IrYr�)rrj)rr;r�rAr�r�s```` �r�_display_history_w_currentz+history.<locals>._display_history_w_current�s��������	�	�	�	�	�	�	�	�	� ���3K�
L�
L�
L�	�	��N�N����	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�A�A�
Ar�)ra)rrdr
r0�stripr�rhri)
rr�r�r�r;r�rAror�r�s
  ``     @r�historyr��s,�����&�
(��
0�
0�F����i����#�N���
��_�_�&�&�,�,�S�1�1�
��d�d����t�	
��F�*�*�+A�B�B�C�C�	���
�������"������y���D�I�-�-��-�"�"�6�6�4��>�>�>�>�>������t�4�4�4�4�4rYc��tj|��}|r|�d��}n'|�|�����}|D]-}|�|�|dd������.dS)z�Show current available heads in the script directory.

    :param config: a :class:`.Config` instance.

    :param verbose: output in verbose mode.

    :param resolve_dependencies: treat dependency version as down revisions.

    r�TF)r��tree_indicatorsN)rrdr��	get_headsrr�)rr��resolve_dependenciesr;r�rUs      rr�r�s����
(��
0�
0�F��9��$�$�W�-�-����$�$�V�%5�%5�%7�%7�8�8���
�
������N�N��$��
�
�
�	
�	
�	
�	
�
�
rYc
�*����tj|�������D]f��jr]|�d���d���d���fd��fd��jD��D�������gdS)zShow current branch points.

    :param config: a :class:`.Config` instance.

    :param verbose: output in verbose mode.

    z%s
%s
T)r��
c3��K�|]C}dtt�j����z�d|�dd������V��DdS)� z -> FT)r�r�N)rlr#rqr�)rb�rev_objr�r�s  ��r�	<genexpr>zbranches.<locals>.<genexpr>8s������� ��c�#�b�k�"2�"2�3�3�3�3�3��*�*�!�D�g�+����������rYc3�B�K�|]}��|��V��dSrQ)�get_revision)rbrUr;s  �rr�zbranches.<locals>.<genexpr>@sB�����$�$�58��+�+�C�0�0�$�$�$�$�$�$rYN)rrdr��is_branch_pointrr�r�nextrev)rr�r�r;s `@@r�branchesr�*s�������
(��
0�
0�F��#�#�%�%����
��	������
�
�g��
�=�=��	�	������$�$�$�$�<>�J�$�$�$������
�
�
���rYc������tj�������fd�}t��|d���5����ddd��dS#1swxYwYdS)z�Display the current revision for a database.

    :param config: a :class:`.Config` instance.

    :param verbose: output in verbose mode.

    c����r7��dtj|jjj������|��D]*}��|�������+gS)NzCurrent revision(s) for %s:)rr
�obfuscate_url_pw�
connection�engine�url�get_all_currentr�)rUrVrr;r�s  ���r�display_versionz current.<locals>.display_versionRs�����	����-��%�g�&8�&?�&C�D�D�
�
�
��)�)�#�.�.�	9�	9�C�������w� 7� 7�8�8�8�8��	rYT)r]�dont_mutateN�rrdrrj)rr�r�r;s`` @rr�r�Gs�������
(��
0�
0�F�	�	�	�	�	�	�	�
���?��
�
�
���	��������������������������s�A�A�A�purgec
��	�
�tj|���
|rmg�	d}tj|��D]S}d|vr8|�dd��\}}||kr|�|}ntjd����	�|���Tntj|���	�	�
fd�}t|�
|||r|ndtj�	��||���5�
�	��ddd��dS#1swxYwYdS)a'stamp' the revision table with the given revision; don't
    run any migrations.

    :param config: a :class:`.Config` instance.

    :param revision: target revision or list of revisions.   May be a list
     to indicate stamping of multiple branch heads.

     .. note:: this parameter is called "revisions" in the command line
        interface.

     .. versionchanged:: 1.2  The revision may be a single revision or
        list of revisions when stamping multiple branch heads.

    :param sql: use ``--sql`` mode

    :param tag: an arbitrary "tag" that can be intercepted by custom
     ``env.py`` scripts via the :class:`.EnvironmentContext.get_tag_argument`
     method.

    :param purge: delete all entries in the version table before stamping.

     .. versionadded:: 1.2

    Nr�r�zMStamp operation with --sql only supports a single starting revision at a timec�T����tj���|��SrQ)�_stamp_revsr
�to_tuple)rUrV�destination_revsr;s  ��r�do_stampzstamp.<locals>.do_stamp�s$����!�!�$�-�0@�"A�"A�3�G�G�GrY)r]r^r�r�r�r�)
rrdr
�to_listr�r0�appendrr�rj)rrqrDr�r�r��	_revision�srevr�r�r;s         @@r�stampr�cs�����B�
(��
0�
0�F�
�2�������h�/�/�	/�	/�I��i���"+�/�/�#�q�"9�"9���i��4�'�'�#�+�'+���"�/�A����
�#�#�I�.�.�.�.�	/� �<��1�1��H�H�H�H�H�H�
�����%(�2�\�\�d��
�&6�7�7���	
�	
�	
�
�
�	������
�
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�
�
s�
C/�/C3�6C3rUc�h��tj|���|dkrF�fd�}t|�|���5����ddd��dS#1swxYwYdS��|��}|stjd|z���|D]}|sJ�tj|j��� dS)zEdit revision script(s) using $EDITOR.

    :param config: a :class:`.Config` instance.

    :param rev: target revision.

    r�c���|stjd�����|��D]}tj|j���gS)NzNo current revisions)r
r0r��open_in_editorr)rUrVr�r;s   �r�edit_currentzedit.<locals>.edit_current�sV����
@��'�(>�?�?�?��*�*�3�/�/�
-�
-���#�B�G�,�,�,�,��IrYr�Nz*No revision files indicated by symbol '%s')	rrdrrjr�r
r0r�r)rrUr��revsr�r;s     @r�editr��s8����
(��
0�
0�F�
�i���	�	�	�	�	� ���<�
@�
@�
@�	�	��N�N����	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	��#�#�C�(�(���	��#�<�s�B���
��	)�	)�B��I�I�2�����(�(�(�(�	)�	)s�A�A�Ac��tj|��}d�}t||||���5|���ddd��dS#1swxYwYdS)z�Create the alembic version table if it doesn't exist already .

    :param config: a :class:`.Config` instance.

    :param sql: use ``--sql`` mode

     .. versionadded:: 1.7.6

    c�.�|���gSrQ)�_ensure_version_table)rUrVs  r�do_ensure_versionz)ensure_version.<locals>.do_ensure_version�s���%�%�'�'�'��	rY)r]r^Nr�)rrDr;r�s    r�ensure_versionr��s����
(��
0�
0�F����
�����	
�
�
���	������
��������������������s�A
�
A�A)rr
)r!F)
rr
r"r#r$r#r%r&r'r()
NFFrAFNNNNN)rr
rBrCr	r&rDr&rAr#rEr&rFrCrGrCrHrCrIrCrJrKr'rL)rrrr'r()NNN)rr
r}r#rBrCrFrCrHrCr'r~)FN)
rr
rqr#rDr&r�rCr'r()NFF)
rr
r�rCr�r&r�r&r'r()FF)F)rr
r�r&r'r()FNF)rr
rqr#rDr&r�rCr�r&r'r()rr
rUr#r'r()rr
rDr&r'r()$�
__future__rr�typingrrrr�r	rfr
�runtime.environmentrr;r�alembic.configr
�alembic.script.baserrr r@rqr|r�r�r�r�r�r�r�r�r�r�r�rarYr�<module>r�s���"�"�"�"�"�"�	�	�	�	������������� � � � � � �������%�%�%�%�%�%�������3�3�3�3�3�3�#�#�#�#�#�#��@�%�%�%�%�%�%�*�*�*�*�*�*�?�?�?�?�?�?�I�I�I�I�,��	Q�Q�Q�Q�Q�l"�����"&�"&� � $�HL�|�|�|�|�|�~5C�5C�5C�5C�v"�"&� �$�$�$�$�$�T��	(�(�(�(�(�\��	+�+�+�+�+�\.�.�.�6 $��"�	C5�C5�C5�C5�C5�L
�
�
�
�2����:�����>���C�C�C�C�C�L)�)�)�)�B������rY