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/flask/__pycache__/cli.cpython-310.pyc
o

'we��@s�ddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddl
mZddlmZddlZddlmZddlmZddlmZddlmZd	d
lmZd	dlmZd	dlmZejrmd	d
l m!Z!Gdd�dej"�Z#dd�Z$dd�Z%dd�Z&dd�Z'd�dd�Z(dd�Z)ej*dgdde)ddd �Z+Gd!d"�d"�Z,ej-e,dd#�Z.d$d%�Z/Gd&d'�d'ej0�Z1d�d/d0�Z2ej*d1d2gd3d4dde2d5�Z3d�d8d9�Z4ej*d:gd;de4d<�Z5d�d=d>�Z6ej*d?d@gej7dddA�dBdde6dC�Z8GdDdE�dEe1�Z9dFdG�Z:d�d�dJdK�Z;dLdM�Z<GdNdO�dOej=�Z>dPdQ�Z?GdRdS�dSej7�Z@ejAdTdUdV�ejBdWdXdYdZd[�ejBd\d]d^d_d[�ejBd`e>�daddb�ejBdcej7ddddd�e?ddedf�ejBdgddhd[�ejBdiddjd[�ejBdkddld[�ejBdmde@�dnejCjD�do�dp�ejBdqde@�drejCjD�do�dp�e.dsdt������������ZEeEjF�Gde5�ejAdudvdV�e/d�dxdy���ZHejAdzd{dV�ejBd|d}e�Id~�dd�d��ejBd�dd�d��e/d�d�d������ZJe9d�d�d��ZKd�d�d��ZLeMd�k�r�eL�dSdS)��)�annotationsN)�update_wrapper)�
itemgetter)�ParameterSource)�
run_simple)�is_running_from_reloader)�
import_string�)�current_app)�get_debug_flag)�get_load_dotenv��Flaskc@seZdZdZdS)�NoAppExceptionz3Raised if an application cannot be found or loaded.N)�__name__�
__module__�__qualname__�__doc__�rr�B/home/arjun/projects/env/lib/python3.10/site-packages/flask/cli.pyrsrcs*ddlm�dD]}t||d�}t|��r|Sq�fdd�|j��D�}t|�dkr0|dSt|�dkrCtd|j�d	|j�d
���dD]B}t||d�}t	�
|�r�z|�}t|��r`|WSWqEty�}zt|�sn�td|�d
|j�d|j�d|�d�	�|�d}~wwqEtd|j�d	|j�d���)zwGiven a module instance this tries to find the best possible
    application in the module or raises an exception.
    r	r
)�app�applicationNcsg|]	}t|��r|�qSr)�
isinstance)�.0�vr
rr�
<listcomp>/sz!find_best_app.<locals>.<listcomp>rz0Detected multiple Flask applications in module 'z'. Use 'z":name' to specify the correct one.)�
create_app�make_appzDetected factory 'z
' in module 'z1', but could not call it without arguments. Use '�:z(args)' to specify arguments.z7Failed to find Flask application or factory in module 'z:name' to specify one.)
�r�getattrr�__dict__�values�lenrr�inspect�
isfunction�	TypeError�_called_with_wrong_args)�module�	attr_namer�matches�app_factory�err
r�
find_best_app!s^
����


�����������r-cCsFt��d}z|dur|jj|jurW~dS|j}|dusW~dS~w)z�Check whether calling a function raised a ``TypeError`` because
    the call failed or because something in the factory raised the
    error.

    :param f: The function that was called.
    :return: ``True`` if the call failed.
    �NFT)�sys�exc_info�tb_frame�f_code�__code__�tb_next)�f�tbrrrr'Vs	��
r'c

Cs�ddlm}ztj|��dd�j}Wnty"td|�d��d�wt|tj	�r1|j
}g}i}nDt|tj�rmt|jtj	�sFtd|�d	���|jj
}zd
d�|j
D�}dd
�|jD�}Wntyltd|�d	��d�wtd|�d���zt||�}Wnty�}z
td|�d|j�d	��|�d}~wwt�|�r�z	||i|��}	Wn ty�}zt|�s��td|�d|j�d��|�d}~ww|}	t|	|�r�|	Std|j�d|�d���)z�Check if the given string is a variable name or a function. Call
    a function to get the app instance, or return the variable directly.
    r	r
�eval)�modezFailed to parse z' as an attribute name or function call.Nz*Function reference must be a simple name: �.cSsg|]}t�|��qSr)�ast�literal_eval)r�argrrrr�sz&find_app_by_string.<locals>.<listcomp>cSsi|]
}|jt�|j��qSr)r<r:r;�value)r�kwrrr�
<dictcomp>�sz&find_app_by_string.<locals>.<dictcomp>z-Failed to parse arguments as literal values: zFailed to find attribute z in zThe factory z in module z2 could not be called with the specified arguments.z1A valid Flask application was not obtained from 'rz'.)rrr:�parse�strip�body�SyntaxErrorrr�Name�id�Call�func�args�keywords�
ValueErrorr �AttributeErrorrr$r%r&r')
r(�app_namer�expr�namerH�kwargs�attrr,rrrr�find_app_by_stringps�
���
�
���
�����
�����

���rQcCs�tj�|�}tj�|�\}}|dkr|}tj�|�dkr"tj�|�}g}	tj�|�\}}|�|�tj�tj�	|d��s>nq%t
jd|krMt
j�d|�d�	|ddd��S)	z�Given a filename this will try to calculate the python path, add it
    to the search path and return the actual module name that is expected.
    z.py�__init__Tz__init__.pyrr9N���)�os�path�realpath�splitext�basename�dirname�split�append�exists�joinr/�insert)rU�fname�ext�module_namerNrrr�prepare_import�s 
�rbTc	Cs�zt|�Wn)ty/t��djr!td|�dt�����d�|r,td|�d��d�YdSwtj|}|dur=t	|�St
||�S)Nr.zWhile importing z, an ImportError was raised:

zCould not import r9)�
__import__�ImportErrorr/r0r4r�	traceback�
format_exc�modulesr-rQ)rarL�raise_if_not_foundr(rrr�
locate_app�s&����


ricCsX|r|jrdStj�d�}tj�d�}tjdt���d|�d|��|jd�|�	�dS)N�flask�werkzeug�Python z
Flask z

Werkzeug )�color)
�resilient_parsing�	importlib�metadata�version�click�echo�platform�python_versionrm�exit)�ctx�paramr=�
flask_version�werkzeug_versionrrr�get_version�s
���r{z	--versionzShow the Flask version.F)�help�expose_value�callback�is_flag�is_eagerc@s,eZdZdZ			dddd
�Zddd�ZdS)�
ScriptInfoa�Helper object to deal with Flask applications.  This is usually not
    necessary to interface with as it's used internally in the dispatching
    to click.  In future versions of Flask this object will most likely play
    a bigger role.  Typically it's created automatically by the
    :class:`FlaskGroup` but you can also manually create it and pass it
    onwards as click object.
    NT�app_import_path�
str | Noner�t.Callable[..., Flask] | None�set_debug_flag�bool�return�NonecCs"||_||_i|_||_d|_dS�N)r�r�datar��_loaded_app)�selfr�rr�rrrrRs

zScriptInfo.__init__rcCs�|jdur|jS|jdur|��}n3|jr1tjd|jdd�dgdd�\}}t|�}t||�}ndD]}t|�}t|ddd�}|rDnq3|sKtd	��|jrRt	�|_
||_|S)
z�Loads the Flask app (if not yet loaded) and returns it.  Calling
        this multiple times will just result in the already loaded app to
        be returned.
        Nz
:(?![\\/])r	)�maxsplitr.)zwsgi.pyzapp.pyF)rhz�Could not locate a Flask application. Use the 'flask --app' option, 'FLASK_APP' environment variable, or a 'wsgi.py' or 'app.py' file in the current directory.)r�rr��rerZrbrirr�r�debug)r�rrUrN�import_namerrr�load_app%s0


���zScriptInfo.load_app)NNT)r�r�rr�r�r�r�r�)r�r)rrrrrRr�rrrrr�s
�r�)�ensurecstj�fdd��}t|��S)a�Wraps a callback so that it's guaranteed to be executed with the
    script's application context.

    Custom commands (and their options) registered under ``app.cli`` or
    ``blueprint.cli`` will always have an app context available, this
    decorator is not required in that case.

    .. versionchanged:: 2.2
        The app context is active for subcommands as well as the
        decorated callback. The app context is always available to
        ``app.cli`` command and parameter callbacks.
    cs8ts|�t���}|�|���|j�g|�Ri|��Sr�)r
�
ensure_objectr�r��
with_resource�app_context�invoke)�__ctxrHrOr�r5rr�	decorator`sz"with_appcontext.<locals>.decorator)rr�pass_contextr)r5r�rr�r�with_appcontextRs
r�c@s eZdZdZdd�Zdd�ZdS)�AppGroupaThis works similar to a regular click :class:`~click.Group` but it
    changes the behavior of the :meth:`command` decorator so that it
    automatically wraps the functions in :func:`with_appcontext`.

    Not to be confused with :class:`FlaskGroup`.
    cs"��dd������fdd�}|S)z�This works exactly like the method of the same name on a regular
        :class:`click.Group` but it wraps callbacks in :func:`with_appcontext`
        unless it's disabled by passing ``with_appcontext=False``.
        r�Tcs*�rt|�}tjj�g��Ri���|�Sr�)r�rr�Group�commandr��rHrOr��wrap_for_ctxrrr�zsz#AppGroup.command.<locals>.decorator)�pop)r�rHrOr�rr�rr�sszAppGroup.commandcOs&|�dt�tjj|g|�Ri|��S)z�This works exactly like the method of the same name on a regular
        :class:`click.Group` but it defaults the group class to
        :class:`AppGroup`.
        �cls)�
