� J�g������ddlmZddlmZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd l mZddl mZddl mZddlmZddlmZddlmZddlmZddlmZddlmZer*ddlmZddlm Z ddlm!Z!ddl"m#Z#ddl"m$Z$ddl%m&Z&ddl%m'Z' ej(r ddl)m*Z*dd l)m+Z+n ddl,m*Z*dd l,m+Z+n #e-$rdZ*YnwxYwej.d!��Z/ej.d"��Z0ej.d#��Z1ej.d$��Z2d%Z3ej.d&��Z4ej.d'��Z5Gd(�d)��Z6Gd*�d+ej!��Z7dS),�)� annotations)�contextmanagerN)� ModuleType)�Any)�cast)�Iterator)�List)�Mapping)�Optional)�Sequence)�Set)�Tuple)� TYPE_CHECKING)�Union���revision)� write_hooks�)�util)� migration)�compat)�not_none)� _GetRevArg)� _RevIdType)�Revision)�Config)�MessagingOptions)� RevisionStep)� StampStep)�ZoneInfo)�ZoneInfoNotFoundErrorz (?!\.\#|__init__)(.*\.py)(c|o)?$z(?!\.\#|__init__)(.*\.py)$z([a-f0-9]+)\.py$z\w+z%(rev)s_%(slug)sz , *|(?: +)z , *|(?: +)|\:c ��eZdZdZedddddddedej��f dcd�Ze ddd���Z ej ded���Z dfd�Z edgd!���Ze dhdid(���Z djdkd,�Zdld0�Zdmd3�Zdnd5�Zdod7�Zdpd=�Zdqd>�Zdrd@�ZdqdA�ZdrdB�ZdsdF�ZdtdG�ZdudK�ZdvdL�Ze dddM���Z dwdP�Z!dxdQ�Z"dydS�Z#dzdU�Z$ d{d|d_�Z%d}db�Z&dS)~�ScriptDirectoryaHProvides operations upon an Alembic script directory. This object is useful to get information as to current revisions, most notably being able to get at the "head" revision, for schemes that want to test if the current revision in the database is the most recent:: from alembic.script import ScriptDirectory from alembic.config import Config config = Config() config.set_main_option("script_location", "myapp:migrations") script = ScriptDirectory.from_config(config) head_revision = script.get_current_head() �(NF�utf-8r�dir�str� file_template�truncate_slug_length� Optional[int]�version_locations�Optional[List[str]]� sourceless�bool�output_encoding�timezone� Optional[str]� hook_config�Optional[Mapping[str, str]]�recursive_version_locations�messaging_opts�return�Nonec �x�||_||_||_|pd|_||_||_t j|j��|_ ||_ ||_ | |_ | |_ tj|tj��s4t#jdtj�|��z���dS)Nr%zVPath doesn't exist: %r. Please use the 'init' command to create a new scripts folder.)r'r)r,r*r.r0r� RevisionMap�_load_revisions� revision_mapr1r3r5r6�os�access�F_OKr� CommandError�path�abspath) �selfr'r)r*r,r.r0r1r3r5r6s �c/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/alembic/script/base.py�__init__zScriptDirectory.__init__Ns������*���!2���$8�$>�B��!�$���.���$�0��1E�F�F��� �� �&���+F��(�,����y��b�g�&�&� ��#�"�$&�G�O�O�C�$8�$8�9��� � � �c�n�|j}t|��dkrtjd���|dS)Nrz"Multiple version_locations presentr)�_version_locations�lenrr@)rC�locs rD�versionszScriptDirectory.versionsps4���%�� �s�8�8�a�<�<��#�$H�I�I� I��q�6�MrF� Sequence[str]c��|jrd�|jD��Stj�tj�|jd����fS)Nc�p�g|]3}tj�tj|������4S�)r=rArBr�coerce_resource_to_filename)�.0�locations rD� <listcomp>z6ScriptDirectory._version_locations.<locals>.<listcomp>{sA����������� @�� J� J�K�K���rFrK)r,r=rArB�joinr'�rCs rDrHz"ScriptDirectory._version_locationsxs]�� � !� J��� $� 6���� � �G�O�O�B�G�L�L���:�$F�$F�G�G�I� IrF�Iterator[Script]c#�K�|jrd�|jD��}n|jg}t��}|D]�}t�||��D]�}t j�|��}||vrtj d|z���=|� |��t j� |��}t j� |��}t�|||��}|���|V�����dS)Nc�P�g|]#}tj�|���!|��$SrO)r=rA�exists)rQ�verss rDrSz3ScriptDirectory._load_revisions.<locals>.<listcomp>�s<�������7�>�>�$�'�'�����rFzJFile %s loaded twice! ignoring. Please ensure version_locations is unique.)r,rHrK�set�Script� _list_py_dirr=rA�realpathr�warn�add�basename�dirname�_from_filename) rC�paths�dupesrZ� file_path� real_path�filename�dir_name�scripts rDr;zScriptDirectory._load_revisions�s0���� � !� $��� �3����E�E� �]�O�E������ � �D�#�0�0��t�<�<� � � ��G�,�,�Y�7�7� ���%�%��I�7�9B�C������ � �)�$�$�$��7�+�+�I�6�6���7�?�?�9�5�5���.�.�t�X�x�H�H���>��� � � � � � � rF�configrc ��|�d��}|�tjd���|�d��}|�t|��}nd}|�d��}|r�|�d��}dddtjd d d �} ||}|�t �|��} nGd �|�|��D��} n'#t$r} td |z��| �d} ~ wwxYwd} |�d��} | r6tt�| ����tj dd�<|�d��dk} ttj|��|�dt ��||�d��dk|�dd��| |�d��|�di��| |j�� � S)z�Produce a new :class:`.ScriptDirectory` given a :class:`.Config` instance. The :class:`.Config` need only have the ``script_location`` key present. �script_locationNz0No 'script_location' key found in configuration.r*r,�version_path_separator� � �:�;)N�space�newliner=rqrrc�:�g|]}|�|�����SrO)�strip)rQ�xs rDrSz/ScriptDirectory.from_config.<locals>.<listcomp>�s6��)�)�)���)���� � �)�)�)rFza'%s' is not a valid value for version_path_separator; expected 'space', 'newline', 'os', ':', ';'�prepend_sys_pathrr5�truer)r.r0r&r1�post_write_hooks) r)r*r.r0r,r1r3r5r6)�get_main_optionrr@�intr=�pathsep�_split_on_space_comma�split�KeyError� ValueError�list�_split_on_space_comma_colon�sysrAr$rP�_default_file_template� get_sectionr6) �clsrkrm�tslr*�version_locations_strrn� split_on_path� split_charr,�kerx�rvls rD� from_configzScriptDirectory.from_config�su��!�0�0�1B�C�C�� � "��#�E��� ��$�$�%;�<�<�� �?�#&�s�8�8� � �#'� � &� 6� 6�7J� K� K�� �& %�%+�%;�%;�(�&�&� "� ����j��� ��M� �,9�*�-� ��%�(=�(C�(C�-�)�)�%�%�)�)�!6�!<�!<�Z�!H�!H�)�)�)�%�%��� � � � �B�-�-��� � ����� ����(!%� �!�1�1�2D�E�E�� � ��+�1�1�2B�C�C���C�H�R�a�R�L��$�$�%B�C�C�v�M��� � ,�_� =� =� �0�0��!7���"6��-�-�l�;�;�v�E�"�2�2�3D�g�N�N�/��+�+�J�7�7��*�*�+=�r�B�B�(+�!�0�  �  �  � s�C� C<�$C7�7C<�ancestor�multiple_heads�start�end� resolution�Iterator[None]c#�`K� dV�dS#tj$r^}|�tt|j��}|�tt|j��}|sd}|||d�z}t j|��|�d}~wtj$rD}|sd}||p|j t j |j ��d�z}t j|��|�d}~wtj $r&}|� d|j z}t j|��|�d}~wtj $r%} t j| jd��| �d} ~ wwxYw)NzgRequested range %(start)s:%(end)s does not refer to ancestor/descendant revisions along the same branch�r�r�z�Multiple head revisions are present for given argument '%(head_arg)s'; please specify a specific target revision, '<branchname>@%(head_arg)s' to narrow to a specific head, or 'heads' for all heads)�head_arg�headsz(Can't locate revision identified by '%s'r)r�RangeNotAncestorErrorrr�lower�upperrr@� MultipleHeads�argument�format_as_commar��ResolutionError� RevisionError�args) rCr�r�r�r�r��rna�mh�re�errs rD�_catch_revision_errorsz&ScriptDirectory._catch_revision_errors�s�����# :� �E�E�E�E�E���-� 7� 7� 7��}��S�#�)�,�,���{��3�� �*�*��� �J�� �E�#�">�">�>�H��#�H�-�-�3� 6������%� <� <� <�!� �J��,��.�2�;��-�b�h�7�7�/�/��N��#�N�3�3�� ;������'� 8� 8� 8��!�G��K�� ��#�J�/�/�R� 7������%� :� :� :��#�C�H�Q�K�0�0�c� 9����� :���s9� �D-�AA2�2D-�?C�D-�!C6�6D-� D(�(D-�baser��headc#��K�|�||���5|j�||dd���D]}tt|��V�� ddd��dS#1swxYwYdS)a-Iterate through all revisions. :param base: the base revision, or "base" to start from the empty revision. :param head: the head revision; defaults to "heads" to indicate all head revisions. May also be "head" to indicate a single head revision. r�TF)� inclusive�assert_relative_lengthN)r�r<�iterate_revisionsrr\)rCr�r��revs rD�walk_revisionszScriptDirectory.walk_revisions"s������ (� (�t�� (� >� >� (� (��(�:�:��d�d�5�;��� (� (���6�3�'�'�'�'�'�'� (� (� (� (� (� (� (� (� (� (� (� (� (���� (� (� (� (� (� (s�9A!�!A%�(A%�id_r�Tuple[Script, ...]c���|���5tttdf|j�|����cddd��S#1swxYwYdS)z�Return the :class:`.Script` instance with the given rev identifier, symbolic name, or sequence of identifiers. .N)r�rrr\r<� get_revisions�rCr�s rDr�zScriptDirectory.get_revisions5s��� � (� (� *� *� � ���f�c�k�"��!�/�/��4�4��� � � � � � � � � � � � ���� � � � � � s�:A�A �#A �Tuple[str, ...]� Set[Script]c���|���5ttt|j�|����cddd��S#1swxYwYdS�N)r�rr r\r<�_get_all_currentr�s rD�get_all_currentzScriptDirectory.get_all_current@s��� � (� (� *� *� N� N���F� �T�%6�%G�%G��%L�%L�M�M� N� N� N� N� N� N� N� N� N� N� N� N���� N� N� N� N� N� Ns�8A�A�!Ar\c��|���5tt|j�|����cddd��S#1swxYwYdS)z�Return the :class:`.Script` instance with the given rev id. .. seealso:: :meth:`.ScriptDirectory.get_revisions` N)r�rr\r<� get_revisionr�s rDr�zScriptDirectory.get_revisionDs���� (� (� *� *� E� E���� 1� >� >�s� C� C�D�D� E� E� E� E� E� E� E� E� E� E� E� E���� E� E� E� E� E� Es�-A�A�A�%Optional[Union[str, Tuple[str, ...]]]c��|���5|j�|��\}}ddd��n #1swxYwY|sdS|dkr|S|dS)z[Convert a symbolic revision, i.e. 'head' or 'base', into an actual revision number.Nr�r)r�r<�_resolve_revision_number)rCr�r�� branch_names rD�as_revision_numberz"ScriptDirectory.as_revision_numberPs��� � (� (� *� *� O� O�#�0�I�I�#�N�N� �C�� O� O� O� O� O� O� O� O� O� O� O���� O� O� O� O�� ��4� �G�^�^��J��q�6�Ms�?�A�Ar��!Union[str, Tuple[str, ...], None]r��kwrc �f�ttt|jj||fi|����S)a�Iterate through script revisions, starting at the given upper revision identifier and ending at the lower. The traversal uses strictly the `down_revision` marker inside each migration script, so it is a requirement that upper >= lower, else you'll get nothing back. The iterator yields :class:`.Script` objects. .. seealso:: :meth:`.RevisionMap.iterate_revisions` )rrr\r<r�)rCr�r�r�s rDr�z!ScriptDirectory.iterate_revisionsas;��*� �V� � /�D� � /��u� C� C�� C� C� � � rFc��|�d���5|j���cddd��S#1swxYwYdS)aGReturn the current head revision. If the script directory has multiple heads due to branching, an error is raised; :meth:`.ScriptDirectory.get_heads` should be preferred. :return: a string revision number. .. seealso:: :meth:`.ScriptDirectory.get_heads` z}The script directory has multiple heads (due to branching).Please use get_heads(), or merge the branches using alembic merge.�r�N)r�r<�get_current_headrUs rDr�z ScriptDirectory.get_current_head{s���� (� (�!�)� � � 8� 8��$�5�5�7�7� 8� 8� 8� 8� 8� 8� 8� 8� 8� 8� 8� 8���� 8� 8� 8� 8� 8� 8s�=�A�A� List[str]c�4�t|jj��S)aUReturn all "versioned head" revisions as strings. This is normally a list of length one, unless branches are present. The :meth:`.ScriptDirectory.get_current_head()` method can be used normally when a script directory has only one head. :return: a tuple of string revision numbers. )r�r<r�rUs rD� get_headszScriptDirectory.get_heads�s���D�%�+�,�,�,rFc��|���}t|��dkrtjd���|r|dSdS)a#Return the "base" revision as a string. This is the revision number of the script that has a ``down_revision`` of None. If the script directory has multiple bases, an error is raised; :meth:`.ScriptDirectory.get_bases` should be preferred. rz@The script directory has multiple bases. Please use get_bases().rN)� get_basesrIrr@)rC�basess rD�get_basezScriptDirectory.get_base�sT����� � �� �u�:�:��>�>��#�*��� �� ���8�O��4rFc�4�t|jj��S)z�return all "base" revisions as strings. This is the revision number of all scripts that have a ``down_revision`` of None. )r�r<r�rUs rDr�zScriptDirectory.get_bases�s���D�%�+�,�,�,rF� destination� current_rev�List[RevisionStep]c������d|���5��||d���}�fd�tt|����D��cddd��S#1swxYwYdS)NzFDestination %(end)s is not a valid upgrade target from current head(s)�r�r�T)� implicit_basec�Z��g|]'}tj��j|����(SrO)r� MigrationStep�upgrade_from_scriptr<�rQrjrCs �rDrSz1ScriptDirectory._upgrade_revs.<locals>.<listcomp>�sF��������'�;�;��%�v�����rF)r�r��reversedr��rCr�r��revss` rD� _upgrade_revszScriptDirectory._upgrade_revs�s����� (� (�*��)� � � � � �)�)��[��*���D�����'�t�D�z�z�2�2� ��� � � � � � � � � � � � ���� � � � � � s�AA&�&A*�-A*c�����d|���5��||d���}�fd�|D��cddd��S#1swxYwYdS)NzHDestination %(end)s is not a valid downgrade target from current head(s)r�T)�select_for_downgradec�Z��g|]'}tj��j|����(SrO)rr��downgrade_from_scriptr<r�s �rDrSz3ScriptDirectory._downgrade_revs.<locals>.<listcomp>�sF��������'�=�=��%�v�����rF)r�r�r�s` rD�_downgrade_revszScriptDirectory._downgrade_revs�s����� (� (�*��)� � � � � �)�)��[�t�*���D�����#� ��� � � � � � � � � � � � ���� � � � � � s�&A � A�Arr�List[StampStep]c ������d���5��|��}g}|sd}g}tj|��D]R}|rN|��j�ttt|��|d������Stj |��}��|��pdg}|D�]}}|�"|��fd�|D�����'||vr�,t�j� |g����} t�j� |g����} | �|��r[| �|��rJ�d�|D��} tj| |jdd�j��} |�| ����| �|��rEd �|D��} tj| |jdd�j��} |�| ����Ftjd |jdd�j��} |�| ����|cddd��S#1swxYwYdS) NzCMultiple heads are present; please specify a single target revisionr�r�T)�include_dependenciesc �T��g|]$}tj|jddd�j����%S)NFT)rr rr<)rQr�rCs �rDrSz/ScriptDirectory._stamp_revs.<locals>.<listcomp>sL��� � � �!%�&�/� $� � $� %� $� $� 1� �� � � rFc��g|] }|j�� SrOr�rQr�s rDrSz/ScriptDirectory._stamp_revs.<locals>.<listcomp>���!K�!K�!K�D�$�-�!K�!K�!KrFFc��g|] }|j�� SrOrr�s rDrSz/ScriptDirectory._stamp_revs.<locals>.<listcomp>,r�rFrO)r�r�r�to_tuple�extendr<�filter_for_lineagerr r\� unique_listr[�_get_descendant_nodes�_get_ancestor_nodes� intersectionrr r�append) rCrr�� heads_revs�steps�filtered_headsr��dests�dest� descendants� ancestors� todo_heads�steps ` rD� _stamp_revszScriptDirectory._stamp_revs�s<���� (� (�%�)� � �Y �Y ��+�+�E�2�2�J��E�� "�!��+-�N��}�X�.�.� � ����"�)�)��)�<�<� ��&�!1�:�>�>��15�=�������"�-�n�=�=�N��&�&�x�0�0�:�T�F�E��> �> ���<��L�L� � � � �)7� � � � � � ���^�+�+��"��%�;�;�T�F�C�C��� � �� 1� E� E�t�f� M� M�N�N� ��+�+�N�;�;�"� )�5�5�n�E�E�E�E�E�!K�!K�N�!K�!K�!K�J�$�.�"�� ����)� ��D��L�L��&�&�&���+�+�N�;�;��"L�!K�N�!K�!K�!K�J�$�.�"�� ����)� ��D��L�L��&�&�&��%�.��D�M�4��t�7H���D��L�L��&�&�&���sY �Y �Y �Y �Y �Y �Y �Y �Y �Y �Y �Y ����Y �Y �Y �Y �Y �Y s�H3I�I�Ic�:�tj|jd��dS)z�Run the script environment. This basically runs the ``env.py`` script present in the migration environment. It is called exclusively by the command functions in :mod:`alembic.command`. �env.pyN)r�load_python_filer'rUs rD�run_envzScriptDirectory.run_envAs�� ��d�h��1�1�1�1�1rFc��tj�tj�|jd����S)Nr�)r=rArBrTr'rUs rD�env_py_locationzScriptDirectory.env_py_locationLs(���w���r�w�|�|�D�H�h�?�?�@�@�@rF�srcr�c ���tjdtj�|����fi|j��5tj|||jfi|��ddd��dS#1swxYwYdS�Nz Generating )r�statusr=rArBr6�template_to_filer0)rCrr�r�s rD�_generate_templatez"ScriptDirectory._generate_templatePs��� �[� 1�"�'�/�/�$�/�/� 1� 1� � �59�5H� � � I� I� � !�#�t�T�-A� H� H�R� H� H� H� I� I� I� I� I� I� I� I� I� I� I� I���� I� I� I� I� I� Is�A�A#�&A#c���tjdtj�|����fi|j��5t j||��ddd��dS#1swxYwYdSr)rrr=rArBr6�shutil�copy)rCrr�s rD� _copy_filezScriptDirectory._copy_fileVs��� �[� 1�"�'�/�/�$�/�/� 1� 1� � �59�5H� � � #� #� �K��T� "� "� "� #� #� #� #� #� #� #� #� #� #� #� #���� #� #� #� #� #� #s�A�A�"ArAc��tj�|��}tj�|��sIt jd|��fi|j��5tj|��ddd��dS#1swxYwYdSdS)NzCreating directory )r=rArBrYrrr6�makedirs)rCrAs rD�_ensure_directoryz!ScriptDirectory._ensure_directory\s����w���t�$�$���w�~�~�d�#�#� "���,�d�,�,���04�0C��� "� "�� �D�!�!�!� "� "� "� "� "� "� "� "� "� "� "� "���� "� "� "� "� "� "� "� "s�A;�;A?�A?�datetime.datetimec�*�|j��t�tjd��� t|j��}n#t$rd}YnwxYw|�S t|j�����}n+#t$rtjd|jz��d�wxYwt j����t jj ���� |��}nt j� ��}|S)NzePython >= 3.9 is required for timezone support or the 'backports.zoneinfo' package must be installed.zCan't locate timezone: %s)�tzinfo) r1r!rr@r"r��datetime�utcnow�replace�utc� astimezone�now)rCr� create_dates rD�_generate_create_datez%ScriptDirectory._generate_create_dateds"�� �=� $����'�J����  �!�$�-�0�0����(� � � ����� �����~� �%�d�m�&9�&9�&;�&;�<�<�F�F��,� � � ��+�3�d�m�C���� � ���� �!�(�(�*�*���� 1� 5��6�6���F�#�#� �K� #�+�/�/�1�1�K��s�9� A�A�&A5�5(B�revid�message�Optional[_RevIdType]�splice�Optional[bool]� branch_labels� version_path� depends_on�Optional[Script]c ���|�d} t�|��n7#tj$r%} t j| jd��| �d} ~ wwxYw��d���5tttddf�j � |����} | D] } | dksJ�� ddd��n #1swxYwYtt| ����t| ��krt jd �������} |�xt�j��d krY| D]A} | �=t#| t��sJ�t$j�| j��}n�Bt jd ���n�j}t$j�t$j�|����}�jD]'}t$j�|��|krn�(t jd |z����jr��|����|||| ��}|s*| D]'} | �#| jst jd | jz����(|rW����5d��fd�t j|��D��D��}ddd��n #1swxYwYnd}�jt$j��jd��|ftA|��tj!tEd�| D������t j#|��tj!|��| tj$|�|ndd�|���j%}|rtMj'||�� t�(�|��}n7#tj$r%} t j| jd��| �d} ~ wwxYw|�dS|r/|j)s(t jd|j�d|�d|j�d�����j �*|��|S)a�Generate a new revision file. This runs the ``script.py.mako`` template, given template arguments, and creates a new file. :param revid: String revision id. Typically this comes from ``alembic.util.rev_id()``. :param message: the revision message, the one passed by the -m argument to the ``revision`` command. :param head: the head revision to generate against. Defaults to the current "head" if no branches are present, else raises an exception. :param splice: if True, allow the "head" version to not be an actual head; otherwise, the selected head must be a head (e.g. endpoint) revision. Nr�rz{Multiple heads are present; please specify the head revision on which the new revision should be based, or perform a merge.r�r.r�z"Duplicate head revisions specifiedrzAMultiple version locations present, please specify --version-pathz7Path %s is not represented in current version locationszeRevision %s is not a head revision; please specify --splice to create a new branch from this revisionc�8�g|]\}}||jvr|n|j��SrO)rr)rQr��deps rDrSz5ScriptDirectory.generate_revision.<locals>.<listcomp>�sE�� '� '� '� !��S��#�"3�3�3��� �\� '� '� 'rFc�b��g|]+}t�j�|����|f��,SrO)rr<r�)rQr%rCs �rDrSz5ScriptDirectory.generate_revision.<locals>.<listcomp>�sG���%�%�%��"�$�"3�"@�"@��"E�"E�F�F��L�%�%�%rFzscript.py.makoc3�,K�|]}|�|jndV��dSr�r)rQ�hs rD� <genexpr>z4ScriptDirectory.generate_revision.<locals>.<genexpr>�s,����K�K��A�M�a�j�j�t�K�K�K�K�K�KrFz empty message)� up_revision� down_revisionrr!r�commarzVersion z specified branch_labels z, however the migration file zb does not have them; have you upgraded your script.py.mako to include the 'branch_labels' section?)+r\� verify_rev_idrr�rr@r�r�rrr r<r�rIr[rrH� isinstancer=rArbrK�normpathrBr,r� _rev_path�is_head�to_listrrTr'r(�tuple_rev_as_scalar�tupler�r�r3r� _run_hooks� _from_pathr� add_revision)rCrrr�rrr r!r�r�r�r(r�head_� norm_path� vers_pathrA�resolved_depends_onrzrjs` rD�generate_revisionz!ScriptDirectory.generate_revision�sl���8 �<��D� :� � � �� '� '� '� '���%� :� :� :��#�C�H�Q�K�0�0�c� 9����� :����� (� (�&�)� � � #� #���h�z�*�C�/�0��!�/�/��5�5���E�� #� #���F�{�{�{�{�{� #� #� #� #� #� #� #� #� #� #� #� #���� #� #� #� #� �s�5�z�z�?�?�c�%�j�j� (� (��#�$H�I�I� I��0�0�2�2� � � ��4�*�+�+�a�/�/�"� � �E��(�)�%��8�8�8�8�8�')�w���u�z�'B�'B� ���)� �+�8����� $�}� ��G�$�$�R�W�_�_�\�%B�%B�C�C� ��0� � �I��w��� �*�*�i�7�7���8��#�$�&2�3��� � � !� 1� � "� "�<� 0� 0� 0��~�~�l�E�7�K�H�H��� �� � ���$�U�]�$��+�M��.�)����� � '��,�,�.�.� � � '� '� %�%�%�%�#'�<� �#;�#;�%�%�%� '� '� '�#� � � � � � � � � � � ���� � � � ��#'� ���� �G�L�L���#3� 4� 4� � ��E� � �"�6��K�K�U�K�K�K�K�K����-� �6�6��3�4G�H�H�#��&�&�2�G�G�� � �� � � � �+�� � ;� � "�4�)9� :� :� :� :��&�&�t�T�2�2�F�F���%� :� :� :��#�C�H�Q�K�0�0�c� 9����� :���� �>��4� � ��!5� ��#�#� �?�?�?�M�M�M�6�;�;�;� @��� � ��&�&�v�.�.�.�� sQ�"�A� A�A�/AC � C�C�+K�K�K�"N>�>O2� O-�-O2�rev_idrc ���t|�����}d�t�|pd�������}t |��|jkr,|d|j��dd��ddz}d|j ||||j |j |j |j |j|jd� zz}t j�||��S)N�_�rrz%s.py) r��slug�epoch�year�month�day�hour�minute�second)r|� timestamprT�_slug_re�findallr�rIr*�rsplitr)rCrDrErFrGrHr=rA)rCrAr=rrrBrArhs rDr0zScriptDirectory._rev_paths����K�)�)�+�+�,�,���x�x��(�(���B�7�7�8�8�>�>�@�@�� �t�9�9�t�0� 0� 0��3�$�3�3�4�;�;�C��C�C�A�F��L�D�� � ����#�(�$�*�"��#�(�%�,�%�,� � � �  ���w�|�|�D�(�+�+�+rF)r'r(r)r(r*r+r,r-r.r/r0r(r1r2r3r4r5r/r6rr7r8�r7r()r7rL)r7rV)rkrr7r$)NNNNN) r�r2r�r2r�r2r�r2r�r2r7r�)r�r�)r�r(r�r(r7rV)r�rr7r�)r�r�r7r�)r�r(r7r\)r�r2r7r�)r�r�r�r�r�rr7rV)r7r2)r7r�)r�r(r�r(r7r�)r�r(r�r2r7r�)rrr�rr7r�)r7r8)rr(r�r(r�rr7r8)rr(r�r(r7r8)rAr(r7r8)r7r)NFNNN)rr(rr2r�rrrrrr r2r!rr�rr7r") rAr(r=r(rr2rrr7r()'�__name__� __module__� __qualname__�__doc__r�rr� EMPTY_DICTrE�propertyrK�memoized_propertyrHr;� classmethodr�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr rrr<r0rOrFrDr$r$:s ��������,4�.0�15� �&�"&�37�,1�+/�4� ���, �, � � � � � �D�����X�� ��J�J�J���J�����:�R �R �R ��[�R �h�#'�(,�#�!�$(� +:�+:�+:�+:��^�+:�\/6�(�(�(�(�(�& � � � �N�N�N�N� E� E� E� E�����" � � � �48�8�8�8�0 -� -� -� -�����,-�-�-�-�����$����$\�\�\�\�| 2� 2� 2� 2��A�A�A��X�A�I�I�I�I� #�#�#�#� "�"�"�"�����@&*�!&�.2�&*�+/�Q�Q�Q�Q�Q�f,�,�,�,�,�,rFr$c���eZdZUdZd%�fd� Zded< ded< dZd ed < ed&d ���Zed&d ���Z ed&d���Z d&d�Z d'd(d�Z d)d*d�Z d&d�Zed+d���Zed,d!���Zed-d$���Z�xZS).r\z�Represent a single revision file in a ``versions/`` directory. The :class:`.Script` instance is returned by methods such as :meth:`.ScriptDirectory.iterate_revisions`. �modulerr=r(rAc ���||_||_t���||jt jt|dd��d���t jt|dd��d������dS)NrrO)�defaultr!)r� dependencies)rWrA�superrEr+rr��getattr)rCrWr=rA� __class__s �rDrEzScript.__init__7s������ ��� � ����� � � ��-�����6�6��������� �d�3�3�R���� � � � � � rFNr�_db_current_indicatorr7c�B�tjd|j��dS)�)Return the docstring given in the script.z r)r�r�longdocrUs rD�docz Script.docOs���x��� �-�-�a�0�0rFc��|jj}|rHt|jd��r|�|jj��}|���SdS)r`�_alembic_source_encodingr@)rWrQ�hasattr�decoderdrv)rCrbs rDrazScript.longdocUs[���k�!�� � ��t�{�$>�?�?� ��j�j��K�8�����9�9�;�;� ��2rFc�j�d|j�|jrdnd�|jrdnd�|jrdnd�|jrdnd�d�}|jr|d|����d�z }n|d |����d�z }|jr|d tj|j��zz }|jr|d tj|j ��zz }|j r |d tj|j ���d�z }|d |j �d�z }|dd� d�|j ���D����zz }|S)NzRev: � (head)r@� (branchpoint)� (mergepoint)� (current)rpzMerges: zParent: zAlso depends on: %s zBranches into: %s zBranch names: zPath: z %s c3� K�|] }d|zV�� dS)z %sNrO)rQ�paras rDr)z#Script.log_entry.<locals>.<genexpr>�s&����L�L�$�h��o�L�L�L�L�L�LrF)rr1�is_branch_point�is_merge_pointr^�_format_down_revisionrZrr��nextrevrrArTra� splitlines)rC�entrys rD� log_entryzScript.log_entrycs���� �M�M��� -�I�I�2� -� $� 4� <� � �"� <�#�2� :�O�O�� :� �6� >�L�L�B� >� >�  �� � � F� �E�t�'A�'A�'C�'C�'C�'C�E� E�E�E� �E�t�'A�'A�'C�'C�'C�'C�E� E�E� � � � �,��$�T�%6�7�7�� �E� � � � �*��$�T�\�2�2�� �E� � � � �E��$�T�%7�8�8�8�8�� �E� ������,�,�� �� �I�I�L�L�$�,�2I�2I�2K�2K�L�L�L� L� L� � ��� rFc��|����d|j�|jrdnd�|jrdnd�|jrdnd�d|j��S)N� -> rhr@rirjz, )rprr1rnrorbrUs rD�__str__zScript.__str__�si�� � &� &� (� (� (� (� �M�M��� -�I�I�2� -� $� 4� <� � �"� <�#�2� :�O�O�� :� :� �H�H�  � rFFT�include_branchesr/� include_doc�include_parents�tree_indicators�head_indicatorsc���|j}|rT|jr4|����dtj|j���d|��}n|����d|��}|�J�|r&|jr|dtj|j��zz }|s|r-||jrdnd�|jr |jsdnd�|jrdnd��z }|r||j rd nd�|j rd nd��z }|r |d |j zz }|S) Nz (z) -> rvz (%s)rhr@z (effective head)rkrirjz, %s) rrZrprr�r� _is_real_headr1r^rnrorb)rCrxryrzr{r|�texts rD� _head_onlyzScript._head_only�s���}�� � I�� � I��.�.�0�0�0�0��(��):�;�;�;�;��D���� &*�%?�%?�%A�%A�%A�%A�4�4�H������ � G�� 2� G� �G�d�2�4�3E�F�F�F� F�D� � �o� � �!�/�7� � �R�7��|��,0�,>��'�'���!%� :�B� � ��B�� �D� � � �$(�$8�@� � �b�@�#'�#6�>���B�>�� �D� � &� �F�T�X�%� %�D�� rF�verbosec�D�|r|jS|�||||��Sr�)rtr�)rCr�rxryrzr{s rD� cmd_formatzScript.cmd_format�s3�� � ��>� !��?�?� �+����� rFc�F�|jsdStj|j��S)Nz<base>)r+rr��_versioned_down_revisionsrUs rDrpzScript._format_down_revision�s'���!� H��8��'��(F�G�G� GrF� scriptdirr$r"c�t�tj�|��\}}|�|||��Sr�)r=rArrc)r�r�rA�dir_rhs rDr6zScript._from_path�s3������t�,�,���h��!�!�)�T�8�<�<�<rFr�c�H�� �g}tj|d���D�]\}}}|�d��r�t|��D]5}|�tj�||�����6|jrtj�|d��� tj�� ��r@d�|D���|� �� fd�tj � ��D����|j sn|� ����|S)NT)�topdown� __pycache__c�D�h|]}|�d��d��S)�.r)r)rQrhs rD� <setcomp>z&Script._list_py_dir.<locals>.<setcomp>�s)��J�J�J��X�^�^�C�0�0��3�J�J�JrFc3��K�|]A}|�d��d�v�tj��|��V��BdS)r�rN)rr=rArT)rQ�pyc�names� py_cache_paths ��rDr)z&Script._list_py_dir.<locals>.<genexpr>�sY�����!�!���9�9�S�>�>�!�,�E�9�9��� � �]�C�8�8�9�9�9�9�!�!rF) r=�walk�endswith�sortedr�rArTr.rYr��listdirr5�sort) r�r�rArd�root�dirs�filesrhr�r�s @@rDr]zScript._list_py_dir�s@������!#���t�!<�!<�!<� � � �D�$���}�}�]�+�+� ��"�5�M�M� ;� ;��� � �R�W�\�\�$��9�9�:�:�:�:��#� � "�� � �T�=� A� A� ��7�>�>�-�0�0� �K�J�E�J�J�J�E��L�L�!�!�!�!�!�#%�:�m�#<�#<�!�!�!���� �8� ��� �I�I�K�K�K�K�� rFr�rhc��|jrt�|��}nt�|��}|sdS|�d��}|jr3|�d��dk}|�d��dk}ndx}}|s|r�t j�t j�||����}t j�t j�||dz����} |s|r| rdStj ||��} t| d��sIt�|��} | stj d|z���| �d��} n| j} t| | t j�||����S)Nrr�c�oFrz�Could not determine revision id from filename %s. Be sure the 'revision' variable is declared inside the script (please see 'Upgrading from Alembic 0.1 to 0.2' in the documentation).)r.�_sourceless_rev_file�match�_only_source_rev_file�groupr=rArYrTrr�re� _legacy_revr@rr\) r�r�r�rh�py_match� py_filename�is_c�is_o� py_exists� pyc_existsrW�mrs rDrczScript._from_filename�s��� � � =�+�1�1�(�;�;�H�H�,�2�2�8�<�<�H�� ��4��n�n�Q�'�'� � � � ��>�>�!�$�$��+�D��>�>�!�$�$��+�D�D�� �D�4� � �4� �����r�w�|�|�D�+�'F�'F�G�G�I������� � �T�;��;L�(M�(M�N�N�J� � �D� �Z� ��t��&�t�X�6�6���v�z�*�*� '��!�!�(�+�+�A�� &��'�F�� �����7�7�1�:�:�����H��f�h��� � �T�8�(D�(D�E�E�ErF)rWrr=r(rAr(rM)FFFTT) rxr/ryr/rzr/r{r/r|r/r7r()FFFT) r�r/rxr/ryr/rzr/r{r/r7r()r�r$rAr(r7r")r�r$rAr(r7r�)r�r$r�r(rhr(r7r")rNrOrPrQrE�__annotations__r^rSrbrartrwr�r�rprUr6r]rc� __classcell__)r]s@rDr\r\/s�����������  �  �  �  �  �  �����B� �I�I�I�(�,0��0�0�0�0�4��1�1�1��X�1� � � � ��X� ��!�!�!��X�!�F � � � �"'�!� %� $� $� &�&�&�&�&�V"'�!� %� $� � � � � �H�H�H�H� �=�=�=��[�=� �"�"�"��[�"�H�/F�/F�/F��[�/F�/F�/F�/F�/FrFr\)8� __future__r� contextlibrrr=r�r r��typesr�typingrrrr r r r r rrrr@rrr�runtimerrrrrrrkrr�runtime.migrationrr �py39�zoneinfor!r"�backports.zoneinfo� ImportError�compiler�r�r�rJr�r~r�r$r\rOrFrD�<module>r�s���"�"�"�"�"�"�%�%�%�%�%�%����� � � � � � � � � � � � � � � � ������������������������������������������������������������� � � � � � ��������������������������������������������.�$�$�$�$�$�$�$�$�$�$�$�$�"�"�"�"�"�"�������)�)�)�)�)�)�0�0�0�0�0�0�-�-�-�-�-�-�� �{�=�%�%�%�%�%�%�2�2�2�2�2�2�2�/�/�/�/�/�/�<�<�<�<�<�<��������H�H�H�����"�r�z�"E�F�F��"�� �#@�A�A���b�j�,�-�-� � �2�:�f� � ��+��"�� �=�1�1��(�b�j�)9�:�:��r ,�r ,�r ,�r ,�r ,�r ,�r ,�r ,�j{F�{F�{F�{F�{F�X� �{F�{F�{F�{F�{Fs�: C�C%�$C%
Memory