� J�g�V��|�ddlmZddlmZddlmZddlmZddlZddlZddl Z ddl m Z ddl m Z ddl m Z dd l mZdd l mZdd l mZdd l mZdd l mZddl mZddlmZddlmZddlmZddlmZddlmZGd�d��ZGd�ded���ZGd�d��Z d'd(d%�Zed&kr e��dSdS))�)� annotations)�ArgumentParser)� Namespace)� ConfigParserN)�Any)�cast)�Dict)�Mapping)�Optional)�overload)�Sequence)�TextIO)�Union)� TypedDict�)� __version__)�command)�util)�compatc��eZdZUdZdddejdej��dfd8d�ZdZ d e d < dZ de d< dZ de d< ej d9d���Zd:d�Zej d;d���Zd<d�Ze d=d>d$���Zed?d&���Zed@d)���Z dAdBd+�ZdCd-�ZdDd.�ZdEd0�Z dAdFd2�ZedGd3���Ze dAdHd4���Z dAdHd5�Zej dId7���ZdS)J�Configa` Represent an Alembic configuration. Within an ``env.py`` script, this is available via the :attr:`.EnvironmentContext.config` attribute, which in turn is available at ``alembic.context``:: from alembic import context some_param = context.config.get_main_option("my option") When invoking Alembic programmatically, a new :class:`.Config` can be created by passing the name of an .ini file to the constructor:: from alembic.config import Config alembic_cfg = Config("/path/to/yourapp/alembic.ini") With a :class:`.Config` object, you can then run Alembic commands programmatically using the directives in :mod:`alembic.command`. The :class:`.Config` object can also be constructed without a filename. Values can be set programmatically, and new sections will be created as needed:: from alembic.config import Config alembic_cfg = Config() alembic_cfg.set_main_option("script_location", "myapp:migrations") alembic_cfg.set_main_option("sqlalchemy.url", "postgresql://foo/bar") alembic_cfg.set_section_option("mysection", "foo", "bar") .. warning:: When using programmatic configuration, make sure the ``env.py`` file in use is compatible with the target configuration; including that the call to Python ``logging.fileConfig()`` is omitted if the programmatic configuration doesn't actually include logging directives. For passing non-string values to environments, such as connections and engines, use the :attr:`.Config.attributes` dictionary:: with engine.begin() as connection: alembic_cfg.attributes['connection'] = connection command.upgrade(alembic_cfg, "head") :param file\_: name of the .ini file to open. :param ini_section: name of the main Alembic section within the .ini file :param output_buffer: optional file-like input buffer which will be passed to the :class:`.MigrationContext` - used to redirect the output of "offline generation" when using Alembic programmatically. :param stdout: buffer where the "print" output of commands will be sent. Defaults to ``sys.stdout``. :param config_args: A dictionary of keys and values that will be used for substitution in the alembic config file. The dictionary as given is **copied** to a new one, stored locally as the attribute ``.config_args``. When the :attr:`.Config.file_config` attribute is first invoked, the replacement variable ``here`` will be added to this dictionary before the dictionary is passed to ``ConfigParser()`` to parse the .ini file. :param attributes: optional dictionary of arbitrary Python keys/values, which will be populated into the :attr:`.Config.attributes` dictionary. .. seealso:: :ref:`connection_sharing` N�alembic�file_�"Union[str, os.PathLike[str], None]� ini_section�str� output_buffer�Optional[TextIO]�stdoutr�cmd_opts�Optional[Namespace]� config_args�Mapping[str, Any]� attributes�Optional[Dict[str, Any]]�return�Nonec��||_||_||_||_||_t |��|_|r|j�|��dSdS)z Construct a new :class:`.Config`N) �config_file_name�config_ini_sectionrrr �dictr"r$�update)�selfrrrrr r"r$s �^/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/alembic/config.py�__init__zConfig.__init__dsh��!&���"-���*����� � �� �� �,�,��� � /� �O� "� "�:� .� .� .� .� .� /� /�r)r*�Dict[str, Any]c��iS)a�A Python dictionary for storage of additional state. This is a utility dictionary which can include not just strings but engines, connections, schema objects, or anything else. Use this to pass objects into an env.py script, such as passing a :class:`sqlalchemy.engine.base.Connection` when calling commands from :mod:`alembic.command` programmatically. .. seealso:: :ref:`connection_sharing` :paramref:`.Config.attributes` ��r-s r.r$zConfig.attributes�s ��$� r0�text�argrc��|rt|��|z}nt|��}tj|j|dfi|j��dS)a�Render a message to standard out. When :meth:`.Config.print_stdout` is called with additional args those arguments will formatted against the provided text, otherwise we simply output the provided text verbatim. This is a no-op when the``quiet`` messaging option is enabled. e.g.:: >>> config.print_stdout('Some text %s', 'arg') Some Text arg � N)rr�write_outstreamr�messaging_opts)r-r5r6�outputs r.� print_stdoutzConfig.print_stdout�sP�� � ���Y�Y��_�F�F���Y�Y�F� ��T�[�&�$�N�N�$�:M�N�N�N�N�Nr0rc�R�|jrBtj�tj�|j����}nd}||jd<t |j��}|jrtj||jg��n|� |j ��|S)aReturn the underlying ``ConfigParser`` object. Direct access to the .ini file is available here, though the :meth:`.Config.get_section` and :meth:`.Config.get_main_option` methods provide a possibly simpler interface. ��here) r)�os�path�abspath�dirnamer"rr�read_config_parser� add_sectionr*)r-r?� file_configs r.rFzConfig.file_config�s��� � � ��7�?�?�2�7�?�?�4�3H�#I�#I�J�J�D�D��D�#'���� �"�4�#3�4�4� � � � =� � %�k�D�4I�3J� K� K� K� K� � #� #�D�$;� <� <� <��r0c���ddl}tj�tj�|j����}tj�|d��S)z�Return the directory where Alembic setup templates are found. This method is used by the alembic ``init`` and ``list_templates`` commands. rN� templates)rr@rArBrC�__file__�join)r-r� package_dirs r.�get_template_directoryzConfig.get_template_directory�sG�� �����g�o�o�b�g�o�o�g�6F�&G�&G�H�H� ��w�|�|�K��5�5�5r0.�name�default�Optional[Dict[str, str]]c��dS�Nr3�r-rMrNs r.� get_sectionzConfig.get_section�s ��$'�3r0�Dict[str, str]c��dSrQr3rRs r.rSzConfig.get_section�s ���r0�Mapping[str, str]�(Union[Dict[str, str], Mapping[str, str]]c��dSrQr3rRs r.rSzConfig.get_section�s ��47�3r0�Optional[Mapping[str, str]]c��|j�|��s|St|j�|����S)z�Return all the configuration options from a given .ini file section as a dictionary. If the given section does not exist, the value of ``default`` is returned, which is expected to be a dictionary or other mapping. )rF� has_sectionr+�itemsrRs r.rSzConfig.get_section�sA����+�+�D�1�1� ��N��D�$�*�*�4�0�0�1�1�1r0�valuec�>�|�|j||��dS)a:Set an option programmatically within the 'main' section. This overrides whatever was in the .ini file. :param name: name of the value :param value: the value. Note that this value is passed to ``ConfigParser.set``, which supports variable interpolation using pyformat (e.g. ``%(some_value)s``). A raw percent sign not part of an interpolation symbol must therefore be escaped, e.g. ``%%``. The given value may refer to another value already in the file using the interpolation format. N)�set_section_optionr*)r-rMr]s r.�set_main_optionzConfig.set_main_option�s%�� ���� 7��u�E�E�E�E�Er0c�F�|j�|j|��dSrQ)rF� remove_optionr*)r-rMs r.�remove_main_optionzConfig.remove_main_options$�� ��&�&�t�'>��E�E�E�E�Er0�sectionc��|j�|��s|j�|��|j�|||��dS)a�Set an option programmatically within the given section. The section is created if it doesn't exist already. The value here will override whatever was in the .ini file. :param section: name of the section :param name: name of the value :param value: the value. Note that this value is passed to ``ConfigParser.set``, which supports variable interpolation using pyformat (e.g. ``%(some_value)s``). A raw percent sign not part of an interpolation symbol must therefore be escaped, e.g. ``%%``. The given value may refer to another value already in the file using the interpolation format. N)rFr[rE�set)r-rdrMr]s r.r_zConfig.set_section_optionsU��(��+�+�G�4�4� 2� � � (� (�� 1� 1� 1� ����W�d�E�2�2�2�2�2r0� Optional[str]c���|j�|��s tjd|j�d|�d����|j�||��r|j�||��S|S)z9Return an option from the given section of the .ini file.zNo config file z found, or file has no '[z ]' section)rFr[r� CommandErrorr)� has_option�get)r-rdrMrNs r.�get_section_optionzConfig.get_section_option*s�����+�+�G�4�4� ��#�#�$(�$9�$9�$9�7�7�7�D��� � � � &� &�w�� 5� 5� ��#�'�'���6�6� 6��Nr0c��dSrQr3rRs r.�get_main_optionzConfig.get_main_option8s��?B�sr0c��dSrQr3rRs r.rnzConfig.get_main_option;s ���r0c�:�|�|j||��S)z�Return an option from the 'main' section of the .ini file. This defaults to being a key from the ``[alembic]`` section, unless the ``-n/--name`` flag were used to indicate a different section. )rlr*rRs r.rnzConfig.get_main_option@s���&�&�t�'>��g�N�N�Nr0�MessagingOptionsc �|�tttjdt |jdd��i����S)zThe messaging options.�quietF)rrqr� immutabledict�getattrr r4s r.r:zConfig.messaging_optsLs?��� � � ��'�$�-��%�@�@�A� � � � � r0)rrrrrrrrr r!r"r#r$r%r&r')r&r1)r5rr6rr&r')r&r)r&r).)rMrrNr'r&rO)rMrrNrTr&rT)rMrrNrVr&rWrQ)rMrrNrYr&rY)rMrr]rr&r')rMrr&r')rdrrMrr]rr&r')rdrrMrrNrgr&rg)rMrrNrr&r)rMrrNrgr&rg)r&rq)�__name__� __module__� __qualname__�__doc__�sysrrrtr/r �__annotations__r)r*�memoized_propertyr$r<rFrLr rSr`rcr_rlrnr:r3r0r.rrs��������F�F�T59�$�*.���(,�);��);�)=�)=�/3�/�/�/�/�/�(%)�H�(�(�(�(� �<@��?�?�?�?�2�"��"�"�"�"�� ��������&O�O�O�O�. ��������, 6� 6� 6� 6��),�'�'�'�'��X�'������X���7�7�7��X�7� AE� 2� 2� 2� 2� 2�F�F�F�F�"F�F�F�F�3�3�3�3�2AE� � � � � ��B�B�B��X�B� �26������X�� 37� O� O� O� O� O� �� � � ��� � � r0rc��eZdZUded<dS)rq�boolrsN)rvrwrxr{r3r0r.rqrqWs��������K�K�K�K�Kr0rqF)�totalc�2�eZdZddd�Zdd�Zdd �Zddd�ZdS)� CommandLineN�progrgr&r'c�0�|�|��dSrQ)�_generate_args)r-r�s r.r/zCommandLine.__init__\s�� ���D�!�!�!�!�!r0c �L� � � �d/� � fd� }t|� ��}|�d d d tz� ��|�ddttj�dd��d���|�ddtdd���|�ddd���|�ddd���|�dd dd!���|���}tj d"d#ii� d$�tt��D��D�]y� tj � ���ra� j d%d&k�rO� jd'k�rCtj� ��}|d(�I|d%d)t#|d(�� �}|d%t#|d(�� d�}n|d%d)d�}g}� � vr� � fd*�|D��}� j}|rXg} |�d+��D]?} | ���sn(| �| ������@ng} |�� j d,�| ���-��� |� � ||��� �� ||f�.����{||_dS)0N�fnr�parser� positional�kwargsr&r'c �`��idddtdtd���f�ddd ttd � ��f�d d tdd���f�ddttd� ��f�ddttd� ��f�ddtdd���f�ddtdd���f�ddttd � ��f�d!d"ttd#� ��f�d$d%ttd&� ��f�d'd(d)tdd*���f�d+d,tdd-���f�d.d/tdd0���f�d1d2d3td4d5���f�d6d7d8tdd9���f�d:d;tdd<���f�d=d>tdd?���f�}d@dAdBdC�}|D]-}||vr'||}|dDdE�|dE}}|j|i|���.|D]t}|dFks|� vr>� ||dFkr,� �dFdG|�dF���H���J� �||�|���I���udS)JN�templatez-tz --template�genericz"Setup template for use with 'init')rN�type�help�messagez-mz --messagez%Message string to use with 'revision')r�r��sqlz--sql� store_truez\Don't emit SQL to database - dump to standard output/file instead. See docs on offline mode.��actionr��tagz--tagz<Arbitrary 'tag' name - can be used by custom env.py scripts.�headz--headzCSpecify head revision or <branchname>@head to base new revision on.�splicez--splicez6Allow a non-head revision as the 'head' to splice onto� depends_onz --depends-on�appendzNSpecify one or more revision identifiers which this revision should depend on.�rev_idz--rev-idz9Specify a hardcoded revision id instead of generating one� version_pathz--version-pathz2Specify specific path from config for version file� branch_labelz--branch-labelz3Specify a branch label to apply to the new revision�verbosez-vz --verbosezUse more verbose output�resolve_dependenciesz--resolve-dependenciesz+Treat dependency versions as down revisions� autogeneratez--autogeneratezgPopulate revision script with candidate migration operations, based on comparison of database to model.� rev_rangez-rz --rev-range�storez1Specify a revision range; format is [start]:[end]�indicate_currentz-iz--indicate-currentzIndicate the current revision�purgez--purgez7Unconditionally erase the version table before stamping�packagez --packagezFWrite empty __init__.py files to the environment and version locationszlocation of scripts directoryzrevision identifierz/one or more revisions, or 'heads' for all heads)� directory�revision� revisionsr�����r��+)�nargsr��r�)r+r� add_argumentrk) r�r�r�r�� kwargs_opts�positional_helpr6�args�kw�positional_translations� subparsers ��r.� add_optionsz/CommandLine._generate_args.<locals>.add_options`s<���H��� �� )� �A�����H����� �'N�����H�"���+�(�����#H�4��� �1�����5H�D��� �3�����EH�T���+�0�����UH�d�"��'�@�����eH�t��� �)�����uH�D�$�� �'����!�EH�T�$�� �'����!�UH�d���� �3L�M�M�M��eH�n'�,��+�J����)�oH�|�$��+�0����!�}H�N��!��&�2�����OH�`#��(��+�<����%�aH�p���+�*�����qH�@���+�<�����AH�K�T=�1�N���O� � 5� 5���+�%�%�&�s�+�D�#�A�b�D�z�4��8�"�D�'�F�'��4��4�4�4��!� O� O���;�&�&��4�4�4�/��3�C�8�K�G�G��*�*�#�!�,�0�0��=�=�+����� �*�*�3�_�5H�5H��5M�5M�*�N�N�N�N� O� Or0�r�z --version�versionz %%(prog)s %s)r�r�z-cz--config�ALEMBIC_CONFIGz alembic.inizaAlternate config file; defaults to value of ALEMBIC_CONFIG environment variable, or "alembic.ini")r�rNr�z-nz--namerz6Name of section in .ini file to use for Alembic configz-xr�zlAdditional arguments consumed by custom env.py scripts, e.g. -x setting1=somesetting -x setting2=somesettingr�z --raiseerrr�z!Raise a full stack trace on errorz-qz--quietzDo not log to std output.r�r�c�8�g|]}tt|����Sr3)rur)�.0�ns r.� <listcomp>z.CommandLine._generate_args.<locals>.<listcomp>1s"��=�=�=�1�7�7�A�&�&�=�=�=r0r�_zalembic.command�rc�H��g|]}���||����Sr3)rk)r�rMr�r�s ��r.r�z.CommandLine._generate_args.<locals>.<listcomp>@s>���"�"�"� �0��3�7�7��d�C�C�"�"�"r0r8� r�)�cmd) r�rr�rr�rr�rr&r')rr�rrr@�environrk�add_subparsersr�stamp�dir�inspect� isfunctionrvrwr�inspect_getfullargspec�lenry�split�stripr�� add_parserrJ� set_defaultsr�)r-r�r�r�� subparsers�specr��kwarg�help_� help_text�liner�r�r�s @@@r.r�zCommandLine._generate_args_sd�����c O�c O�c O�c O�c O�c O�c O�J �T�*�*�*����� � �>�K�3O� � � � � ��� � ���J�N�N�#3�]�C�C�D� � � � � ��� � ���L� � � � � ��� ��;� � � � � ��� ��4� � � � � ��� � ��,� � � � � �*�*�,�,� � �M�J� �4�3 ��>�=��G� � �=�=�=�# D�# D�B��"�2�&�&�" D��K��N�c�)�)��M�%6�6�6��4�R�8�8����7�&�!%�a���c�$�q�'�l�l�]�):�!;�J� ��G�S��a��\�\�M�O�O�4�E�E�!%�a������J��E��0�0�0�"�"�"�"�"�$.�"�"�"�J� � ���#� "�I� %� � �D� 1� 1�;�;��#�z�z�|�|�;�!�E�%�,�,�T�Z�Z�\�\�:�:�:�:�� "�I�&�1�1��K�c�h�h�y�&9�&9�2��� �� �B� �:�u�=�=�=��&�&�B� �E�+B�&�C�C�C���� � � r0�configr�optionsrc�����j\}}} ||g�fd�|D���Ri�fd�|D����dS#tj$r7}�jr�tjt |��fi|j��Yd}~dSd}~wwxYw)Nc�2��g|]}t�|d����SrQ�ru�r��kr�s �r.r�z'CommandLine.run_cmd.<locals>.<listcomp>]s%���@�@�@��'�'�1�d�+�+�@�@�@r0c�4��i|]}|t�|d����SrQr�r�s �r.� <dictcomp>z'CommandLine.run_cmd.<locals>.<dictcomp>^s'���?�?�?�A�1�g�g�q�$�/�/�?�?�?r0)r�rri�raiseerr�errrr:)r-r�r�r�r�r��es ` r.�run_cmdzCommandLine.run_cmdWs���� '� ���J�� :� �B�� �@�@�@�@�Z�@�@�@� � � �@�?�?�?��?�?�?� � � � � �� � � :� :� :��� :�����Q���9�9�6�#8�9�9�9�9�9�9�9�9�9�����  :���s�$4�A:�,A5�5A:�argv�Optional[Sequence[str]]c���|j�|��}t|d��s|j�d��dSt |j|j|���}|�||��dS)Nr�ztoo few arguments)rrr )r�� parse_args�hasattr�errorrr�rMr�)r-r�r��cfgs r.�mainzCommandLine.mainfs����+�(�(��.�.���w��&�&� '� �K� � �1� 2� 2� 2� 2� 2���n�#�L� ����C� �L�L��g� &� &� &� &� &r0rQ)r�rgr&r')r�rr�rr&r')r�r�r&r')rvrwrxr/r�r�r�r3r0r.r�r�[ss������"�"�"�"�"�v�v�v�v�p :� :� :� :� '� '� '� '� '� '� 'r0r�r�r�r�rgr�rr&r'c �N�t|����|���dS)z(The console runner function for Alembic.r�)r�N)r�r�)r�r�r�s r.r�r�us,���T������T��*�*�*�*�*r0�__main__)NN)r�r�r�rgr�rr&r') � __future__r�argparserr� configparserrr�r@rz�typingrrr r r r r rr�typing_extensionsrr>rrrrrrqr�r�rvr3r0r.�<module>r�s<��"�"�"�"�"�"�#�#�#�#�#�#�������%�%�%�%�%�%����� � � � � � � � �������������������������������������������������������'�'�'�'�'�'�������������������������y �y �y �y �y �y �y �y �x �����y������W'�W'�W'�W'�W'�W'�W'�W'�v%)��+�+�+�+�+� �z����D�F�F�F�F�F��r0
Memory