
    iV                    |   d dl mZ d dlmZ d dlmZ d dlmZ d dlZd dlZd dl	Z	d dl
mZ d dl
mZ d dl
mZ d d	l
mZ d d
l
mZ d dl
mZ d dl
mZ d dl
mZ d dl
mZ d dlmZ ddlmZ ddlmZ ddlmZ ddlmZ  G d d          Z G d ded          Z G d d          Z	 	 d'd(d%Zed&k    r e             dS dS ))    )annotations)ArgumentParser)	Namespace)ConfigParserN)Any)cast)Dict)Mapping)Optional)overload)Sequence)TextIO)Union)	TypedDict   )__version__)command)util)compatc                     e Zd ZU dZdddej        d ej                    dfd8dZdZ	de
d<   	 dZde
d<   	 dZde
d<   	 ej        d9d            Zd:dZej        d;d            Zd<dZe	 d=d>d$            Zed?d&            Zed@d)            Z	 dAdBd+ZdCd-ZdDd.ZdEd0Z	 dAdFd2ZedGd3            Ze	 dAdHd4            Z	 dAdHd5Zej        dId7            ZdS )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                            |           dS dS )z Construct a new :class:`.Config`N)	config_file_nameconfig_ini_sectionr   r   r    dictr"   r$   update)selfr   r   r   r   r    r"   r$   s           T/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/alembic/config.py__init__zConfig.__init__d   sh     !&"-* ,, 	/O"":.....	/ 	/    r)   r*   Dict[str, Any]c                    i S )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$   zConfig.attributes   s	    $ 	r0   textargr   c                    |rt          |          |z  }nt          |          }t          j        | j        |dfi | j         dS )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)r   r   write_outstreamr   messaging_opts)r-   r5   r6   outputs       r.   print_stdoutzConfig.print_stdout   sP       	YY_FFYYFT[&$NN$:MNNNNNr0   r   c                R   | j         rBt          j                            t          j                            | j                             }nd}|| j        d<   t          | j                  }| j         rt          j        || j         g           n|	                    | j
                   |S )a  Return 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"   r   r   read_config_parseradd_sectionr*   )r-   r?   file_configs      r.   rF   zConfig.file_config   s       	7??27??43H#I#IJJDDD#' "4#344  	=%kD4I3JKKKK##D$;<<<r0   c                    ddl }t          j                            t          j                            |j                            }t          j                            |d          S )zReturn the directory where Alembic setup templates are found.

        This method is used by the alembic ``init`` and ``list_templates``
        commands.

        r   N	templates)r   r@   rA   rB   rC   __file__join)r-   r   package_dirs      r.   get_template_directoryzConfig.get_template_directory   sG     	goobgoog6F&G&GHHw||K555r0   .namedefaultOptional[Dict[str, str]]c                    d S Nr3   r-   rM   rN   s      r.   get_sectionzConfig.get_section   	     	r0   Dict[str, str]c                    d S rQ   r3   rR   s      r.   rS   zConfig.get_section   rT   r0   Mapping[str, str](Union[Dict[str, str], Mapping[str, str]]c                    d S rQ   r3   rR   s      r.   rS   zConfig.get_section   rT   r0   Optional[Mapping[str, str]]c                    | j                             |          s|S t          | j                             |                    S )zReturn 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+   itemsrR   s      r.   rS   zConfig.get_section   sA     ++D11 	ND$**400111r0   valuec                >    |                      | j        ||           dS )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-   rM   r^   s      r.   set_main_optionzConfig.set_main_option  s%     	 7uEEEEEr0   c                F    | j                             | j        |           d S rQ   )rF   remove_optionr*   )r-   rM   s     r.   remove_main_optionzConfig.remove_main_option  s$    &&t'>EEEEEr0   sectionc                    | j                             |          s| j                             |           | j                             |||           dS )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)rF   r\   rE   set)r-   re   rM   r^   s       r.   r`   zConfig.set_section_option  sU    ( ++G44 	2((111WdE22222r0   Optional[str]c                    | j                             |          s t          j        d| j        d|d          | j                             ||          r| j                             ||          S |S )z9Return an option from the given section of the .ini file.zNo config file z found, or file has no '[z
]' section)rF   r\   r   CommandErrorr)   
has_optionget)r-   re   rM   rN   s       r.   get_section_optionzConfig.get_section_option-  s     ++G44 	##$($9$9$9777D   &&w55 	#''666Nr0   c                    d S rQ   r3   rR   s      r.   get_main_optionzConfig.get_main_option;  s    r0   c                    d S rQ   r3   rR   s      r.   ro   zConfig.get_main_option?  rT   r0   c                :    |                      | j        ||          S )zReturn 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.

        )rm   r*   rR   s      r.   ro   zConfig.get_main_optionE  s     &&t'>gNNNr0   MessagingOptionsc                |    t          t          t          j        dt	          | j        dd          i                    S )zThe messaging options.quietF)r   rr   r   immutabledictgetattrr    r4   s    r.   r:   zConfig.messaging_optsQ  s?     '$-%@@A 
 
 	
