o
    ê}”e„  ã                   @  s´  d dl mZ d dlZd dlZd dlZd dlZd dlZd dl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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 ejrmd	dl m!Z! G dd„ dej"ƒZ#dd„ Z$dd„ Z%dd„ Z&dd„ Z'd�dd„Z(dd„ Z)ej*dgdde)ddd �Z+G d!d"„ d"ƒZ,ej-e,dd#�Z.d$d%„ Z/G d&d'„ d'ej0ƒZ1d‘d/d0„Z2ej*d1d2gd3d4dde2d5�Z3d’d8d9„Z4ej*d:gd;de4d<�Z5d‘d=d>„Z6ej*d?d@gej7dddA�dBdde6dC�Z8G dDdE„ dEe1ƒZ9dFdG„ Z:d“d”dJdK„Z;dLdM„ Z<G dNdO„ dOej=ƒZ>dPdQ„ Z?G dRdS„ dSej7ƒZ@ejAdTdUdV�ejBdWdXdYdZd[�ejBd\d]d^d_d[�ejBd`e>ƒ daddb�ejBdcej7ddddd�e?ddedf�ejBdgddhd[�ejBdiddjd[�ejBdkddld[�ejBdmde@ƒ dnejCjD›do�dp�ejBdqde@ƒ drejCjD›do�dp�e.dsdt„ ƒƒƒƒƒƒƒƒƒƒƒZEeEjF Gd e5¡ ejAdudvdV�e/d•dxdy„ƒƒZHejAdzd{dV�ejBd|d}e Id~¡dd€d��ejBd‚ddƒd„�e/d–dˆd‰„ƒƒƒƒZJe9dŠd‹dŒ�ZKd•d�dŽ„ZLeMd�k�rØeLƒ  dS dS )—é    )ÚannotationsN)Úupdate_wrapper)Ú
itemgetter)ÚParameterSource)Ú
run_simple)Úis_running_from_reloader)Úimport_stringé   )Úcurrent_app)Úget_debug_flag)Úget_load_dotenv©ÚFlaskc                   @  s   e Zd ZdZdS )ÚNoAppExceptionz3Raised if an application cannot be found or loaded.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   úR/Users/abhinavbhinder/Documents/map/venv/lib/python3.10/site-packages/flask/cli.pyr      s    r   c                   s*  ddl m‰  dD ]}t| |dƒ}t|ˆ ƒr|  S q‡ fdd„| j ¡ D ƒ}t|ƒdkr0|d S t|ƒdkrCtd| j› d	| j› d
�ƒ‚dD ]B}t| |dƒ}t	 
|¡r‡z|ƒ }t|ˆ ƒr`|W   S W qE ty† } zt|ƒsn‚ td|› d| j› d| j› d|› d�	ƒ|‚d}~ww qEtd| 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   )ÚappZapplicationNc                   s   g | ]	}t |ˆ ƒr|‘qS r   )Ú
isinstance)Ú.0Úvr   r   r   Ú
<listcomp>/   s    z!find_best_app.<locals>.<listcomp>r   z0Detected multiple Flask applications in module 'z'. Use 'z":name' to specify the correct one.)Ú
create_appZmake_appzDetected 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Úlenr   r   ÚinspectÚ
isfunctionÚ	TypeErrorÚ_called_with_wrong_args)ÚmoduleÚ	attr_namer   ÚmatchesZapp_factoryÚer   r   r   Úfind_best_app!   s^   
ÿÿÿÿ


ÿþþÿû€üúÿÿÿr*   c                 C  sF   t  ¡ d }z|dur|jj| ju rW ~dS |j}|dusW ~dS ~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Útbr   r   r   r%   V   s   	ùû
r%   c           
   
   C  s°  ddl m} ztj| ¡ dd�j}W n ty"   td|›d�ƒd‚w t|tj	ƒr1|j
}g }i }nDt|tjƒrmt|jtj	ƒsFtd|›d	�ƒ‚|jj
}zd
d„ |jD ƒ}dd„ |jD ƒ}W n tyl   td|›d	�ƒd‚w td|›d�ƒ‚zt| |ƒ}W n ty• } ztd|›d| j›d	�ƒ|‚d}~ww t |¡rÃz	||i |¤Ž}	W n  tyÂ } zt|ƒs±‚ td|›d| j›d�ƒ|‚d}~ww |}	t|	|ƒrÌ|	S td| 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)ÚmodezFailed to parse z' as an attribute name or function call.Nz*Function reference must be a simple name: Ú.c                 S  s   g | ]}t  |¡‘qS r   )ÚastÚliteral_eval)r   Úargr   r   r   r   Ž   s    z&find_app_by_string.<locals>.<listcomp>c                 S  s   i | ]
}|j t |j¡“qS r   )r9   r7   r8   Úvalue)r   Úkwr   r   r   Ú
<dictcomp>�   s    z&find_app_by_string.<locals>.<dictcomp>z-Failed to parse arguments as literal values: zFailed 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   r   r7   ÚparseÚstripÚbodyÚSyntaxErrorr   r   ÚNameÚidÚCallÚfuncÚargsÚkeywordsÚ
ValueErrorr   ÚAttributeErrorr   r"   r#   r$   r%   )
r&   Úapp_namer   ÚexprÚnamerE   ÚkwargsÚattrr)   r   r   r   r   Úfind_app_by_stringp   sˆ   
ÿþÿ
ÿ
ÿþý
ÿÿþ€ÿ
ÿÿü€ü

ÿÿÿrN   c                 C  s®   t j | ¡} t j | ¡\}}|dkr|} t j | ¡dkr"t j | ¡} g }	 t j | ¡\} }| |¡ t j t j 	| d¡¡s>nq%t
jd | krMt
j d| ¡ d 	|ddd… ¡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__.pyr   r6   Néÿÿÿÿ)ÚosÚpathÚrealpathÚsplitextÚbasenameÚdirnameÚsplitÚappendÚexistsÚjoinr,   Úinsert)rR   ÚfnameÚextÚmodule_namerK   r   r   r   Úprepare_import¼   s    
ûr_   Tc              	   C  s„   zt | ƒ W n) ty/   t ¡ d jr!td| ›dt ¡ › �ƒd ‚|r,td| ›d�ƒd ‚Y d S w tj|  }|d u r=t	|ƒS t
||ƒS )Nr+   zWhile importing z, an ImportError was raised:

zCould not import r6   )Ú
__import__ÚImportErrorr,   r-   r1   r   Ú	tracebackÚ
format_excÚmodulesr*   rN   )r^   rI   Úraise_if_not_foundr&   r   r   r   Ú
locate_appÙ   s&   ÿÿýõ

rf   c                 C  sX   |r| j rd S tj d¡}tj d¡}tjdt ¡ › d|› d|› �| jd� |  	¡  d S )NÚflaskÚwerkzeugúPython z
Flask z

Werkzeug )Úcolor)
Zresilient_parsingÚ	importlibÚmetadataÚversionÚclickÚechoÚplatformÚpython_versionrj   Úexit)ÚctxÚparamr:   Zflask_versionZwerkzeug_versionr   r   r   Úget_versionñ   s   
ÿþüru   z	--versionzShow the Flask version.F)ÚhelpÚexpose_valueÚcallbackÚis_flagÚis_eagerc                   @  s,   e Zd ZdZ			dddd„Zddd„ZdS )Ú
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ÚNonec                 C  s"   || _ || _i | _|| _d | _d S ©N)r|   r   Údatar   Ú_loaded_app)Úselfr|   r   r   r   r   r   rO     s
   
zScriptInfo.__init__r   c                 C  s®   | j dur| j S | jdur|  ¡ }n3| jr1tjd| jdd�dg dd… \}}t|ƒ}t||ƒ}ndD ]}t|ƒ}t|ddd�}|rD nq3|sKtd	ƒ‚| jrRt	ƒ |_
|| _ |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+   )zwsgi.pyzapp.pyF)re   zŸ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|   ÚrerW   r_   rf   r   r   r   Údebug)r†   r   rR   rK   Úimport_namer   r   r   Úload_app%  s0   


þÿÿzScriptInfo.load_app)NNT)r|   r}   r   r~   r   r€   r�   r‚   )r�   r   )r   r   r   r   rO   r‹   r   r   r   r   r{     s    
ür{   )Zensurec                   s   t j‡ fdd„ƒ}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.
    c                   s8   t s|  t¡ ¡ }|  | ¡ ¡ | jˆ g|¢R i |¤ŽS rƒ   )r
   Úensure_objectr{   r‹   Úwith_resourceÚapp_contextZinvoke)Z__ctxrE   rL   r   ©r2   r   r   Ú	decorator`  s   z"with_appcontext.<locals>.decorator)rn   Zpass_contextr   )r2   r�   r   r�   r   Úwith_appcontextR  s   
r‘   c                   @  s    e Zd ZdZdd„ Zdd„ ZdS )ÚAppGroupa   This 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`.
    c                   s"   ˆ  dd¡‰‡ ‡‡‡fdd„}|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‘   Tc                   s*   ˆrt | ƒ} tjjˆgˆ ¢R i ˆ¤Ž| ƒS rƒ   )r‘   rn   ÚGroupÚcommandr�   ©rE   rL   r†   Zwrap_for_ctxr   r   r�   z  s   z#AppGroup.command.<locals>.decorator)Úpop)r†   rE   rL   r�   r   r•   r   r”   s  s   zAppGroup.commandc                 O  s&   |  dt¡ tjj| g|¢R i |¤Ž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’   rn   r“   Úgroup)r†   rE   rL   r   r   r   r™   �  s   zAppGroup.groupN)r   r   r   r   r”   r™   r   r   r   r   r’   k  s    r’   rs   úclick.Contextrt   úclick.Optionr:   r}   r�   c                 C  s    |d u rd S |   t¡}||_|S rƒ   )rŒ   r{   r|   )rs   rt   r:   Úinfor   r   r   Ú_set_appŠ  s
   
r�   z-Az--appZ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.)Úmetavarrv   rz   rw   rx   r€   úbool | Nonec                 C  s>   |   |j¡}|d ur|tjtjfv rd S |rdndtjd< |S )NÚ1Ú0ZFLASK_DEBUG)Zget_parameter_sourcerK   r   ÚDEFAULTZDEFAULT_MAPrQ   Úenviron)rs   rt   r:   Úsourcer   r   r   Ú
_set_debug¦  s   
þr¥   z--debug/--no-debugzSet debug mode.)rv   rw   rx   c                 C  sP   |d u rd S dd l }z| d¡ W n ty!   tjd| |d�d ‚w t|ƒ |S )Nr   Údotenvz4python-dotenv must be installed to load an env file.)rs   rt   )rk   Úimport_modulera   rn   ÚBadParameterÚload_dotenv)rs   rt   r:   rk   r   r   r   Ú_env_file_callback¿  s    ýüÿ	rª   z-ez
--env-file)rY   Údir_okayzKLoad environment variables from this file. python-dotenv must be installed.)Útyperv   rz   rw   rx   c                      sn   e Zd ZdZ					d#d$‡ fdd„Zdd„ Z‡ fdd„Z‡ fdd„Z	d%d&‡ fdd„Zd'‡ fd!d"„Z	‡  Z
S )(Ú
FlaskGroupa0  Special 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€   r   r~   Úadd_version_optionr©   r   Úextraút.Anyr�   r‚   c                   s¦   t | dd ¡pdƒ}| tttf¡ |r| t¡ d|vr!i |d< |d  dd¡ t	ƒ j
dd|i|¤Ž || _|| _|| _|rN|  t¡ |  t¡ |  t¡ d| _d S )NÚparamsr   Úcontext_settingsZauto_envvar_prefixZFLASKF)Úlistr–   ÚextendÚ_env_file_optionÚ_app_optionÚ_debug_optionrX   Úversion_optionr˜   ÚsuperrO   r   r©   r   Úadd_commandÚrun_commandÚshell_commandÚroutes_commandÚ_loaded_plugin_commands)r†   r®   r   r¯   r©   r   r°   r²   ©Ú	__class__r   r   rO   ÿ  s    	




zFlaskGroup.__init__c                 C  sX   | j rd S tjdkrddlm} ndd l}|jdd�D ]}|  | ¡ |j	¡ qd| _ d S )N)é   é
   r   )rl   zflask.commands)r™   T)
r¿   r,   Úversion_infork   rl   Zimportlib_metadataZentry_pointsr»   ÚloadrK   )r†   rl   Úepr   r   r   Ú_load_plugin_commands$  s   

z FlaskGroup._load_plugin_commandsc              
     s¨   |   ¡  tƒ  ||¡}|d ur|S | t¡}z| ¡ }W n! ty= } ztjd| 	¡ › d�ddd� W Y d }~d S d }~ww t
rFt
 ¡ |urM| | ¡ ¡ |j ||¡S ©NzError: Ú
TÚred)ÚerrÚfg)rÇ   rº   Úget_commandrŒ   r{   r‹   r   rn   ÚsechoÚformat_messager
   Z_get_current_objectr�   rŽ   Úcli)r†   rs   rK   Úrvrœ   r   r)   rÀ   r   r   rÍ   5  s   
€þzFlaskGroup.get_commandc              
     sº   |   ¡  ttƒ  |¡ƒ}| t¡}z| | ¡ j |¡¡ W t|ƒS  t	yD } zt
jd| ¡ › d�ddd� W Y d }~t|ƒS d }~w ty\   t
jt ¡ › d�ddd� Y t|ƒS w rÈ   )rÇ   Úsetrº   Úlist_commandsrŒ   r{   Úupdater‹   rÐ   r   rn   rÎ   rÏ   Ú	Exceptionrb   rc   Úsorted)r†   rs   rÑ   rœ   r)   rÀ   r   r   rÓ   P  s   

÷&€ûûzFlaskGroup.list_commandsÚ	info_namer}   rE   ú	list[str]Úparentúclick.Context | Nonerš   c                   sZ   dt jd< t| jƒrtƒ  d|vr d| jvr t| j| jd�|d< tƒ j	||fd|i|¤ŽS )NÚtrueZFLASK_RUN_FROM_CLIÚobj)r   r   rÙ   )
rQ   r£   r   r©   r³   r{   r   r   rº   Úmake_context)r†   r×   rE   rÙ   r°   rÀ   r   r   rÝ   e  s   



ÿzFlaskGroup.make_contextrs   c                   s4   |s| j rt |i g ¡ t |i g ¡ tƒ  ||¡S rƒ   )Zno_args_is_helpr¶   Zhandle_parse_resultr·   rº   Ú
parse_args)r†   rs   rE   rÀ   r   r   rÞ   }  s   
zFlaskGroup.parse_args)TNTTT)r®   r€   r   r~   r¯   r€   r©   r€   r   r€   r°   r±   r�   r‚   rƒ   )
r×   r}   rE   rØ   rÙ   rÚ   r°   r±   r�   rš   )rs   rš   rE   rØ   r�   rØ   )r   r   r   r   rO   rÇ   rÍ   rÓ   rÝ   rÞ   Ú__classcell__r   r   rÀ   r   r­   â  s    ú%ür­   c                 C  s&   t j | |t| ƒd…  t j¡¡|kS )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)rQ   rR   rZ   r!   ÚlstripÚsep)rR   Úotherr   r   r   Ú_path_is_ancestorˆ  s   &rã   rR   ústr | os.PathLike | Nonec                 C  s¬   zddl }W n  ty&   | stj d¡stj d¡r#tjdddd� Y d	S w | dur:tj | ¡r8|j| d
d�S d	S d	}dD ]}|j|dd�} | 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
    r   Nú.envú	.flaskenvz^ * Tip: There are .env or .flaskenv files present. Do "pip install python-dotenv" to use them.ÚyellowT)rÌ   rË   Fzutf-8)Úencoding)rå   ræ   )Zusecwd)	r¦   ra   rQ   rR   Úisfilern   rÎ   r©   Zfind_dotenv)rR   r¦   ZloadedrK   r   r   r   r©   �  s.   ü÷r©   c                 C  sL   t ƒ rdS |durt d|› d�¡ | dur$t d| rdnd› �¡ dS dS )z]Show extra startup messages the first time the server is run,
    ignoring the reloader.
    Nz * Serving Flask app 'ú'z * Debug mode: ÚonÚoff)r   rn   ro   )r‰   r|   r   r   r   Úshow_server_bannerÌ  s   ÿrí   c                   @  s$   e Zd ZdZdZdd„ Zdd„ ZdS )Ú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.
    rR   c                 C  s   t jdddd�| _d S )NTF©rY   r«   Zresolve_path)rn   ÚPathÚ	path_type)r†   r   r   r   rO   â  s   zCertParamType.__init__c                 C  s¼   zdd l }W n ty   t d||¡d ‚w z|  |||¡W S  tjy]   t |||¡ ¡ }|dkrLz	dd l}W | Y S  tyK   t d||¡d ‚w t|dd�}t	||j
ƒr\| Y S ‚ w )Nr   z?Using "--cert" requires Python to be compiled with SSL support.Úadhocz<Using ad-hoc certificates requires the cryptography library.T)Zsilent)Ússlra   rn   r¨   rñ   ÚSTRINGÚlowerÚcryptographyr   r   Ú
SSLContext)r†   r:   rt   rs   ró   rö   rÜ   r   r   r   Úconvertå  sB   ýüÿ
ùýüÿ	ìzCertParamType.convertN)r   r   r   r   rK   rO   rø   r   r   r   r   rî   Ú  s
    rî   c                 C  s²   | j  d¡}|dk}zddl}W n ty   d}Y nw t||jƒ}|durJ|r/t d| |¡‚|r8t d| |¡‚|sAt d| |¡‚||f| j d< |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ò   r   NFz.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.zRequired when using "--cert".)r²   Úgetró   ra   r   r÷   rn   r¨   )rs   rt   r:   rù   Zis_adhocró   Z
is_contextr   r   r   Ú_validate_key  s0   ÿÿÿýrû   c                      s    e Zd ZdZ‡ fdd„Z‡  ZS )Ú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.
    c                   s(   |   |¡}tƒ j‰‡ ‡‡fdd„|D ƒS )Nc                   s   g | ]}ˆ|ˆˆ ƒ‘qS r   r   )r   Úitem©rs   rt   Zsuper_convertr   r   r   6  s    z-SeparatedPathType.convert.<locals>.<listcomp>)Zsplit_envvar_valuerº   rø   )r†   r:   rt   rs   ÚitemsrÀ   rþ   r   rø   3  s   
zSeparatedPathType.convert)r   r   r   r   rø   rß   r   r   rÀ   r   rü   -  s    rü   ÚrunzRun a development server.)Z
short_helpz--hostz-hz	127.0.0.1zThe interface to bind to.)Údefaultrv   z--portz-piˆ  zThe port to bind to.z--certz(Specify a certificate file to use HTTPS.)r¬   rv   rz   z--keyrï   z2The key file to use when specifying a certificate.)r¬   rx   rw   rv   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 r6   )r  r¬   rv   z--exclude-patternsznFiles matching these fnmatch patterns will not trigger a reload on change. Multiple patterns are separated by c	                   s    z|   ¡ }	W n% ty+ }
 ztƒ rt ¡  |
‰ ‡ fdd„}	n|
d‚W Y d}
~
nd}
~
ww tƒ }|du r5|}|du r;|}t|| jƒ t|||	||||||d�	 dS )a  Run 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.
    c                   s   ˆ d ‚rƒ   r   )r£   Zstart_response©rË   r   r   r   Š  s   zrun_command.<locals>.appN)Zuse_reloaderZuse_debuggerZthreadedÚssl_contextÚextra_filesÚexclude_patterns)	r‹   rÕ   r   rb   Ú	print_excr   rí   r|   r   )rœ   ÚhostÚportÚreloadZdebuggerZwith_threadsrù   r  r  r   r)   r‰   r   r  r   r¼   9  s8   Hú€ù
÷r¼   ÚshellzRun a shell in the app context.r‚   c                  C  s   ddl } dtj› dtj› dtj› dtj› �}i }tj 	d¡}|rEtj
 |¡rEt|ƒ�}tt| ¡ |dƒ|ƒ W d  ƒ n1 s@w   Y  | t ¡ ¡ ttd	dƒ}|durwzddl}dd
lm} W n	 tyk   Y n	w | ||ƒj¡ |ƒ  | j||d� dS )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.
    r   Nri   z on z
App: z
Instance: ZPYTHONSTARTUPÚexecÚ__interactivehook__)Ú	Completer)ÚbannerÚlocal)Úcoder,   rm   rp   r
   rŠ   Zinstance_pathrQ   r£   rú   rR   ré   Úopenr4   ÚcompileÚreadrÔ   Zmake_shell_contextr   ÚreadlineÚrlcompleterr  ra   Zset_completerZcompleteZinteract)r  r  rs   Zstartupr2   Zinteractive_hookr  r  r   r   r   r½   ¬  s2   
ÿþÿ
ÿÿr½   ZrouteszShow the routes for the app.z--sortz-s)ÚendpointÚmethodsÚdomainÚruleÚmatchr  zgMethod to sort routes by. 'match' is the order that Flask will match routes when dispatching a request.)r¬   r  rv   z--all-methodszShow HEAD and OPTIONS methods.)ry   rv   ÚsortÚstrÚall_methodsc                   s–  t tj ¡ ƒ}|st d¡ dS |rtƒ nddh}tjj‰ t‡ fdd„|D ƒƒ}g ‰|D ],}|j	d 
t|jp8tƒ | ƒ¡g}|rM| ˆ rG|jn|jpKd¡ | |j¡ ˆ |¡ q,d	d
g}ddg}|rq| ˆ ridnd¡ | d¡ | d¡ | d¡ zˆjt| | ¡ƒd� W n	 ty‘   Y nw ˆ d|¡ ‡fdd„tt|ƒƒD ƒ}	ˆ ddd„ |	D ƒ¡ d 
dd„ t|	ƒD ƒ¡}
ˆD ]
}t |
j|Ž ¡ q¾dS )z6Show all registered routes with endpoints and methods.zNo routes were registered.NÚHEADÚOPTIONSc                 3  s    � | ]}ˆ r	|j n|jV  qd S rƒ   )r  Ú	subdomain)r   r  )Úhost_matchingr   r   Ú	<genexpr>ô  s   € z!routes_command.<locals>.<genexpr>z, r   ZEndpointZMethodsr  r  ÚHostZ	Subdomainr  ZRuler  )Úkeyr   c                   s"   g | ]‰ t ‡ fd d„ˆD ƒƒ‘qS )c                 3  s   � | ]	}t |ˆ  ƒV  qd S rƒ   )r!   )r   Úrow©Úir   r   r"    s   € z,routes_command.<locals>.<listcomp>.<genexpr>)Úmax)r   )Úrowsr&  r   r     s   " z"routes_command.<locals>.<listcomp>r	   c                 S  s   g | ]}d | ‘qS )ú-r   )r   Úwr   r   r   r     s    z  c                 s  s&   � | ]\}}d |› d|› d�V  qdS )Ú{z:<Ú}Nr   )r   r'  r+  r   r   r   r"    s   €$ )r´   r
   Zurl_mapZ
iter_rulesrn   ro   rÒ   r!  Úanyr  rZ   rÖ   r  rX   r  r   r  r  r   ÚindexrG   r[   Úranger!   Ú	enumerateÚformat)r  r  ÚrulesZignored_methodsZ
has_domainr  r%  ÚheadersZsortsZwidthsÚtemplater   )r!  r)  r   r¾   Ý  sF   
þ


ÿÿr¾   rg   zÑ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.
)rK   rv   c                   C  s   t  ¡  d S rƒ   )rÐ   Úmainr   r   r   r   r6  '  s   r6  Ú__main__)T)rs   rš   rt   r›   r:   r}   r�   r}   )rs   rš   rt   r›   r:   r€   r�   rŸ   rƒ   )rR   rä   r�   r€   )r�   r‚   )r  r  r  r€   r�   r‚   )NÚ
__future__r   r7   Úimportlib.metadatark   r"   rQ   rp   rˆ   r,   rb   ÚtypingÚtÚ	functoolsr   Úoperatorr   rn   Z
click.corer   rh   r   Zwerkzeug.servingr   Zwerkzeug.utilsr   Úglobalsr
   Zhelpersr   r   ÚTYPE_CHECKINGr   r   Z
UsageErrorr   r*   r%   rN   r_   rf   ru   ÚOptionr¹   r{   Zmake_pass_decoratorZpass_script_infor‘   r“   r’   r�   r·   r¥   r¸   rª   rð   r¶   r­   rã   r©   rí   Z	ParamTyperî   rû   rü   r”   ÚoptionrR   Úpathsepr¼   r²   r[   r½   ZChoicer¾   rÐ   r6  r   r   r   r   r   Ú<module>   s$   5L
ú
D
õ
ü
ú
 '=.%üûýýýÿû	þû
;/ú
1þ


ÿ