Format: application/x-python-code
1 o
2
3 D'h� � @ sT d dl mZ d dlZd dlmZ d dlZd dlZd dl Z d dl
4 Z
5 d dlZd dlZd dl
6 Z
7 d dlZd dlmZ d dlmZ d dlmZ d dlZd dlmZ d dlmZ d dlmZ d d lmZ d
8 dlm Z d
9 dl!m"Z" d
10 d
11 l!m#Z# ej$r�d dl%Z%d dl&m'Z' d dl&m(Z( d dl&m)Z) d
12 dl*m+Z+ G dd� 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>�Z6G d?d@� d@�Z7ej8e7d&dA�Z9ej:dBej;d-ej<f dC�Z=d�dDdE�Z>G dFdG� dGej?�Z@d�dIdJ�ZAej5dKdLgdMdNd&d=eAdO�ZBd�dQdR�ZCej5dSgdTd=eCdU�ZDd�dVdW�ZEej5dXdYgejFd&d=dZ�d[d&d=eEd\�ZGG d]d^� d^e@�ZHd�d`da�ZI &d�d�ddde�ZJd�dhdi�ZKG djdk� dkejL�ZMd�dldm�ZNG dndo� 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�Vd eD� 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[� dS dS )�� )�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 @ s e Zd ZdZdS )�NoAppExceptionz3Raised if an application cannot be found or loaded.N)�__name__�
18 __module__�__qualname__�__doc__� r r �?C:\Users\shubh\Videos\agent\nova\Lib\site-packages\flask/cli.pyr % s r �moduler �returnr c s* ddl m� dD ]}t| |d�}t|� �r| S q� fdd�| j�� D �}t|�dkr0|d S t|�dkrCtd| j� d | j� d
19 ���dD ]B}t| |d�}t �
20 |�r�z|� }t|� �r`|W S W qE ty� } zt|�sn� td|� d
21 | j� d| j� d|� d� �|�d}~ww qEtd| 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 )�appZapplicationNc s g | ] }t |� �r|�qS r )�
25 isinstance)�.0�vr r r �
26 <listcomp>7 s z!find_best_app.<locals>.<listcomp>r z0Detected 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�lenr r �inspect�
30 isfunction� TypeError�_called_with_wrong_args)r Z attr_namer �matchesZapp_factory�er r r �
31 find_best_app) s^
32 ����
33
34
35 �����������r. �f�t.Callable[..., Flask]�boolc C sF t �� d }z|dur|jj| ju rW ~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/ �tbr r r r+ ^ s ��
42 r+ �app_name�strc
43
44 C s� ddl m} ztj|�� dd�j}W n ty" td|�d��d�w t|tj �r1|j
45 }g }i }nDt|tj�rmt|jtj �sFtd|�d ���|jj
46 }zd
47 d� |j
48 D �}dd
49 � |jD �}W n tyl td|�d ��d�w td|�d���zt| |�}W n ty� } z
50 td|�d| j�d ��|�d}~ww t�|�r�z ||i |��} W n ty� } zt|�s�� td|�d| j�d��|�d}~ww |} t| |�r�| S td| 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: �.c S s g | ]}t �|��qS r )�ast�literal_eval)r �argr r r r � s z&find_app_by_string.<locals>.<listcomp>c S s&