r0   )r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   )r&   r1   )r5   r   r6   r   r&   r'   )r&   r   )r&   r   ).)rM   r   rN   r'   r&   rO   )rM   r   rN   rU   r&   rU   )rM   r   rN   rW   r&   rX   rQ   )rM   r   rN   rZ   r&   rZ   )rM   r   r^   r   r&   r'   )rM   r   r&   r'   )re   r   rM   r   r^   r   r&   r'   )re   r   rM   r   rN   rh   r&   rh   )rM   r   rN   r   r&   r   )rM   r   rN   rh   r&   rh   )r&   rr   )__name__
__module____qualname____doc__sysr   r   ru   r/   r    __annotations__r)   r*   memoized_propertyr$   r<   rF   rL   r   rS   ra   rd   r`   rm   ro   r:   r3   r0   r.   r   r      s        F FT 59$*.(,););)=)=/3/ / / / /( %)H((((	 <@????2""""" 
   &O O O O. 
   ,
6 
6 
6 
6 ),    X    X
    X AE2 2 2 2 2F F F F"F F F F3 3 3 32 AE        X 26    X 37
O 
O 
O 
O 
O 

 
 
 
 
 
r0   r   c                      e Zd ZU ded<   dS )rr   boolrt   N)rw   rx   ry   r|   r3   r0   r.   rr   rr   \  s         KKKKKr0   rr   F)totalc                  2    e Zd ZdddZddZddZdddZdS )CommandLineNprogrh   r&   r'   c                0    |                      |           d S rQ   )_generate_args)r-   r   s     r.   r/   zCommandLine.__init__a  s    D!!!!!r0   c           	     L   d/fd}t          |	          }|                    d
ddt          z             |                    ddt          t          j                            dd          d           |                    ddt          dd           |                    ddd           |                    ddd           |                    dd dd!           |                                }t          j	        d"d#iid$ t          t                    D             D ]yt          j                  raj        d%         d&k    rOj        d'k    rCt          j                  }|d(         I|d%         d)t#          |d(                             }|d%         t#          |d(                    d          }n|d%         d)d          }g }v rfd*|D             }j        }|rXg }	|                    d+          D ]?}
|
                                s n(|	                    |
                                           @ng }	|                    j        d,                    |	          -           |||                               ||f.           {|| _        d S )0Nfnr   parser
positionalkwargsr&   r'   c           	     `   i dddt          dt          d          fddd	t          t          d
          fddt          dd          fddt          t          d          fddt          t          d          fddt          dd          fddt          dd          fddt          t          d           fd!d"t          t          d#          fd$d%t          t          d&          fd'd(d)t          dd*          fd+d,t          dd-          fd.d/t          dd0          fd1d2d3t          d4d5          fd6d7d8t          dd9          fd:d;t          dd<          fd=d>t          dd?          f}d@dAdBdC}|D ]-}||v r'||         }|dDdE         |dE         }} |j        |i | .|D ]t}|dFk    s| 	v r>	|          |         dFk    r,
                    dFdG|                    dF          H           J
                    ||                    |          I           ud S )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	--verbosezUse 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-currentzIndicate the current revisionpurgez--purgez7Unconditionally erase the version table before stampingpackagez	--packagezFWrite empty __init__.py files to the environment and version locationszlocation of scripts directoryzrevision identifierz/one or more revisions, or 'heads' for all heads)	directoryrevision	revisionsr   r   +)nargsr   r   )r+   r   add_argumentrl   )r   r   r   r   kwargs_optspositional_helpr6   argskwpositional_translations	subparsers            r.   add_optionsz/CommandLine._generate_args.<locals>.add_optionse  s<   H  ) A  H  'N  H" +(  #H4  1  5HD  3  EHT +0  UHd "'@  eHt  )  uHD $ '  !EHT $ '  !UHd 3LMMMeHn ',+J  )oH| $+0  !}HN !&2  OH` #(+<  %aHp +*  qH@ +<  AHKT =1N O
  5 5+%%&s+D#AbDz48"D'F'4444! O O;&&444/3C8KGG**#!,00== +     **3_5H5H5M5M*NNNNO Or0   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   rN   r   z-nz--namer   z6Name 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--quietzDo not log to std output.r   r   c                8    g | ]}t          t          |          S r3   )rv   r   ).0ns     r.   
