HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/alembic/__pycache__/config.cpython-310.pyc
o

+we�U�@s4ddlmZddlmZddlmZddlmZddlZddlZddl	Z	ddl
mZddl
mZddl
m
Z
dd	l
mZdd
l
mZddl
mZddl
mZdd
l
mZddlmZddlmZddlmZddlmZddlmZGdd�d�ZGdd�dedd�ZGdd�d�Zddd�Zedkr�e�dSdS) �)�annotations)�ArgumentParser)�	Namespace)�ConfigParserN)�Any)�cast)�Dict)�Mapping)�Optional)�overload)�TextIO)�Union)�	TypedDict�)�__version__)�command)�util)�compatc@s.eZdZUdZdddejde��dfd@dd�ZdZ	d
e
d<	dZde
d<	dZde
d<	ej
dd��ZdAdd�Zej
dd��ZdBdd �Ze	!dCdDd%d&��ZedEd(d&��ZedFd+d&��Z	dGdHd-d&�ZdId/d0�ZdJd1d2�ZdKd4d5�Z	dGdLd7d8�ZedMd9d:��Ze	dGdNd;d:��ZdGd<d:�Zej
dOd>d?��ZdS)P�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]�return�NonecCs@||_||_||_||_||_t|�|_|r|j�|�dSdS)z Construct a new :class:`.Config`N)	�config_file_name�config_ini_sectionrrr�dictrr!�update)�selfrrrrrrr!�r*�G/home/arjun/projects/env/lib/python3.10/site-packages/alembic/config.py�__init__cs
�zConfig.__init__r%r&cCsiS)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*�r)r*r*r+r!�szConfig.attributes�textcGs8|r	t|�|}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)r.�arg�outputr*r*r+�print_stdout�szConfig.print_stdoutcCs`|jrtj�tj�|j��}nd}||jd<t|j�}|jr(t�||jg�|S|�	|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�dirnamerrr�read_config_parser�add_sectionr&)r)r6�file_configr*r*r+r=�s

�zConfig.file_configcCs,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)rr7r8r9r:�__file__�join)r)r�package_dirr*r*r+�get_template_directory�szConfig.get_template_directory.�name�default�Optional[Dict[str, str]]cC�dS�Nr*�r)rCrDr*r*r+�get_section��zConfig.get_section�Dict[str, str]cCrFrGr*rHr*r*r+rI�rJ�Mapping[str, str]�(Union[Dict[str, str], Mapping[str, str]]cCrFrGr*rHr*r*r+rI�rJ�Optional[Mapping[str, str]]cCs |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.

        )r=�has_sectionr'�itemsrHr*r*r+rI�s
�valuecCs|�|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)rCrQr*r*r+�set_main_optionszConfig.set_main_optioncCs|j�|j|�dSrG)r=�
remove_optionr&)r)rCr*r*r+�remove_main_optionszConfig.remove_main_option�sectioncCs,|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)r=rOr<�set)r)rVrCrQr*r*r+rRszConfig.set_section_option�
Optional[str]cCs@|j�|�st�d|j|f��|j�||�r|j�||�S|S)z9Return an option from the given section of the .ini file.z6No config file %r found, or file has no '[%s]' section)r=rOr�CommandErrorr%�
has_option�get)r)rVrCrDr*r*r+�get_section_option,s��zConfig.get_section_optioncCrFrGr*rHr*r*r+�get_main_option:szConfig.get_main_optioncCrFrGr*rHr*r*r+r]>rJcCs|�|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.

        )r\r&rHr*r*r+r]Ds�MessagingOptionsc	Csttt�dt|jdd�i��S)zThe messaging options.�quietF)rr^r�
immutabledict�getattrrr-r*r*r+r1Ns��zConfig.messaging_opts)rrrrrrrrrrrr r!r"r#r$)r.rr#r$)r#r).)rCrrDr$r#rE)rCrrDrKr#rK)rCrrDrLr#rMrG)rCrrDrNr#rN)rCrrQrr#r$)rCrr#r$)rVrrCrrQrr#r$)rVrrCrrDrXr#rX)rCrrDrr#r)rCrrDrXr#rX)r#r^)�__name__�
__module__�__qualname__�__doc__�sysrrr`r,r�__annotations__r%r&�memoized_propertyr!r4r=rBrrIrSrUrRr\r]r1r*r*r*r+rsX
J�



��


��

rc@seZdZUded<dS)r^�boolr_N)rbrcrdrgr*r*r*r+r^Ys
r^F)�totalc@s6eZdZdddd�Zddd	�Zddd�Zddd�ZdS)�CommandLineN�progrXr#r$cCs|�|�dSrG)�_generate_args)r)rlr*r*r+r,^szCommandLine.__init__cs���fdd�}t|d�}|jdddtd�|jdd	ttj�d
d�dd
�|jddtddd
�|jdddd�|jdddd�|jddddd�|��}tj	ddii�dd�t
t�D�D]��t���r�j
d d!kr�jd"kr�t���}|d#dur�|d d$t|d#��}|d t|d#�d�}n
|d d$d�}g}��vr���fd%d�|D�}�j}|r�g}	|�d&�D]}
|
��s�n|	�|
���q�ng}	|j�j
d'�|	�d(��|��||��j�||fd)�q\||_dS)*Nc		s�idddtdtdd�f�ddd	ttd
d�f�dd
tddd�f�ddttdd�f�ddttdd�f�ddtddd�f�ddtddd�f�ddttd d�f�d!d"ttd#d�f�d$d%ttd&d�f�d'd(d)tdd*d�f�d+d,tdd-d�f�d.d/tdd0d�f�d1d2d3td4d5d�f�d6d7d8tdd9d�f�d:d;tdd<d�f�d=d>tdd?d�f�}d@dAdBdC�}|D]}||vr�||}|dDdE�|dE}}|j|i|��q�|D](}|dFks�|�vr�||dFkr�jdFdG|�dF�dH�qɈj||�|�dI�q�dS)JN�templatez-tz
--template�genericz"Setup template for use with 'init')rD�type�help�messagez-mz	--messagez%Message string to use with 'revision')rprq�sqlz--sql�
store_truez\Don't emit SQL to database - dump to standard output/file instead. See docs on offline mode.��actionrq�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��+)�nargsrq�rq)r'r�add_argumentr[)	�fn�parser�
positional�kwargs�kwargs_opts�positional_helpr2�args�kw)�positional_translations�	subparserr*r+�add_optionsbsF���
���������"���*���2���:���B���J���R
��W���^���g���p���x�����������z/CommandLine._generate_args.<locals>.add_options�rlz	--version�versionz%%(prog)s %s)rvr�z-cz--config�ALEMBIC_CONFIGzalembic.inizaAlternate config file; defaults to value of ALEMBIC_CONFIG environment variable, or "alembic.ini")rprDrqz-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=somesettingruz
--raiseerrrtz!Raise a full stack trace on errorz-qz--quietzDo not log to std output.r�r�cSsg|]}tt|��qSr*)rar)�.0�nr*r*r+�
<listcomp>/sz.CommandLine._generate_args.<locals>.<listcomp>r�_zalembic.command�rcsg|]
}���||��qSr*)r[)r�rC)r�r�r*r+r�>s��r/� r�)�cmd)rr�rrr7�environr[�add_subparsersr�stamp�dir�inspect�
isfunctionrbrcr�inspect_getfullargspec�lenre�split�stripr{�
add_parserr@�set_defaultsr�)r)rlr�r��
subparsers�specr��kwarg�help_�	help_text�liner*)r�r�r�r+rmas�
$
�������

����
zCommandLine._generate_args�configr�optionsrc
s��j\}}}z||g�fdd�|D��Ri�fdd�|D���WdStjyF}z�jr/�tjt|�fi|j��WYd}~dSd}~ww)Ncsg|]}t�|d��qSrG�ra�r��k�r�r*r+r�[sz'CommandLine.run_cmd.<locals>.<listcomp>csi|]	}|t�|d��qSrGr�r�r�r*r+�
<dictcomp>\sz'CommandLine.run_cmd.<locals>.<dictcomp>)r�rrY�raiseerr�errrr1)r)r�r�r�r�r��er*r�r+�run_cmdUs���&��zCommandLine.run_cmdcCsH|j�|�}t|d�s|j�d�dSt|j|j|d�}|�||�dS)Nr�ztoo few arguments)rrr)r��
parse_args�hasattr�errorrr�rCr�)r)�argvr��cfgr*r*r+�mainds
�zCommandLine.mainrG)rlrXr#r$)r�rr�rr#r$)rbrcrdr,rmr�r�r*r*r*r+rk]s

urkcKst|d�j|d�dS)z(The console runner function for Alembic.r�)r�N)rkr�)r�rlr�r*r*r+r�ssr��__main__)NN)�
__future__r�argparserr�configparserrr�r7rf�typingrrrr	r
rrr
�typing_extensionsrr5rrrrrr^rkr�rbr*r*r*r+�<module>s>A

