Format: application/x-python-code
⬇ Download File (29.2 KB)
   1  o
   2  
   3  D'h��@sTddlmZddlZddlmZddlZddlZddl	Z	ddl
   4  Z
   5  ddlZddlZddl
   6  Z
   7  ddlZddlmZddlmZddlmZddlZddlmZddlmZddlmZdd	lmZd
   8  dlm Z d
   9  dl!m"Z"d
  10  d
  11  l!m#Z#ej$r�ddl%Z%ddl&m'Z'ddl&m(Z(ddl&m)Z)d
  12  dl*m+Z+Gdd�dej,�Z-d�dd�Z.d�dd�Z/d�d!d"�Z0d�d$d%�Z1ej2	&d�d�d+d,��Z3ej2	-d�d�d0d,��Z3	&d�d�d1d,�Z3d�d9d:�Z4ej5d;gd<d=e4d&d&d>�Z6Gd?d@�d@�Z7ej8e7d&dA�Z9ej:dBej;d-ej<fdC�Z=d�dDdE�Z>GdFdG�dGej?�Z@d�dIdJ�ZAej5dKdLgdMdNd&d=eAdO�ZBd�dQdR�ZCej5dSgdTd=eCdU�ZDd�dVdW�ZEej5dXdYgejFd&d=dZ�d[d&d=eEd\�ZGGd]d^�d^e@�ZHd�d`da�ZI	&d�d�ddde�ZJd�dhdi�ZKGdjdk�dkejL�ZMd�dldm�ZNGdndo�doejF�ZOejPdpdqdr�ejQdsdtdudvdw�ejQdxdydzd{dw�ejQd|eM�d}d&d~�ejQdejFd&d=d&d��eNd=d�d��ejQd�dd�dw�ejQd�dd�dw�ejQd�d&d�dw�ejQd�deO�d�e	jRjS�d��d��ejQd�deO�d�e	jRjS�d��d��e9d�d�d�������������ZTeTjU�VdeD�ejPd�d�dr�e>d�d�d����ZWejPd�d�dr�ejQd�d�e�Xd��d�d�d��ejQd�d&d�d��e>d�d�d������ZYeHd�d�d��ZZd�d�d��Z[e\d�k�r(e[�dSdS)��)�annotationsN)�update_wrapper)�
  13  itemgetter)�
  14  ModuleType)�ParameterSource)�
  15  run_simple)�is_running_from_reloader)�
  16  import_string�)�current_app)�get_debug_flag)�get_load_dotenv)�
  17  StartResponse)�WSGIApplication)�WSGIEnvironment��Flaskc@seZdZdZdS)�NoAppExceptionz3Raised if an application cannot be found or loaded.N)�__name__�
  18  __module__�__qualname__�__doc__�rr�?C:\Users\shubh\Videos\agent\nova\Lib\site-packages\flask/cli.pyr%sr�moduler�returnrcs*ddlm�dD]}t||d�}t|��r|Sq�fdd�|j��D�}t|�dkr0|dSt|�dkrCtd|j�d	|j�d
  19  ���dD]B}t||d�}t	�
  20  |�r�z|�}t|��r`|WSWqEty�}zt|�sn�td|�d
  21  |j�d|j�d|�d�	�|�d}~wwqEtd|j�d	|j�d���)zwGiven a module instance this tries to find the best possible
  22      application in the module or raises an exception.
  23      r
  24  r)�appZapplicationNcsg|]	}t|��r|�qSr)�
  25  isinstance)�.0�vrrr�
  26  <listcomp>7sz!find_best_app.<locals>.<listcomp>rz0Detected multiple Flask applications in module 'z'. Use 'z":name' to specify the correct one.)�
  27  create_appZmake_appzDetected factory 'z
  28  ' 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.)
  29  �r�getattrr�__dict__�values�lenrr�inspect�
  30  isfunction�	TypeError�_called_with_wrong_args)rZ	attr_namer�matchesZapp_factory�errr�
  31  find_best_app)s^
  32  ����
  33  
  34  
  35  �����������r.�f�t.Callable[..., Flask]�boolcCsFt��d}z|dur|jj|jurW~dS|j}|dusW~dS~w)z�Check whether calling a function raised a ``TypeError`` because
  36      the call failed or because something in the factory raised the
  37      error.
  38  
  39      :param f: The function that was called.
  40      :return: ``True`` if the call failed.
  41      �NFT)�sys�exc_info�tb_frame�f_code�__code__�tb_next)r/�tbrrrr+^s	��
  42  r+�app_name�strc
  43  
  44  Cs�ddlm}ztj|��dd�j}Wnty"td|�d��d�wt|tj	�r1|j
  45  }g}i}nDt|tj�rmt|jtj	�sFtd|�d	���|jj
  46  }zd
  47  d�|j
  48  D�}dd
  49  �|jD�}Wntyltd|�d	��d�wtd|�d���zt||�}Wnty�}z
  50  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
  51      a function to get the app instance, or return the variable directly.
  52      r
  53  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>cSs&i|]}|jdur|jt�|j��qS�N)rAr?r@�value)r�kwrrr�
  54  <dictcomp>�s
  55  
  56  �z&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 'r"z'.)r#rr?�parse�strip�body�SyntaxErrorrr�Name�id�Call�func�args�keywords�
  57  ValueErrorr$�AttributeErrorrr(r)r*r+)
  58  rr:r�expr�namerN�kwargs�attrr-rrrr�find_app_by_stringxs�
  59  ���
  60  �
  61  �
  62  ���
  63  �����
  64  �����
  65  
  66  ���rV�pathcCs�tj�|�}tj�|�\}}|dkr|}tj�|�dkr"tj�|�}g}	tj�|�\}}|�|�tj�tj�	|d��s>nq%t
  67  jd|krMt
  68  j�d|�d�	|ddd��S)	z�Given a filename this will try to calculate the python path, add it
  69      to the search path and return the actual module name that is expected.
  70      z.py�__init__Tz__init__.pyrr>N�����)�osrW�realpath�splitext�basename�dirname�split�append�exists�joinr3�insert)rW�fname�ext�module_namerSrrr�prepare_import�s 
  71  �rgTrf�
  72  str | None�raise_if_not_found�t.Literal[True]cC�dSrBr�rfr:rirrr�
  73  locate_app��rm.�t.Literal[False]�Flask | NonecCrkrBrrlrrrrm�rnc	Cs�zt|�Wn)ty/t��djr!td|�dt�����d�|r,td|�d��d�YdSwtj|}|dur=t	|�St
  74  ||�S)Nr2zWhile importing z, an ImportError was raised:
  75  
  76  zCould not import r>)�
  77  __import__�ImportErrorr3r4r8r�	traceback�
  78  format_exc�modulesr.rV)rfr:rirrrrrm�s&����
  79  
  80  
  81  �ctx�
  82  click.Context�param�click.ParameterrC�t.Any�NonecCsX|r|jrdStj�d�}tj�d�}tjdt���d|�d|��|jd�|�	�dS)N�flask�werkzeug�Python z
  83  Flask z
  84  
  85  Werkzeug )�color)
  86  Zresilient_parsing�	importlib�metadata�version�click�echo�platform�python_versionr�exit)rvrxrCZ
  87  flask_versionZwerkzeug_versionrrr�get_versions
  88  ���r�z	--versionzShow the Flask version.F)�help�expose_value�callback�is_flag�is_eagerc@s.eZdZdZ				ddd
  89  d�Zddd�ZdS)�
  90  ScriptInfoa�Helper object to deal with Flask applications.  This is usually not
  91      necessary to interface with as it's used internally in the dispatching
  92      to click.  In future versions of Flask this object will most likely play
  93      a bigger role.  Typically it's created automatically by the
  94      :class:`FlaskGroup` but you can also manually create it and pass it
  95      onwards as click object.
  96  
  97      .. versionchanged:: 3.1
  98          Added the ``load_dotenv_defaults`` parameter and attribute.
  99      NT�app_import_pathrhr!�t.Callable[..., Flask] | None�set_debug_flagr1�load_dotenv_defaultsrr{cCs.||_||_i|_||_t|�|_	d|_dSrB)r�r!�datar�r
 100  r��_loaded_app)�selfr�r!r�r�rrrrX1s
 101  
 102  zScriptInfo.__init__rcCs�|jdur|jSd}|jdur|��}n5|jr3tjd|jdd�dgdd�\}}t|�}t||�}ndD]}t|�}t|ddd�}|durHnq5|durQtd	��|jrXt	�|_
 103  ||_|S)
 104  z�Loads the Flask app (if not yet loaded) and returns it.  Calling
 105          this multiple times will just result in the already loaded app to
 106          be returned.
 107          Nz
 108  :(?![\\/])r
 109  )�maxsplitr2)zwsgi.pyzapp.pyF)riz�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�r!r��rer_rgrmrr�r�debug)r�rrWrS�import_namerrr�load_appMs2
 110  
 111  
 112  ���zScriptInfo.load_app)NNTT)
 113  r�rhr!r�r�r1r�r1rr{)rr)rrrrrXr�rrrrr�%s
 114  �r�)Zensure�F)�boundcstjd
 115  �fdd��}t|��S)a�Wraps a callback so that it's guaranteed to be executed with the
 116      script's application context.
 117  
 118      Custom commands (and their options) registered under ``app.cli`` or
 119      ``blueprint.cli`` will always have an app context available, this
 120      decorator is not required in that case.
 121  
 122      .. versionchanged:: 2.2
 123          The app context is active for subcommands as well as the
 124          decorated callback. The app context is always available to
 125          ``app.cli`` command and parameter callbacks.
 126      rvrwrNrzrTrcs8ts|�t���}|�|���|j�g|�Ri|��SrB)r�
 127  ensure_objectr�r��
 128  with_resource�app_contextZinvoke)rvrNrTr�r/rr�	decorator�sz"with_appcontext.<locals>.decoratorN)rvrwrNrzrTrzrrz)r�Zpass_contextr)r/r�rr�r�with_appcontext|s
 129  r�cs0eZdZdZd�fdd�Zd
 130  �fd
 131  d�Z�ZS)�AppGroupaThis works similar to a regular click :class:`~click.Group` but it
 132      changes the behavior of the :meth:`command` decorator so that it
 133      automatically wraps the functions in :func:`with_appcontext`.
 134  
 135      Not to be confused with :class:`FlaskGroup`.
 136      rNrzrTr�3t.Callable[[t.Callable[..., t.Any]], click.Command]cs&��dd��d
 137  �����fdd�}|S)z�This works exactly like the method of the same name on a regular
 138          :class:`click.Group` but it wraps callbacks in :func:`with_appcontext`
 139          unless it's disabled by passing ``with_appcontext=False``.
 140          r�Tr/�t.Callable[..., t.Any]r�
 141  click.Commandcs&�rt|�}tt��j�i���|�SrB)r��superr��commandr�)�	__class__rNrTr��wrap_for_ctxrrr��sz#AppGroup.command.<locals>.decoratorN)r/r�rr�)�pop)r�rNrTr��r�)rNrTr�r�rr��szAppGroup.command�1t.Callable[[t.Callable[..., t.Any]], click.Group]cs|�dt�t�j|i|��S)z�This works exactly like the method of the same name on a regular
 142          :class:`click.Group` but it defaults the group class to
 143          :class:`AppGroup`.
 144          �cls)�
 145  setdefaultr�r��group)r�rNrTr�rrr��szAppGroup.group)rNrzrTrzrr�)rNrzrTrzrr�)rrrrr�r��
 146  __classcell__rrr�rr��sr��click.OptioncCs |durdS|�t�}||_|SrB)r�r�r�)rvrxrC�inforrr�_set_app�s
 147  
 148  r�z-Az--appZIMPORTz�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��bool | NonecCs>|�|j�}|dur|tjtjfvrdS|rdndtjd<|S)N�1�0ZFLASK_DEBUG)Zget_parameter_sourcerSr�DEFAULTZDEFAULT_MAPrZ�environ)rvrxrC�sourcerrr�
 149  _set_debug�s
 150  �r�z--debug/--no-debugzSet debug mode.)r�r�r�cCs^zddl}Wnty|durtjd||d�d�Ynw|dus%|jjr-t||jjd�|S)Nrz4python-dotenv must be installed to load an env file.)rvrx)�
 151  load_defaults)�dotenvrrr��BadParameter�objr��load_dotenv)rvrxrCr�rrr�_env_file_callback�s ����r�z-ez
 152  --env-file)ra�dir_okayz�Load environment variables from this file, taking precedence over those set by '.env' and '.flaskenv'. Variables set directly in the environment take highest precedence. python-dotenv must be installed.)�typer�r�r�r�csteZdZdZ					d&d'�fdd�
 153  Zd(dd�Zd)�fdd�Zd*�fdd�Z	d+d,�fd"d#�
 154  Zd-�fd$d%�Z	�Z
 155  S).�
 156  FlaskGroupa�Special subclass of the :class:`AppGroup` group that supports
 157      loading more commands from the configured Flask app.  Normally a
 158      developer does not have to interface with this class but there are
 159      some very advanced use cases for which it makes sense to create an
 160      instance of this. see :ref:`custom-scripts`.
 161  
 162      :param add_default_commands: if this is True then the default run and
 163          shell commands will be added.
 164      :param add_version_option: adds the ``--version`` option.
 165      :param create_app: an optional callback that is passed the script info and
 166          returns the loaded app.
 167      :param load_dotenv: Load the nearest :file:`.env` and :file:`.flaskenv`
 168          files to set environment variables. Will also change the working
 169          directory to the directory containing the first file found.
 170      :param set_debug_flag: Set the app's debug flag.
 171  
 172      .. versionchanged:: 3.1
 173          ``-e path`` takes precedence over default ``.env`` and ``.flaskenv`` files.
 174  
 175      .. versionchanged:: 2.2
 176          Added the ``-A/--app``, ``--debug/--no-debug``, ``-e/--env-file`` options.
 177  
 178      .. versionchanged:: 2.2
 179          An app context is pushed when running ``app.cli`` commands, so
 180          ``@with_appcontext`` is no longer required for those commands.
 181  
 182      .. versionchanged:: 1.0
 183          If installed, python-dotenv will be used to load environment variables
 184          from :file:`.env` and :file:`.flaskenv` files.
 185      TN�add_default_commandsr1r!r��add_version_optionr�r��extrarzrr{cs�t|�dd�pd�}|�tttf�|r|�t�d|vr!i|d<|d�dd�t	�j
 186  dd|i|��||_||_||_
 187  |rN|�t�|�t�|�t�d|_dS)N�paramsr�context_settingsZauto_envvar_prefixZFLASKF)�listr��extend�_env_file_option�_app_option�
 188  _debug_optionr`�version_optionr�r�rXr!r�r��add_command�run_command�
 189  shell_command�routes_command�_loaded_plugin_commands)r�r�r!r�r�r�r�r�r�rrrX3s 	
 190  
 191  
 192  
 193  
 194  zFlaskGroup.__init__cCsX|jrdStjdkrddlm}nddl}|jdd�D]}|�|��|j	�qd|_dS)N)��
 195  r)r�zflask.commands)r�T)
 196  r�r3�version_infor�r��importlib_metadata�entry_pointsr��loadrS)r�r��eprrr�_load_plugin_commandsXs
 197  
 198  z FlaskGroup._load_plugin_commandsrvrwrSr;�click.Command | Nonec
 199  s�|��t��||�}|dur|S|�t�}z|��}Wn!ty=}ztjd|�	��d�ddd�WYd}~dSd}~wwt
 200  rFt
 201  ��|urM|�|�
 202  ��|j�||�S�NzError: �
 203  T�red)�err�fg)r�r��get_commandr�r�r�rr��secho�format_messagerZ_get_current_objectr�r��cli)r�rvrS�rvr�rr-r�rrr�is
 204  ��zFlaskGroup.get_command�	list[str]c
 205  s�|��tt��|��}|�t�}z|�|��j�|��Wt|�St	yD}zt
 206  jd|���d�ddd�WYd}~t|�Sd}~wt
 207  y\t
 208  jt���d�ddd�Yt|�Swr�)r��setr��
 209  list_commandsr�r��updater�r�rr�r�r��	Exceptionrsrt�sorted)r�rvr�r�r-r�rrr��s
 210  
 211  �&���zFlaskGroup.list_commands�	info_namerhrN�parent�click.Context | NonecsNdtjd<d|vrd|jvrt|j|j|jd�|d<t�j||fd|i|��S)N�trueZFLASK_RUN_FROM_CLIr�)r!r�r�r�)	rZr�r�r�r!r�r�r��make_context)r�r�rNr�r�r�rrr��s
 212  
 213  
 214  �zFlaskGroup.make_contextcs4|s|jrt�|ig�t�|ig�t��||�SrB)Zno_args_is_helpr�Zhandle_parse_resultr�r��
 215  parse_args)r�rvrNr�rrr��s
 216  zFlaskGroup.parse_args)TNTTT)r�r1r!r�r�r1r�r1r�r1r�rzrr{�rr{)rvrwrSr;rr�)rvrwrr�rB)
 217  r�rhrNr�r�r�r�rzrrw)rvrwrNr�rr�)rrrrrXr�r�r�r�r�r�rrr�rr�s!�
 218  %�r��othercCs&tj�||t|�d��tj��|kS)z�Take ``other`` and remove the length of ``path`` from it. Then join it
 219      to ``path``. If it is the original value, ``path`` is an ancestor of
 220      ``other``.N)rZrWrbr'�lstrip�sep)rWr�rrr�_path_is_ancestor�s&r��str | os.PathLike[str] | Noner�cCs�zddl}Wn ty&|stj�d�stj�d�r#tjdddd�Yd	Swi}|rCd
 221  D]}|j|dd�}s9q-||j|dd
 222  �O}q-|durVtj�|�rV||j|dd
 223  �O}|�	�D]\}}|tj
 224  vsg|durhqZ|tj
 225  |<qZt|�S)acLoad "dotenv" files to set environment variables. A given path takes
 226      precedence over ``.env``, which takes precedence over ``.flaskenv``. After
 227      loading and combining these files, values are only set if the key is not
 228      already set in ``os.environ``.
 229  
 230      This is a no-op if `python-dotenv`_ is not installed.
 231  
 232      .. _python-dotenv: https://github.com/theskumar/python-dotenv#readme
 233  
 234      :param path: Load the file at this location.
 235      :param load_defaults: Search for and load the default ``.flaskenv`` and
 236          ``.env`` files.
 237      :return: ``True`` if at least one env var was loaded.
 238  
 239      .. versionchanged:: 3.1
 240          Added the ``load_defaults`` parameter. A given path takes precedence
 241          over default files.
 242  
 243      .. versionchanged:: 2.0
 244          The current directory is not changed to the location of the
 245          loaded file.
 246  
 247      .. versionchanged:: 2.0
 248          When loading the env files, set the default encoding to UTF-8.
 249  
 250      .. versionchanged:: 1.1.0
 251          Returns ``False`` when python-dotenv is not installed, or when
 252          the given path isn't a file.
 253  
 254      .. versionadded:: 1.0
 255      rN�.env�	.flaskenvzH * Tip: There are .env files present. Install python-dotenv to use them.�yellowT)r�r�F)r�r�)Zusecwdzutf-8)�encoding)r�rrrZrW�isfiler�r�Zfind_dotenvZ
 256  dotenv_values�itemsr�r1)rWr�r�r��default_nameZdefault_path�keyrCrrrr��s0"��r�r�r�cCsLt�rdS|durt�d|�d��|dur$t�d|rdnd���dSdS)z]Show extra startup messages the first time the server is run,
 257      ignoring the reloader.
 258      Nz * Serving Flask app '�'z * Debug mode: �on�off)rr�r�)r�r�rrr�show_server_banners�rc@s(eZdZdZdZddd�Zdd
 259  d�ZdS)�
 260  CertParamTypez�Click option type for the ``--cert`` option. Allows either an
 261      existing file, the string ``'adhoc'``, or an import for a
 262      :class:`~ssl.SSLContext` object.
 263      rWrr{cCstjdddd�|_dS)NTF�rar�Zresolve_path)r��Path�	path_type)r�rrrrXszCertParamType.__init__rCrzrx�click.Parameter | Nonervr�cCs�zddl}Wntyt�d||�d�wz|�|||�WStjy]t�|||���}|dkrLz	ddl}W|YStyKt�d||�d�wt|dd�}t	||j
 264  �r\|YS�w)Nrz?Using "--cert" requires Python to be compiled with SSL support.�adhocz<Using ad-hoc certificates requires the cryptography library.T)Zsilent)�sslrrr�r�r
 265  �STRING�lower�cryptographyr	r�
 266  SSLContext)r�rCrxrvr
 267  rr�rrr�convertsB���
 268  ����	�zCertParamType.convertNr��rCrzrxrrvr�rrz)rrrrrSrXrrrrrrs
 269  
 270  rcCs�|j�d�}|dk}zddl}Wntyd}Ynwt||j�}|durJ|r/t�d||��|r8t�d||��|sAt�d||��||f|jd<|S|rW|sW|sWt�d	||��|S)
 271  z�The ``--key`` option must be specified when ``--cert`` is a file.
 272      Modifies the ``cert`` param to be a ``(cert, key)`` pair if needed.
 273      �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��getr
 274  rrrrr�r�)rvrxrCrZis_adhocr
 275  Z
 276  is_contextrrr�
 277  _validate_keyBs4����rcs"eZdZdZd�fd	d
 278  �Z�ZS)�SeparatedPathTypez�Click option type that accepts a list of values separated by the
 279      OS's path separator (``:``, ``;`` on Windows). Each value is
 280      validated as a :class:`click.Path` type.
 281      rCrzrxrrvr�rcs(|�|�}t�j����fdd�|D�S)Ncsg|]}�|����qSrr)r�item�rvrxZ
 282  super_convertrrr usz-SeparatedPathType.convert.<locals>.<listcomp>)Zsplit_envvar_valuer�r)r�rCrxrvrr�rrros
 283  zSeparatedPathType.convertr)rrrrrr�rrr�rrisr�runzRun a development server.)Z
 284  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--keyrz2The 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
 285  --extra-fileszMExtra files that trigger a reload on change. Multiple paths are separated by r>)rr�r�z--exclude-patternsznFiles matching these fnmatch patterns will not trigger a reload on change. Multiple patterns are separated by r��host�port�int�reload�debugger�with_threadsr�Cssl.SSLContext | tuple[str, str | None] | t.Literal['adhoc'] | None�extra_files�list[str] | None�exclude_patternsc	s�z|��}	Wn&ty,}
 286  zt�rt��|
 287  �d�fdd�}	n|
 288  d	�WYd	}
 289  ~
 290  nd	}
 291  ~
 292  wwt�}|d	ur6|}|d	ur<|}t||j�t|||	||||||d
 293  �	d	S)aRun a local development server.
 294  
 295      This server is for development purposes only. It does not provide
 296      the stability, security, or performance of production WSGI servers.
 297  
 298      The reloader and debugger are enabled by default with the '--debug'
 299      option.
 300      r�r�start_responserr�cabc.Iterable[bytes]cs�d�rBr)r�r&�r�rrr�szrun_command.<locals>.appN)Zuse_reloaderZuse_debuggerZthreaded�ssl_contextr#r%)r�rr&rrr')	r�r�rrs�	print_excrrr�r)r�rrrr r!rr#r%rr-r�rr(rr�xs8H���
 301  �r��shellzRun a shell in the app context.cCsddl}dtj�dtj�dtj�dtj��}i}tj�	d�}|rEtj
 302  �|�rEt|��}t
 303  t|��|d�|�Wd�n1s@wY|�t���ttd	d�}|durwzddl}dd
 304  lm}Wn	tykYn	w|�||�j�|�|j||d�dS)a:Run an interactive Python shell in the context of a given
 305      Flask application.  The application will populate the default
 306      namespace of this shell according to its configuration.
 307  
 308      This is useful for executing small snippets of management code
 309      without having to manually configure the application.
 310      rNr~z on z
 311  App: z
 312  Instance: Z
 313  PYTHONSTARTUP�exec�__interactivehook__)�	Completer)�banner�local)�coder3r�r�rr�Z
 314  instance_pathrZr�rrWr��openr<�compile�readr�Zmake_shell_contextr$�readline�rlcompleterr.rrZ
 315  set_completerZcompleteZinteract)r1r/rvZstartupr/Zinteractive_hookr5r.rrrr��s2
 316  ���
 317  ��r�ZrouteszShow the routes for the app.z--sortz-s)�endpoint�methods�domain�rule�matchr7zgMethod to sort routes by. 'match' is the order that Flask will match routes when dispatching a request.)r�rr�z
 318  --all-methodszShow HEAD and OPTIONS methods.)r�r��sort�all_methodscs�ttj���}|st�d�dS|rt�nddh}tjj�t�fdd�|D��}g�|D],}|j	d�
 319  t|jp8t�|��g}|rM|�
 320  �rG|jn|jpKd�|�
 321  |j���
 322  |�q,d	d
 323  g}ddg}|rq|�
 324  �rid
 325  nd�|�
 326  d�|�
 327  d�|�
 328  d�z
 329  �jt|�|��d�Wn	ty�Ynw��d|��fdd�tt|��D�}	��ddd�|	D��d�
 330  dd�t|	�D��}
 331  �D]
 332  }t�|
 333  j|��q�dS)z6Show all registered routes with endpoints and methods.zNo routes were registered.N�HEAD�OPTIONSc3s �|]}�r	|jn|jVqdSrB)r�	subdomain)rr:)�
 334  host_matchingrr�	<genexpr>5s�z!routes_command.<locals>.<genexpr>z, r#ZEndpointZMethodsr7r8�HostZ	Subdomainr9�Ruler:)rrcs"g|]
 335  �t�fdd��D���qS)c3s�|]	}t|��VqdSrB)r')r�row��irrrBTs�z,routes_command.<locals>.<listcomp>.<genexpr>)�max)r)�rowsrFrr Ts"z"routes_command.<locals>.<listcomp>r
 336  cSsg|]}d|�qS)�-r)r�wrrrr Usz  css&�|]\}}d|�d|�d�VqdS)�{z:<�}Nr)rrGrKrrrrBVs�$)r�rZurl_mapZ
 337  iter_rulesr�r�r�rA�anyr7rbr�r8r`rr@r:r<r�indexrPrc�ranger'�	enumerate�format)r<r=�rulesZignored_methodsZ
 338  has_domainr:rE�headersZsorts�widths�templater)rArIrr�sF
 339  �
 340  
 341  
 342  ��r�r|z�A general utility script for Flask applications.
 343  
 344  An application to load must be given with the '--app' option,
 345  'FLASK_APP' environment variable, or with a 'wsgi.py' or 'app.py' file
 346  in the current directory.
 347  )rSr�cCst��dSrB)r��mainrrrrrWhsrW�__main__)rrrr)r/r0rr1)rrr:r;rr)rWr;rr;)T)rfr;r:rhrirjrr).)rfr;r:rhrirorrp)rfr;r:rhrir1rrp)rvrwrxryrCrzrr{)r/r�rr�)rvrwrxr�rCrhrrh)rvrwrxr�rCr1rr�)rWr;r�r;rr1)NT)rWr�r�r1rr1)r�r1r�rhrr{)rvrwrxryrCrzrrz)r�r�rr;rrrr1r r1r!r1rr"r#r$r%r$rr{r�)r<r;r=r1rr{)]�
 348  __future__rr?�collections.abc�abcZcabc�importlib.metadatar�r(rZr�r�r3rs�typing�t�	functoolsr�operatorr�typesrr�Z
 349  click.corerr}rZwerkzeug.servingrZwerkzeug.utilsr	�globalsr�helpersrr
 350  �
 351  TYPE_CHECKINGr
 352  Z_typeshed.wsgirrrrrZ
 353  UsageErrorrr.r+rVrg�overloadrmr��Optionr�r�Zmake_pass_decoratorZpass_script_info�TypeVar�Callable�Anyr�r��Groupr�r�r�r�r�r�r	r�r�r�r�rZ	ParamTyperrrr��optionrW�pathsepr�r�rcr�ZChoicer�r�rWrrrrr�<module>sB
 354  
 355  5
 356  
 357  P���
 358  �
 359  R
 360  
 361  #
 362  �
 363  �
 364  �
 365  '�
 366  D
 367  0'�������	��
 368   =/�
 369  1�
 370  
 371  
 372  