<listcomp>z.CommandLine._generate_args.<locals>.<listcomp>6  s"    ===177A&&===r0   r   _zalembic.command   r   c                H    g | ]}                              ||          S r3   )rl   )r   rM   r   r   s     r.   r   z.CommandLine._generate_args.<locals>.<listcomp>E  s>     " " "  0377dCC" " "r0   r8    r   )cmd)
r   r   r   r   r   r   r   r   r&   r'   )r   r   r   r   r@   environrl   add_subparsersr   stampdirinspect
isfunctionrw   rx   r   inspect_getfullargspeclenrz   splitstripr   
add_parserrJ   set_defaultsr   )r-   r   r   r   
subparsersspecr   kwarghelp_	help_textliner   r   r   s              @@@r.   r   zCommandLine._generate_argsd  sd   c	O c	O c	O c	O c	O c	O c	OJ  T***	>K3O 	 	
 	
 	
 	JNN#3]CCD 	 	
 	
 	
 	L 	 	
 	
 	
 	; 	 	
 	
 	
 	4 	 	
 	
 	

 	,	 	 	
 	
 	
 **,,
 MJ43
 >=G=== #	D #	DB"2&&"DKNc))M%6664R887&!%ac$q'll]):!;J GSa\\MOO4EE!%aJE000" " " " "$." " "J 
 # "I %D 1 1 ; ;#zz|| ;!E%,,TZZ\\:::: "I&11Kchhy&9&9 2  	 B	:u===&&B
E+B&CCCr0   configr   optionsr   c                    j         \  }}}	  ||gfd|D             R i fd|D              d S # t          j        $ r7}j        r t          j        t          |          fi |j         Y d }~d S d }~ww xY w)Nc                2    g | ]}t          |d           S rQ   rv   r   kr   s     r.   r   z'CommandLine.run_cmd.<locals>.<listcomp>b  s%    @@@''1d++@@@r0   c                4    i | ]}|t          |d           S rQ   r   r   s     r.   
<dictcomp>z'CommandLine.run_cmd.<locals>.<dictcomp>c  s'    ???A1ggq$//???r0   )r   r   rj   raiseerrerrr   r:   )r-   r   r   r   r   r   es     `    r.   run_cmdzCommandLine.run_cmd\  s     'J
	:B@@@@Z@@@   @??????    
   	: 	: 	: :Q996#8999999999		:s   $4 A:,A55A:argvOptional[Sequence[str]]c                    | j                             |          }t          |d          s| j                             d           d S t	          |j        |j        |          }|                     ||           d S )Nr   ztoo few arguments)r   r   r    )r   
parse_argshasattrerrorr   r   rM   r   )r-   r   r   cfgs       r.   mainzCommandLine.maink  s    +((..w&& 
	' K122222n#L   C
 LLg&&&&&r0   rQ   )r   rh   r&   r'   )r   r   r   r   r&   r'   )r   r   r&   r'   )rw   rx   ry   r/   r   r   r   r3   r0   r.   r   r   `  ss        " " " " "v v v vp: : : :' ' ' ' ' ' 'r0   r   r   r   r   rh   r   r   r&   r'   c                N    t          |                              |            dS )z(The console runner function for Alembic.r   )r   N)r   r   )r   r   r   s      r.   r   r   z  s,     TT*****r0   __main__)NN)r   r   r   rh   r   r   r&   r'   ) 
__future__r   argparser   r   configparserr   r   r@   r{   typingr   r   r	   r
   r   r   r   r   r   typing_extensionsr   r>   r   r   r   r   r   rr   r   r   rw   r3   r0   r.   <module>r      s<   " " " " " " # # # # # #       % % % % % %  				 



                                                       ' ' ' ' ' '                        ~
 ~
 ~
 ~
 ~
 ~
 ~
 ~
B
    y    W' W' W' W' W' W' W' W'v %)+ + + + + zDFFFFF r0   