setdefaultr�rrr��group)r�rHrOrrrr��szAppGroup.groupN)rrrrr�r�rrrrr�ksr�rw�
click.Contextrx�click.Optionr=r�r�cCs |durdS|�t�}||_|Sr�)r�r�r�)rwrxr=�inforrr�_set_app�s

r�z-Az--app�IMPORTz�The Flask application or factory function to load, in the form 'module:name'. Module can be a dotted import or file path. Name is not required if it is 'app', 'application', 'create_app', or 'make_app', and can be 'name(args)' to pass arguments.)�metavarr|r�r}r~r��bool | NonecCs>|�|j�}|dur|tjtjfvrdS|rdndtjd<|S)N�1�0�FLASK_DEBUG)�get_parameter_sourcerNr�DEFAULT�DEFAULT_MAPrT�environ)rwrxr=�sourcerrr�
_set_debug�s
�r�z--debug/--no-debugzSet debug mode.)r|r}r~cCsP|durdSddl}z|�d�Wnty!tjd||d�d�wt|�|S)Nr�dotenvz4python-dotenv must be installed to load an env file.)rwrx)ro�
import_modulerdrr�BadParameter�load_dotenv)rwrxr=rorrr�_env_file_callback�s ���	r�z-ez
--env-file)r\�dir_okayzKLoad environment variables from this file. python-dotenv must be installed.)�typer|r�r}r~csneZdZdZ					d#d$�fdd�
Zdd�Z�fdd�Z�fdd�Z	d%d&�fdd�
Zd'�fd!d"�Z	�Z
S)(�
FlaskGroupa0Special subclass of the :class:`AppGroup` group that supports
    loading more commands from the configured Flask app.  Normally a
    developer does not have to interface with this class but there are
    some very advanced use cases for which it makes sense to create an
    instance of this. see :ref:`custom-scripts`.

    :param add_default_commands: if this is True then the default run and
        shell commands will be added.
    :param add_version_option: adds the ``--version`` option.
    :param create_app: an optional callback that is passed the script info and
        returns the loaded app.
    :param load_dotenv: Load the nearest :file:`.env` and :file:`.flaskenv`
        files to set environment variables. Will also change the working
        directory to the directory containing the first file found.
    :param set_debug_flag: Set the app's debug flag.

    .. versionchanged:: 2.2
        Added the ``-A/--app``, ``--debug/--no-debug``, ``-e/--env-file`` options.

    .. versionchanged:: 2.2
        An app context is pushed when running ``app.cli`` commands, so
        ``@with_appcontext`` is no longer required for those commands.

    .. versionchanged:: 1.0
        If installed, python-dotenv will be used to load environment variables
        from :file:`.env` and :file:`.flaskenv` files.
    TN�add_default_commandsr�rr��add_version_optionr�r��extra�t.Anyr�r�cs�t|�dd�pd�}|�tttf�|r|�t�d|vr!i|d<|d�dd�t	�j
