
_;y              "   @   s  d  Z  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
 m Z d d l m 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 d	 d l m Z d	 d l m Z y d d l Z Wn e  k
 rpd Z Yn Xy d d l! Z! Wn e  k
 rd Z! Yn XGd d   d e j"  Z# d d   Z$ f  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% d& d' d( e* d) d d* d Z, Gd+ d,   d, e-  Z. Gd- d.   d. e-  Z/ e j0 e/ d/ d Z1 d0 d1   Z2 Gd2 d3   d3 e j3  Z4 Gd4 d5   d5 e4  Z5 d6 d7   Z6 d d8 d9  Z7 d: d;   Z8 Gd< d=   d= e j9  Z: d> d?   Z; Gd@ dA   dA e j<  Z= e j> dB dC dD e j? dE dF dG dH d$ dI e j? dJ dK dG dL d$ dM e j? dN dO e:   d$ dP e j? dQ dO e j< dR d dS d' dT d  d( e; d& d' d$ dU e j? dV dG d d$ dW e j? dX dG d d$ dY e j? dZ dG d d$ d[ e j? d\ dG d d$ d] e j? d^ dG d dO e=   d$ d_ j@ e jA jB  e1 d` da              ZC e j> db dC dc e2 dd de     ZD e j> df dC dg e j? dh di dO e jE d  dG dj d$ dn e j? do d) d d$ dp e2 dq dr       ZF e5 d$ ds j@ dt e jG du k r9dv n dw dx e jG du k rTdy n dz   ZH d' d{ d|  ZI eJ d} k reI d~ d  d S)z
    flask.cli
    ~~~~~~~~~

    A simple command line application to run flask apps.

    :copyright: 2010 Pallets
    :license: BSD-3-Clause
    )print_functionN)update_wrapper)
attrgetter)Lock)Thread)import_string   )
getargspec)
itervalues)reraise)	text_type)current_app)get_debug_flag)get_env)get_load_dotenvc               @   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   */tmp/pip-build-5gj8f0j9/flask/flask/cli.pyr   0   s   r   c                sk  d d l  m   x3 d D]+ } t | | d  } t |    r | Sq W  f d d   t | j  D } t |  d k r | d St |  d k r t d	 j d
 | j	    x d D] } t | | d  } t
 j |  r y& t |  |  } t |    r| SWq t k
 rGt |  s"  t d j d | d
 | j	    Yq Xq Wt d j d
 | j	    d S)zwGiven a module instance this tries to find the best possible
    application in the module or raises an exception.
    r   )FlaskappapplicationNc                s%   g  |  ] } t  |    r |  q Sr   )
isinstance).0v)r   r   r   
<listcomp>B   s   	 z!find_best_app.<locals>.<listcomp>r   ztDetected multiple Flask applications in module "{module}". Use "FLASK_APP={module}:name" to specify the correct one.module
create_appmake_appzDetected factory "{factory}" in module "{module}", but could not call it without arguments. Use "FLASK_APP='{module}:{factory}(args)'" to specify arguments.factoryznFailed to find Flask application or factory in module "{module}". Use "FLASK_APP={module}:name to specify one.)r   r   )r    r!   ) r   getattrr   r
   __dict__lenr   formatr   inspect
isfunctioncall_factory	TypeError_called_with_wrong_args)script_infor   	attr_namer   matchesapp_factoryr   )r   r   find_best_app4   s8    "			r1   c             C   s   t  |  } | j } | j } d | k r: | | d |   S| rJ | |   S| ry t |  d k ry | d k ry | |   S|   S)zTakes an app factory, a ``script_info` object and  optionally a tuple
    of arguments. Checks for the existence of a script_info argument and calls
    the app_factory depending on that and the arguments provided.
    r-   r   N)r	   argsdefaultsr&   )r-   r0   Z	argumentsZ	args_specZ	arg_namesZarg_defaultsr   r   r   r*   g   s    		
%
r*   c          	   C   sX   t  j   d } z= x2 | d k	 rG | j j |  j k r; d S| j } q Wd SWd ~ Xd S)zCheck whether calling a function raised a ``TypeError`` because
    the call failed or because something in the factory raised the
    error.

    :param factory: the factory function that was called
    :return: true if the call failed
       NFT)sysexc_infotb_framef_code__code__tb_next)r"   tbr   r   r   r,   z   s    r,   c       
   0   C   s  d d l  m } t j d |  } | s@ t d j d |    | j   \ } } y t | |  } Wn8 t k
 r } z t | j	 d   WYd d } ~ Xn Xt
 j |  r| r#y t j d j d	 |   } Wq)t t f k
 r} z# t d
 j d | d |    WYd d } ~ Xq)Xn f  } y t |  | |  }	 Wqt k
 r} z; t |  sc  t d j d | d | d | j    WYd d } ~ XqXn | }	 t |	 |  r|	 St d j d | j d |    d S)zChecks if the given string is a variable name or a function. If it is a
    function, it checks for specified arguments and whether it takes a
    ``script_info`` argument and calls the function with the appropriate
    arguments.
    r   )r   z%^ *([^ ()]+) *(?:\((.*?) *,? *\))? *$z="{name}" is not a valid variable name or function expression.namer   Nz	({args},)r2   z.Could not parse the arguments in "{app_name}".eapp_namezc{e}
The factory "{app_name}" in module "{module}" could not be called with the specified arguments.r   zFA valid Flask application was not obtained from "{module}:{app_name}".)r#   r   rematchr   r'   groupsr$   AttributeErrorr2   r(   r)   astZliteral_eval
ValueErrorSyntaxErrorr*   r+   r,   r   r   )
r-   r   r>   r   r@   r<   r2   attrr=   r   r   r   r   find_app_by_string   sD    	&	(	1	rG   c             C   s   t  j j |   }  t  j j |   \ } } | d k r< | }  t  j j |   d k rf t  j j |   }  g  } xK t  j j |   \ }  } | j |  t  j j t  j j	 |  d   so Pqo Wt
 j d |  k r t
 j j d |   d j	 | d d d   S)	zGiven 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__z__init__.pyr   .Nr   )ospathrealpathsplitextbasenamedirnamesplitappendexistsjoinr5   insert)rL   fnameextmodule_namer<   r   r   r   prepare_import   s    !rY   Tc             C   s   d } y t  |  Wnq t k
 r t j   d j r^ t d j d | d t j      n% | r t d j d |    n d  SYn Xt j	 | } | d  k r t
 |  |  St |  | |  Sd  S)NTr   z:While importing "{name}", an ImportError was raised:

{tb}r<   r;   zCould not import "{name}".rJ   )
__import__ImportErrorr5   r6   r:   r   r'   	traceback
format_excmodulesr1   rG   )r-   rX   r>   raise_if_not_found__traceback_hide__r   r   r   r   
locate_app   s    		ra   c             C   sy   | s |  j  r d  Sd d  l } d d l m } d } t j | d t j   d | d | j i d |  j |  j	   d  S)	Nr   r   )__version__z7Python %(python)s
Flask %(flask)s
Werkzeug %(werkzeug)spythonZflaskwerkzeugcolor)
Zresilient_parsingrd   r#   rb   clickechoplatformpython_versionre   exit)ctxparamvaluerd   rb   messager   r   r   get_version  s    
ro   z	--versionhelpzShow the flask versionZexpose_valueFcallbackZis_flagZis_eagerc               @   sU   e  Z d  Z d Z d d d  Z d d   Z d d   Z d	 d
   Z d d   Z d S)DispatchingAppa  Special application that dispatches to a Flask application which
    is imported by name in a background thread.  If an error happens
    it is recorded and shown as part of the WSGI handling which in case
    of the Werkzeug debugger means that it shows up in the browser.
    Fc             C   sH   | |  _  d  |  _ t   |  _ d  |  _ | r: |  j   n
 |  j   d  S)N)loader_appr   _lock_bg_loading_exc_info_load_unlocked_load_in_background)selfrs   use_eager_loadingr   r   r   rH   +  s    			zDispatchingApp.__init__c                s5     f d d   } t  d | d f   } | j   d  S)Nc                 sM   d }    j  7 y   j   Wn! t k
 rA t j     _ Yn XWd  QRXd  S)NT)ru   rw   	Exceptionr5   r6   rv   )r`   )ry   r   r   	_load_app6  s    
z5DispatchingApp._load_in_background.<locals>._load_apptargetr2   )r   start)ry   r|   tr   )ry   r   rx   5  s    z"DispatchingApp._load_in_backgroundc             C   s2   d } |  j  } | d  k	 r. d  |  _  t |   d  S)NT)rv   r   )ry   r`   r6   r   r   r   _flush_bg_loading_exceptionA  s
    		z*DispatchingApp._flush_bg_loading_exceptionc             C   s&   d } |  j    |  _ } d  |  _ | S)NT)rs   rt   rv   )ry   r`   rvr   r   r   rw   H  s    	zDispatchingApp._load_unlockedc          
   C   sx   d } |  j  d  k	 r% |  j  | |  S|  j   |  j 9 |  j  d  k	 rT |  j  } n |  j   } | | |  SWd  QRXd  S)NT)rt   r   ru   rw   )ry   environZstart_responser`   r   r   r   r   __call__N  s    

zDispatchingApp.__call__N)	r   r   r   r   rH   rx   r   rw   r   r   r   r   r   rr   $  s   
rr   c               @   s7   e  Z d  Z d Z d d d d d  Z 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.
    NTc             C   sC   | p t  j j d  |  _ | |  _ i  |  _ | |  _ d  |  _ d  S)NZ	FLASK_APP)rK   r   getapp_import_pathr    dataset_debug_flag_loaded_app)ry   r   r    r   r   r   r   rH   d  s
    			zScriptInfo.__init__c             C   s  d } |  j  d k	 r |  j  Sd } |  j d k	 rF t |  |  j  } n |  j r t j d |  j d  d g d d  \ } } t |  } t |  | |  } n< x9 d D]1 } t |  } t |  | d d d	 } | r Pq W| s t d
   |  j	 rt
   | _ | |  _  | S)zLoads 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.
        TNz
:(?![\\/])r   r4   wsgi.pyapp.pyr_   FzCould not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory.)r   r   )r   r    r*   r   r?   rQ   rY   ra   r   r   r   debug)ry   r`   r   rL   r<   import_namer   r   r   load_appp  s.    				zScriptInfo.load_app)r   r   r   r   rH   r   r   r   r   r   r   [  s   r   Zensurec                s(   t  j   f d d    } t |    S)zWraps a callback so that it's guaranteed to be executed with the
    script's application context.  If callbacks are registered directly
    to the ``app.cli`` object then they are wrapped with this function
    by default unless it's disabled.
    c                s:   |  j  t  j   j    |  j   | |  SWd  QRXd  S)N)ensure_objectr   r   Zapp_contextZinvoke)Z__ctxr2   kwargs)fr   r   	decorator  s    z"with_appcontext.<locals>.decorator)rf   Zpass_contextr   )r   r   r   )r   r   with_appcontext  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                s1    j  d d        f d d   } | S)zThis 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      |   S)N)r   rf   Groupcommand)r   )r2   r   ry   wrap_for_ctxr   r   r     s    z#AppGroup.command.<locals>.decorator)pop)ry   r2   r   r   r   )r2   r   ry   r   r   r     s    zAppGroup.commandc             O   s&   | j  d t  t j j |  | |  S)zThis 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   rf   r   group)ry   r2   r   r   r   r   r     s    zAppGroup.groupN)r   r   r   r   r   r   r   r   r   r   r     s   r   c                   sg   e  Z d  Z d Z d d d d d d d  Z d d   Z d d	   Z d
 d   Z   f d d   Z   S)
FlaskGroupaj  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.

    For information as of why this is useful 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 based on the active
        environment

    .. versionchanged:: 1.0
        If installed, python-dotenv will be used to load environment variables
        from :file:`.env` and :file:`.flaskenv` files.
    TNc             K   s   t  | j d d   p f   } | r1 | j t  t j |  d | | | |  _ | |  _ | |  _ | r |  j	 t
  |  j	 t  |  j	 t  d |  _ d  S)NparamsF)listr   rR   version_optionr   rH   r    load_dotenvr   add_commandrun_commandshell_commandroutes_command_loaded_plugin_commands)ry   Zadd_default_commandsr    Zadd_version_optionr   r   extrar   r   r   r   rH     s    				zFlaskGroup.__init__c             C   s   |  j  r d  Sy d d  l } Wn t k
 r> d |  _  d  SYn Xx0 | j d  D] } |  j | j   | j  qO Wd |  _  d  S)Nr   Tzflask.commands)r   pkg_resourcesr[   iter_entry_pointsr   loadr<   )ry   r   epr   r   r   _load_plugin_commands  s    			z FlaskGroup._load_plugin_commandsc             C   s   |  j    t j |  | |  } | d  k	 r/ | S| j t  } y/ | j   j j | |  } | d  k	 rl | SWn t k
 r Yn Xd  S)N)r   r   get_commandr   r   r   clir   )ry   rk   r<   r   infor   r   r   r     s    
	zFlaskGroup.get_commandc             C   s   |  j    t t j j |  |   } | j t  } y# | j | j   j	 j |   Wn t
 k
 ru t j   Yn Xt |  S)N)r   setrf   r   list_commandsr   r   updater   r   r{   r\   	print_excsorted)ry   rk   r   r   r   r   r   r   $  s    
#zFlaskGroup.list_commandsc                s   d t  j d <t |  j  r# t   | j d  } | d  k rY t d |  j d |  j  } | | d <| j d d  t	 t
 |   j | |   S)NtrueZFLASK_RUN_FROM_CLIobjr    r   Zauto_envvar_prefixZFLASK)rK   r   r   r   r   r   r    r   r   superr   main)ry   r2   r   r   )	__class__r   r   r   7  s    
zFlaskGroup.main)	r   r   r   r   rH   r   r   r   r   r   r   )r   r   r     s   r   c             C   s5   t  j j |  | t |   d  j t  j   | k S)zTake ``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)rK   rL   rT   r&   lstripsep)rL   otherr   r   r   _path_is_ancestorM  s    r   c             C   s  t  d k rS |  s6 t j j d  s6 t j j d  rO t j d d d d d d	 S|  d k	 r t j j |   r~ t  j |   Sd	 Sd } xW d D]O } t  j | d
 d }  |  s q | d k r t j j |   } t  j |   q W| rt j	   | k rt j
 |  | d k	 S)aH  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.

    Changes the current working directory to the location of the first file
    found, with the assumption that it is in the top level project directory
    and will be where the Python path should import local packages from.

    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:: 1.1.0
        Returns ``False`` when python-dotenv is not installed, or when
        the given path isn't a file.

    .. versionadded:: 1.0
    N.env	.flaskenvz^ * Tip: There are .env or .flaskenv files present. Do "pip install python-dotenv" to use them.fgZyellowerrTFZusecwd)r   r   )dotenvrK   rL   isfilerf   sechor   Zfind_dotenvrP   getcwdchdir)rL   Znew_dirr<   r   r   r   r   T  s,    *r   c             C   s   t  j j d  d k r d S| d k	 rT d j |  } | sG | d 7} t j |  t j d j |    |  d k r t j d d	 d
 t j d d d | d k	 r t j d j | r d n d   d S)z]Show extra startup messages the first time the server is run,
    ignoring the reloader.
    ZWERKZEUG_RUN_MAINr   Nz * Serving Flask app "{0}"z (lazy loading)z * Environment: {0}
productionzS   WARNING: This is a development server. Do not use it in a production deployment.r   Zredz(   Use a production WSGI server instead.ZdimTz * Debug mode: {0}onoff)rK   r   r   r'   rf   rg   r   )envr   r   eager_loadingrn   r   r   r   show_server_banner  s    
r   c               @   s4   e  Z d  Z d Z d Z d d   Z d d   Z d S)CertParamTypezClick option type for the ``--cert`` option. Allows either an
    existing file, the string ``'adhoc'``, or an import for a
    :class:`~ssl.SSLContext` object.
    rL   c             C   s%   t  j d d d d d d  |  _ d  S)NrS   Tdir_okayFresolve_path)rf   Path	path_type)ry   r   r   r   rH     s    zCertParamType.__init__c             C   s   t  d  k r! t j d | |   y |  j | | |  SWn t j k
 r t j | | |  j   } | d k r y d d  l } Wn' t k
 r t j d | |   Yn X| St | d d } t	 j
 d
 k  r | r | Sn t | t  j  r | S  Yn Xd  S)Nz?Using "--cert" requires Python to be compiled with SSL support.adhocr   z-Using ad-hoc certificates requires pyOpenSSL.ZsilentTr4      	   )r4   r   r   )sslrf   BadParameterr   STRINGlowerOpenSSLr[   r   r5   version_infor   
SSLContext)ry   rm   rl   rk   r   r   r   r   r   convert  s.    	zCertParamType.convertN)r   r   r   r   r<   rH   r   r   r   r   r   r     s   r   c             C   s   |  j  j d  } | d k } t j d k  rL | oF t | t t f  } n t | t j  } | d k	 r | r t	 j
 d |  |   | r t	 j
 d |  |   | s t	 j
 d	 |  |   | | f |  j  d <n( | r | p | r t	 j
 d
 |  |   | S)zThe ``--key`` option must be specified when ``--cert`` is a file.
    Modifies the ``cert`` param to be a ``(cert, key)`` pair if needed.
    certr   r4   r   r   Nz.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".)r4   r   r   )r   r   r5   r   r   r   bytesr   r   rf   r   )rk   rl   rm   r   Zis_adhocZ
is_contextr   r   r   _validate_key  s$    r   c                   s(   e  Z d  Z d Z   f d d   Z   S)SeparatedPathTypezClick 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>   |  j  |  } t t |   j      f d d   | D S)Nc                s"   g  |  ] }  |      q Sr   r   )r   item)rk   rl   super_convertr   r   r     s   	 z-SeparatedPathType.convert.<locals>.<listcomp>)Zsplit_envvar_valuer   r   r   )ry   rm   rl   rk   items)r   )rk   rl   r   r   r     s    zSeparatedPathType.convert)r   r   r   r   r   r   r   )r   r   r     s   r   runZ
short_helpzRun a development server.z--hostz-hdefaultz	127.0.0.1zThe interface to bind to.z--portz-pi  zThe port to bind to.z--certtypez(Specify a certificate file to use HTTPS.z--keyrS   r   r   z2The key file to use when specifying a certificate.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--eager-loading/--lazy-loaderzaEnable or disable eager loading. By default eager loading is enabled if the reloader is disabled.z --with-threads/--without-threadsz!Enable or disable multithreading.z--extra-fileszRExtra files that trigger a reload on change. Multiple paths are separated by '{}'.c	             C   s   t    }	 | d k r |	 } | d k r- |	 } | d k r@ | } t t   |	 |  j |  t |  j d | }
 d d l m } | | | |
 d | d | d | d | 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 if
    FLASK_ENV=development or FLASK_DEBUG=1.
    Nrz   r   )
run_simpleZuse_reloaderZuse_debuggerthreadedssl_contextextra_files)r   r   r   r   rr   r   Zwerkzeug.servingr   )r   hostportreloadZdebuggerr   Zwith_threadsr   r   r   r   r   r   r   r   r     s&    9	r   shellzRun a shell in the app context.c              C   s   d d l  }  d d l m } | j j } d t j t j | j | j	 | j
 f } i  } t j j d  } | r t j j |  r t | d  & } t t | j   | d  |  Wd QRX| j | j    |  j d	 | 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 it's configuration.

    This is useful for executing small snippets of management code
    without having to manually configure the application.
    r   Nr   )_app_ctx_stackz)Python %s on %s
App: %s [%s]
Instance: %sZPYTHONSTARTUPrexecbannerlocal)codeglobalsr   topr   r5   versionrh   r   r   Zinstance_pathrK   r   r   rL   r   openevalcompilereadr   Zmake_shell_contextZinteract)r   r   r   r   rk   Zstartupr   r   r   r   r   `  s     
&r   ZrouteszShow the routes for the app.z--sortz-sendpointmethodsruler@   zgMethod to sort routes by. "match" is the order that Flask will match routes when dispatching a request.z--all-methodszShow HEAD and OPTIONS methods.c       	         s  t  t j j    } | s, t j d  d St | r; f  n d    |  d k rk t | d t |   } n$ |  d k r t | d d	 d
   }   f d d   | D } d } t	 d d   | D  t	 d d   | D  t	 d d   | D  f } d d   t
 | |  D } d j |   } t j | j |   j    t j | j d d   | D    xE t
 | |  D]4 \ } } t j | j | j | | j  j    qpWd S)z6Show all registered routes with endpoints and methods.zNo routes were registered.NHEADOPTIONSr   r   keyr   c             S   s   t  |  j  S)N)r   r   )r   r   r   r   <lambda>  s    z routes_command.<locals>.<lambda>c                s,   g  |  ]" } d  j  t | j      q S)z, )rT   r   r   )r   r   )ignored_methodsr   r   r     s   	 z"routes_command.<locals>.<listcomp>EndpointMethodsRulec             s   s   |  ] } t  | j  Vq d  S)N)r&   r   )r   r   r   r   r   	<genexpr>  s    z!routes_command.<locals>.<genexpr>c             s   s   |  ] } t  |  Vq d  S)N)r&   )r   r   r   r   r   r    s    c             s   s   |  ] } t  | j  Vq d  S)N)r&   r   )r   r   r   r   r   r    s    c             S   s+   g  |  ]! \ } } t  t |  |   q Sr   )maxr&   )r   hwr   r   r   r     s   	 z"{{0:<{0}}}  {{1:<{1}}}  {{2:<{2}}}c             s   s   |  ] } d  | Vq d S)-Nr   )r   widthr   r   r   r    s    )r   r   )r   r   )r  r  r  )r   r   Zurl_mapZ
iter_rulesrf   rg   r   r   r   r  zipr'   stripr   r   rstrip)	sortZall_methodsrulesZrule_methodsheadersZwidthsrowr   r   r   )r  r   r     s(    #r   a  A general utility script for Flask applications.

Provides commands from Flask, extensions, and the application. Loads the
application defined in the FLASK_APP environment variable, or from a wsgi.py
file. Setting the FLASK_ENV environment variable to 'development' will enable
debug mode.


  {prefix}{cmd} FLASK_APP=hello.py
  {prefix}{cmd} FLASK_ENV=development
  {prefix}flask run
cmdposixexportr   prefixz$ z> c             C   s3   t  j d t j d d   d |  r( d n d   d  S)Nr2   r   Z	prog_namezpython -m flask)r   r   r5   argv)	as_moduler   r   r   r     s    r   __main__r  )r   r   r   r@   )Kr   
__future__r   rC   r(   rK   rh   r?   r5   r\   	functoolsr   operatorr   	threadingr   r   rf   Zwerkzeug.utilsr   _compatr	   r
   r   r   r   r   helpersr   r   r   r   r[   r   Z
UsageErrorr   r1   r*   r,   rG   rY   ra   ro   Optionr   objectrr   r   Zmake_pass_decoratorZpass_script_infor   r   r   r   r   r   r   Z	ParamTyper   r   r   r   r   optionr'   rL   pathsepr   r   ZChoicer   r<   r   r   r   r   r   r   r   <module>
   s   3;		7B=.#	0(""	!