dd|i|��||_||_||_
|rN|�t�|�t�|�t�d|_dS)N�paramsr�context_settings�auto_envvar_prefix�FLASKF)�listr��extend�_env_file_option�_app_option�
_debug_optionr[�version_optionr��superrRrr�r��add_command�run_command�
shell_command�routes_command�_loaded_plugin_commands)r�r�rr�r�r�r�r���	__class__rrrR�s 	




zFlaskGroup.__init__cCsX|jrdStjdkrddlm}nddl}|jdd�D]}|�|��|j	�qd|_dS)N)��
r)rpzflask.commands)r�T)
r�r/�version_infororp�importlib_metadata�entry_pointsr��loadrN)r�rp�eprrr�_load_plugin_commands$s

z FlaskGroup._load_plugin_commandsc
s�|��t��||�}|dur|S|�t�}z|��}Wn!ty=}ztjd|�	��d�ddd�WYd}~dSd}~wwt
rFt
��|urM|�|�
��|j�||�S�NzError: �
T�red)�err�fg)r�r��get_commandr�r�r�rrr�secho�format_messager
�_get_current_objectr�r��cli)r�rwrN�rvr�rr,r�rrr�5s
��zFlaskGroup.get_commandc
s�|��tt��|��}|�t�}z|�|��j�|��Wt|�St	yD}zt
jd|���d�ddd�WYd}~t|�Sd}~wt
y\t
jt���d�ddd�Yt|�Swr�)r��setr��
list_commandsr�r��updater�r�rrrr�r��	Exceptionrerf�sorted)r�rwr�r�r,r�rrr�Ps

�&���zFlaskGroup.list_commands�	info_namer�rH�	list[str]�parent�click.Context | Noner�csZdtjd<t|j�r
t�d|vr d|jvr t|j|jd�|d<t�j	||fd|i|��S)N�true�FLASK_RUN_FROM_CLI�obj)rr�r�)
rTr�rr�r�r�rr�r��make_context)r�r�rHr�r�r�rrr�es



�zFlaskGroup.make_contextrwcs4|s|jrt�|ig�t�|ig�t��||�Sr�)�no_args_is_helpr��handle_parse_resultr�r��
parse_args)r�rwrHr�rrr�}s
zFlaskGroup.parse_args)TNTTT)r�r�rr�r�r�r�r�r�r�r�r�r�r�r�)
r�r�rHr�r�r�r�r�r�r�)rwr�rHr�r�r�)rrrrrRr�r�r�r�r��
__classcell__rrr�rr��s�%�r�cCs&tj�||t|�d��tj��|kS)z�Take ``other`` and remove the length of ``path`` from it. Then join it
    to ``path``. If it is the original value, ``path`` is an ancestor of
    ``other``.N)rTrUr]r#�lstrip�sep)rU�otherrrr�_path_is_ancestor�s&r�rU�str | os.PathLike | NonecCs�zddl}Wn ty&|stj�d�stj�d�r#tjdddd�Yd	Sw|dur:tj�|�r8|j|d
d�Sd	Sd	}dD]}|j|dd
�}|sJq>|j|d
d�d}q>|S)a?Load "dotenv" files in order of precedence to set environment variables.

    If an env var is already set it is not overwritten, so earlier files in the
    list are preferred over later files.

    This is a no-op if `python-dotenv`_ is not installed.

    .. _python-dotenv: https://github.com/theskumar/python-dotenv#readme

    :param path: Load the file at this location instead of searching.
    :return: ``True`` if a file was loaded.

    .. versionchanged:: 2.0
        The current directory is not changed to the location of the
        loaded file.

    .. versionchanged:: 2.0
        When loading the env files, set the default encoding to UTF-8.

    .. versionchanged:: 1.1.0
        Returns ``False`` when python-dotenv is not installed, or when
        the given path isn't a file.

    .. versionadded:: 1.0
    rN�.env�	.flaskenvz^ * Tip: There are .env or .flaskenv files present. Do "pip install python-dotenv" to use them.�yellowT)r�r�Fzutf-8)�encoding)r�r�)�usecwd)	r�rdrTrU�isfilerrr�r��find_dotenv)rUr��loadedrNrrrr��s.��
r�cCsLt�rdS|durt�d|�d��|dur$t�d|rdnd���dSdS)z]Show extra startup messages the first time the server is run,
    ignoring the reloader.
    Nz * Serving Flask app '�'z * Debug mode: �on�off)rrrrs)r�r�rrr�show_server_banner�s�rc@s$eZdZdZdZdd�Zdd�ZdS)�
CertParamTypez�Click option type for the ``--cert`` option. Allows either an
    existing file, the string ``'adhoc'``, or an import for a
    :class:`~ssl.SSLContext` object.
    rUcCstjdddd�|_dS)NTF�r\r��resolve_path)rr�Path�	path_type)r�rrrrR�szCertParamType.__init__cCs�zddl}Wntyt�d||�d�wz|�|||�WStjy]t�|||���}|dkrLz	ddl}W|YStyKt�d||�d�wt|dd�}t	||j
�r\|YS�w)Nrz?Using "--cert" requires Python to be compiled with SSL support.�adhocz<Using ad-hoc certificates requires the cryptography library.T)�silent)�sslrdrrr�r�STRING�lower�cryptographyrr�
SSLContext)r�r=rxrwrrr�rrr�convert�sB���
����	�zCertParamType.convertN)rrrrrNrRrrrrrr�s
rcCs�|j�d�}|dk}zddl}Wntyd}Ynwt||j�}|durJ|r/t�d||��|r8t�d||��|sAt�d||��||f|jd<|S|rW|sW|sWt�d	||��|S)
z�The ``--key`` option must be specified when ``--cert`` is a file.
    Modifies the ``cert`` param to be a ``(cert, key)`` pair if needed.
    �certr
rNFz.When "--cert" is "adhoc", "--key" is not used.z:When "--cert" is an SSLContext object, "--key is not used.z "--cert" must also be specified.zRequired when using "--cert".)r��getrrdrrrrr�)rwrxr=r�is_adhocr�
is_contextrrr�
_validate_keys0����rcs eZdZdZ�fdd�Z�ZS)�SeparatedPathTypez�Click option type that accepts a list of values separated by the
    OS's path separator (``:``, ``;`` on Windows). Each value is
    validated as a :class:`click.Path` type.
    cs(|�|�}t�j����fdd�|D�S)Ncsg|]}�|����qSrr)r�item�rwrx�
super_convertrrr6sz-SeparatedPathType.convert.<locals>.<listcomp>)�split_envvar_valuer�r)r�r=rxrw�itemsr�rrr3s
zSeparatedPathType.convert)rrrrrr�rrr�rr-sr�runzRun a development server.)�
short_helpz--hostz-hz	127.0.0.1zThe interface to bind to.)�defaultr|z--portz-pi�zThe port to bind to.z--certz(Specify a certificate file to use HTTPS.)r�r|r�z--keyr	z2The key file to use when specifying a certificate.)r�r~r}r|z--reload/--no-reloadzVEnable or disable the reloader. By default the reloader is active if debug is enabled.z--debugger/--no-debuggerzVEnable or disable the debugger. By default the debugger is active if debug is enabled.z --with-threads/--without-threadsz!Enable or disable multithreading.z
--extra-fileszMExtra files that trigger a reload on change. Multiple paths are separated by r9)r"r�r|z--exclude-patternsznFiles matching these fnmatch patterns will not trigger a reload on change. Multiple patterns are separated by c	s�z|��}	Wn%ty+}
zt�rt��|
��fdd�}	n|
d�WYd}
~
nd}
~
wwt�}|dur5|}|dur;|}t||j�t|||	||||||d�	dS)aRun a local development server.

    This server is for development purposes only. It does not provide
    the stability, security, or performance of production WSGI servers.

    The reloader and debugger are enabled by default with the '--debug'
    option.
    cs�d�r�r)r��start_response�r�rrr�szrun_command.<locals>.appN)�use_reloader�use_debugger�threaded�ssl_context�extra_files�exclude_patterns)	r�r�rre�	print_excrrr�r)r��host�port�reload�debugger�with_threadsrr)r*rr,r�rr$rr�9s8H���
�r��shellzRun a shell in the app context.r�cCsddl}dtj�dtj�dtj�dtj��}i}tj�	d�}|rEtj
�|�rEt|��}t
t|��|d�|�Wd�n1s@wY|�t���ttd	d�}|durwzddl}dd
lm}Wn	tykYn	w|�||�j�|�|j||d�dS)a:Run an interactive Python shell in the context of a given
    Flask application.  The application will populate the default
    namespace of this shell according to its configuration.

    This is useful for executing small snippets of management code
    without having to manually configure the application.
    rNrlz on z
App: z
Instance: �
PYTHONSTARTUP�exec�__interactivehook__)�	Completer)�banner�local)�coder/rqrtr
r��
instance_pathrTr�rrUr�openr7�compile�readr��make_shell_contextr �readline�rlcompleterr5rd�
set_completer�complete�interact)r8r6rw�startupr5�interactive_hookr>r5rrrr��s2
���
��r��routeszShow the routes for the app.z--sortz-s)�endpoint�methods�domain�rule�matchrFzgMethod to sort routes by. 'match' is the order that Flask will match routes when dispatching a request.)r�r"r|z
--all-methodszShow HEAD and OPTIONS methods.)rr|�sort�str�all_methodscs�ttj���}|st�d�dS|rt�nddh}tjj�t�fdd�|D��}g�|D],}|j	d�
t|jp8t�|��g}|rM|�
�rG|jn|jpKd�|�
|j���
|�q,d	d
g}ddg}|rq|�
�rid
nd�|�
d�|�
d�|�
d�z
�jt|�|��d�Wn	ty�Ynw��d|��fdd�tt|��D�}	��ddd�|	D��d�
dd�t|	�D��}
�D]
}t�|
j|��q�dS)z6Show all registered routes with endpoints and methods.zNo routes were registered.N�HEAD�OPTIONSc3s �|]}�r	|jn|jVqdSr�)r,�	subdomain)rrI)�
host_matchingrr�	<genexpr>�s�z!routes_command.<locals>.<genexpr>z, r�Endpoint�MethodsrFrG�Host�	SubdomainrH�RulerI)�keyrcs"g|]
�t�fdd��D���qS)c3s�|]	}t|��VqdSr�)r#)r�row��irrrRs�z,routes_command.<locals>.<listcomp>.<genexpr>)�max)r)�rowsrZrrs"z"routes_command.<locals>.<listcomp>r	cSsg|]}d|�qS)�-r)r�wrrrrsz  css&�|]\}}d|�d|�d�VqdS)�{z:<�}Nr)rr[r_rrrrRs�$)r�r
�url_map�
iter_rulesrrrsr�rQ�anyrFr]r�rGr[r,rPrIrKr�indexrJr^�ranger#�	enumerate�format)rKrM�rules�ignored_methods�
has_domainrIrY�headers�sorts�widths�templater)rQr]rr��sF
�


��r�rjz�A general utility script for Flask applications.

An application to load must be given with the '--app' option,
'FLASK_APP' environment variable, or with a 'wsgi.py' or 'app.py' file
in the current directory.
)rNr|cCst��dSr�)r��mainrrrrrp'srp�__main__)T)rwr�rxr�r=r�r�r�)rwr�rxr�r=r�r�r�r�)rUr�r�r�)r�r�)rKrLrMr�r�r�)N�
__future__rr:�importlib.metadataror$rTrtr�r/re�typing�t�	functoolsr�operatorrrr�
click.corerrkr�werkzeug.servingr�werkzeug.utilsr�globalsr
�helpersrr�
TYPE_CHECKINGrr�
UsageErrorrr-r'rQrbrir{�Optionr�r��make_pass_decorator�pass_script_infor�r�r�r�r�r�r�r�rr�r�r�r�r�	ParamTyperrrr��optionrU�pathsepr�r�r^r��Choicer�r�rprrrrr�<module>s$5L
�
D

�
�
�
'=.%�������	��
;/�
1�


