https://t.me/AnonymousX5
Server : Apache
System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64
User : njnconst ( 1116)
PHP Version : 8.4.18
Disable Function : NONE
Directory :  /lib64/python2.7/site-packages/flask/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib64/python2.7/site-packages/flask/helpers.pyc
�
-/�_c@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddl
m
Z
ddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddl#m$Z$ddl#m%Z%ddl#m&Z&ddl#m'Z'ddl#m(Z(ddl)m*Z*e+�Z,e-d�ej.j/ej.j0gD��Z1d�Z2d�Z3e4d�Z5d�Z6d�Z7d �Z8d!�Z9d"�Z:d#d$�Z;e<d3d%�Z=de<de4de<dd&�Z?d'�Z@d(�ZAd)�ZBd*�ZCd+�ZDd,�ZEd-e+fd.��YZFd/e+fd0��YZGd1�ZHd2�ZIdS(4s
    flask.helpers
    ~~~~~~~~~~~~~

    Implements various helpers.

    :copyright: 2010 Pallets
    :license: BSD-3-Clause
i����N(tupdate_wrapper(tRLock(ttime(tadler32(tFileSystemLoader(tHeaders(t
BadRequest(tNotFound(tRequestedRangeNotSatisfiable(t
BuildError(t	url_quote(t	wrap_filei(tfspath(tPY2(tstring_types(t	text_type(t_app_ctx_stack(t_request_ctx_stack(tcurrent_app(trequest(tsession(tmessage_flashedccs!|]}|dkr|VqdS(t/N(NR(tNone(t.0tsep((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pys	<genexpr>4scCstjjd�pdS(s�Get the environment the app is running in, indicated by the
    :envvar:`FLASK_ENV` environment variable. The default is
    ``'production'``.
    t	FLASK_ENVt
production(tostenvirontget(((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pytget_env8scCs5tjjd�}|s%t�dkS|j�dkS(s�Get whether debug mode should be enabled for the app, indicated
    by the :envvar:`FLASK_DEBUG` environment variable. The default is
    ``True`` if :func:`.get_env` returns ``'development'``, or ``False``
    otherwise.
    tFLASK_DEBUGtdevelopmentt0tfalsetno(R"sfalsesno(RRRRtlower(tval((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pytget_debug_flag@s
cCs,tjjd�}|s|S|j�dkS(s�Get whether the user has disabled loading dotenv files by setting
    :envvar:`FLASK_SKIP_DOTENV`. The default is ``True``, load the
    files.

    :param default: What to return if the env var isn't set.
    tFLASK_SKIP_DOTENVR"R#R$(R"sfalsesno(RRRR%(tdefaultR&((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pytget_load_dotenvNscCs|dk	std��|jS(ssInternal helper that returns the default endpoint for a given
    function.  This always is the function name.
    s/expected view func if endpoint is not provided.N(RtAssertionErrort__name__(t	view_func((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyt_endpoint_from_view_func]scscyt���Wn*tk
r<�fd�}t|��SX�fd�}|�}t|�|S(s�Request contexts disappear when the response is started on the server.
    This is done for efficiency reasons and to make it less likely to encounter
    memory leaks with badly written WSGI middlewares.  The downside is that if
    you are using streamed responses, the generator cannot access request bound
    information any more.

    This function however can help you keep the context around for longer::

        from flask import stream_with_context, request, Response

        @app.route('/stream')
        def streamed_response():
            @stream_with_context
            def generate():
                yield 'Hello '
                yield request.args['name']
                yield '!'
            return Response(generate())

    Alternatively it can also be used around a specific generator::

        from flask import stream_with_context, request, Response

        @app.route('/stream')
        def streamed_response():
            def generate():
                yield 'Hello '
                yield request.args['name']
                yield '!'
            return Response(stream_with_context(generate()))

    .. versionadded:: 0.9
    cs�||�}t|�S(N(tstream_with_context(targstkwargstgen(tgenerator_or_function(s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyt	decorator�sc
3sttj}|dkr$td��n|�DdVzx�D]}|Vq:WWdt�d�ri�j�nXWdQXdS(Ns\Attempted to stream with context but there was no context in the first place to keep around.tclose(RttopRtRuntimeErrorthasattrR5(tctxtitem(R2(s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyt	generator�s	

(titert	TypeErrorRtnext(R3R4R;t	wrapped_g((R2R3s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyR/es"
	
cGs<|stj�St|�dkr/|d}ntj|�S(sySometimes it is necessary to set additional headers in a view.  Because
    views do not have to return response objects but can return a value that
    is converted into a response object by Flask itself, it becomes tricky to
    add headers to it.  This function can be called instead of using a return
    and you will get a response object which you can use to attach headers.

    If view looked like this and you want to add a new header::

        def index():
            return render_template('index.html', foo=42)

    You can now do something like this::

        def index():
            response = make_response(render_template('index.html', foo=42))
            response.headers['X-Parachutes'] = 'parachutes are cool'
            return response

    This function accepts the very same arguments you can return from a
    view function.  This for example creates a response with a 404 error
    code::

        response = make_response(render_template('not_found.html'), 404)

    The other use case of this function is to force the return value of a
    view function into a response which is helpful with view
    decorators::

        response = make_response(view_function())
        response.headers['X-Parachutes'] = 'parachutes are cool'

    Internally this function does the following things:

    -   if no arguments are passed, it creates a new response argument
    -   if one argument is passed, :meth:`flask.Flask.make_response`
        is invoked with it.
    -   if more than one argument is passed, the arguments are passed
        to the :meth:`flask.Flask.make_response` function as tuple.

    .. versionadded:: 0.6
    ii(Rtresponse_classtlent
make_response(R0((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyRB�s
*

c
Kstj}tj}|dkr-td��n|dk	r�|j}tj}|d dkr�|dk	rt||}q�|d}n|jdt	�}n6|j}|dkr�td��n|jdt
�}|jdd�}|jdd�}|jdd�}	|jj||�d}
|	dk	rQ|s<t
d	��n|j}
|	|_nyBz"|j||d
|d|�}Wd|
dk	r�|
|_nXWnNtk
r�}||d<||d<||d<|	|d<|jj|||�SX|dk	r|d
t|�7}n|S(s�Generates a URL to the given endpoint with the method provided.

    Variable arguments that are unknown to the target endpoint are appended
    to the generated URL as query arguments.  If the value of a query argument
    is ``None``, the whole pair is skipped.  In case blueprints are active
    you can shortcut references to the same blueprint by prefixing the
    local endpoint with a dot (``.``).

    This will reference the index function local to the current blueprint::

        url_for('.index')

    For more information, head over to the :ref:`Quickstart <url-building>`.

    Configuration values ``APPLICATION_ROOT`` and ``SERVER_NAME`` are only used when
    generating URLs outside of a request context.

    To integrate applications, :class:`Flask` has a hook to intercept URL build
    errors through :attr:`Flask.url_build_error_handlers`.  The `url_for`
    function results in a :exc:`~werkzeug.routing.BuildError` when the current
    app does not have a URL for the given endpoint and values.  When it does, the
    :data:`~flask.current_app` calls its :attr:`~Flask.url_build_error_handlers` if
    it is not ``None``, which can return a string to use as the result of
    `url_for` (instead of `url_for`'s default to raise the
    :exc:`~werkzeug.routing.BuildError` exception) or re-raise the exception.
    An example::

        def external_url_handler(error, endpoint, values):
            "Looks up an external URL when `url_for` cannot build a URL."
            # This is an example of hooking the build_error_handler.
            # Here, lookup_url is some utility function you've built
            # which looks up the endpoint in some external URL registry.
            url = lookup_url(endpoint, **values)
            if url is None:
                # External lookup did not have a URL.
                # Re-raise the BuildError, in context of original traceback.
                exc_type, exc_value, tb = sys.exc_info()
                if exc_value is error:
                    raise exc_type, exc_value, tb
                else:
                    raise error
            # url_for will use this result, instead of raising BuildError.
            return url

        app.url_build_error_handlers.append(external_url_handler)

    Here, `error` is the instance of :exc:`~werkzeug.routing.BuildError`, and
    `endpoint` and `values` are the arguments passed into `url_for`.  Note
    that this is for building URLs outside the current application, and not for
    handling 404 NotFound errors.

    .. versionadded:: 0.10
       The `_scheme` parameter was added.

    .. versionadded:: 0.9
       The `_anchor` and `_method` parameters were added.

    .. versionadded:: 0.9
       Calls :meth:`Flask.handle_build_error` on
       :exc:`~werkzeug.routing.BuildError`.

    :param endpoint: the endpoint of the URL (name of the function)
    :param values: the variable arguments of the URL rule
    :param _external: if set to ``True``, an absolute URL is generated. Server
      address can be changed via ``SERVER_NAME`` configuration variable which
      falls back to the `Host` header, then to the IP and port of the request.
    :param _scheme: a string specifying the desired URL scheme. The `_external`
      parameter must be set to ``True`` or a :exc:`ValueError` is raised. The default
      behavior uses the same scheme as the current request, or
      ``PREFERRED_URL_SCHEME`` from the :ref:`app configuration <config>` if no
      request context is available. As of Werkzeug 0.10, this also can be set
      to an empty string to build protocol-relative URLs.
    :param _anchor: if provided this is added as anchor to the URL.
    :param _method: if provided this explicitly specifies an HTTP method.
    s�Attempted to generate a URL without the application context being pushed. This has to be executed when application context is available.it.t	_externals�Application was not able to create a URL adapter for request independent URL generation. You might be able to fix this by setting the SERVER_NAME config variable.t_anchort_methodt_schemes/When specifying _scheme, _external must be Truetmethodtforce_externalNt#(RR6RRR7turl_adapterRt	blueprinttpoptFalsetTruetapptinject_url_defaultst
ValueErrort
url_schemetbuildR	thandle_url_build_errorR
(
tendpointtvaluestappctxtreqctxRKtblueprint_nametexternaltanchorRHtschemet
old_schemetrvterror((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyturl_for�sVL				

		



cCsttjj|�j|�S(sXLoads a macro (or variable) a template exports.  This can be used to
    invoke a macro from within Python code.  If you for example have a
    template named :file:`_cider.html` with the following contents:

    .. sourcecode:: html+jinja

       {% macro hello(name) %}Hello {{ name }}!{% endmacro %}

    You can access this from Python code like this::

        hello = get_template_attribute('_cider.html', 'hello')
        return hello('World')

    .. versionadded:: 0.2

    :param template_name: the name of the template
    :param attribute: the name of the variable of macro to access
    (tgetattrRt	jinja_envtget_templatetmodule(t
template_namet	attribute((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pytget_template_attributeystmessagecCsRtjdg�}|j||f�|td<tjtj�d|d|�dS(s�Flashes a message to the next request.  In order to remove the
    flashed message from the session and to display it to the user,
    the template has to call :func:`get_flashed_messages`.

    .. versionchanged:: 0.3
       `category` parameter added.

    :param message: the message to be flashed.
    :param category: the category for the message.  The following values
                     are recommended: ``'message'`` for any kind of message,
                     ``'error'`` for errors, ``'info'`` for information
                     messages and ``'warning'`` for warnings.  However any
                     kind of string can be used as category.
    t_flashesRitcategoryN(RRtappendRtsendRt_get_current_object(RiRktflashes((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pytflash�s

cs�tjj}|dkrFdtkr3tjd�ngtj_}n�rmtt�fd�|��}n|s�g|D]}|d^qzS|S(s�Pulls all flashed messages from the session and returns them.
    Further calls in the same request to the function will return
    the same messages.  By default just the messages are returned,
    but when `with_categories` is set to ``True``, the return value will
    be a list of tuples in the form ``(category, message)`` instead.

    Filter the flashed messages to one or more categories by providing those
    categories in `category_filter`.  This allows rendering categories in
    separate html blocks.  The `with_categories` and `category_filter`
    arguments are distinct:

    * `with_categories` controls whether categories are returned with message
      text (``True`` gives a tuple, where ``False`` gives just the message text).
    * `category_filter` filters the messages down to only those matching the
      provided categories.

    See :ref:`message-flashing-pattern` for examples.

    .. versionchanged:: 0.3
       `with_categories` parameter added.

    .. versionchanged:: 0.9
        `category_filter` parameter added.

    :param with_categories: set to ``True`` to also receive categories.
    :param category_filter: whitelist of categories to limit return values
    Rjcs|d�kS(Ni((tf(tcategory_filter(s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyt<lambda>�siN(RR6RoRRRMtlisttfilter(twith_categoriesRrRotx((Rrs./tmp/pip-install-sTXtzD/flask/flask/helpers.pytget_flashed_messages�s.!cCs�d"}d"}	t|d�r*t|�}nt|t�r�|}
tjj|
�sltjjt	j
|
�}
nd"}|d"kr�tjj|
�}q�n|}d"}
|d"kr�|d"k	r�tj
|�dp�d}n|d"kr�td��q�nt�}|r�|d"krtd��nt|t�s?|jd�}ny|jd�}WnMtk
r�itjd|�jdd	�d
6dt|dd
�d6}
nXi|d
6}
|jdd|
�nt	jr|
r|d"k	r�|j�n|
|d<tjj|
�}	|	|d<d"}n�|d"krht|
d�}tjj|
�}tjj|
�}	|	|d<nXt|tj�r�y|j �j!}	Wn#t"k
r�t#|j$��}	nX|	|d<nt%t&j'|�}t	j(|d|d|dt)�}|d"k	r||_*n|d"k	r#||_*nt)|j+_,|d"krMt	j-|
�}n|d"k	r~||j+_.t/t0�|�|_1n|r)|
d"k	r)ddl2m3}y^|j4dtjj|
�tjj|
�t5t|
t�r�|
jd�n|
�d@f�Wq)t6k
r%|d|
dd�q)Xn|r�y|j7t&dt)d|	�}Wn-t8k
r}|d"k	rw|j�n�nX|j9d kr�|j:j;d!d"�q�n|S(#s�Sends the contents of a file to the client.  This will use the
    most efficient method available and configured.  By default it will
    try to use the WSGI server's file_wrapper support.  Alternatively
    you can set the application's :attr:`~Flask.use_x_sendfile` attribute
    to ``True`` to directly emit an ``X-Sendfile`` header.  This however
    requires support of the underlying webserver for ``X-Sendfile``.

    By default it will try to guess the mimetype for you, but you can
    also explicitly provide one.  For extra security you probably want
    to send certain files as attachment (HTML for instance).  The mimetype
    guessing requires a `filename` or an `attachment_filename` to be
    provided.

    ETags will also be attached automatically if a `filename` is provided. You
    can turn this off by setting `add_etags=False`.

    If `conditional=True` and `filename` is provided, this method will try to
    upgrade the response stream to support range requests.  This will allow
    the request to be answered with partial content response.

    Please never pass filenames to this function from user sources;
    you should use :func:`send_from_directory` instead.

    .. versionadded:: 0.2

    .. versionadded:: 0.5
       The `add_etags`, `cache_timeout` and `conditional` parameters were
       added.  The default behavior is now to attach etags.

    .. versionchanged:: 0.7
       mimetype guessing and etag support for file objects was
       deprecated because it was unreliable.  Pass a filename if you are
       able to, otherwise attach an etag yourself.  This functionality
       will be removed in Flask 1.0

    .. versionchanged:: 0.9
       cache_timeout pulls its default from application config, when None.

    .. versionchanged:: 0.12
       The filename is no longer automatically inferred from file objects. If
       you want to use automatic mimetype and etag support, pass a filepath via
       `filename_or_fp` or `attachment_filename`.

    .. versionchanged:: 0.12
       The `attachment_filename` is preferred over `filename` for MIME-type
       detection.

    .. versionchanged:: 1.0
        UTF-8 filenames, as specified in `RFC 2231`_, are supported.

    .. _RFC 2231: https://tools.ietf.org/html/rfc2231#section-4

    .. versionchanged:: 1.0.3
        Filenames are encoded with ASCII instead of Latin-1 for broader
        compatibility with WSGI servers.

    .. versionchanged:: 1.1
        Filename may be a :class:`~os.PathLike` object.

    .. versionadded:: 1.1
        Partial content supports :class:`~io.BytesIO`.

    :param filename_or_fp: the filename of the file to send.
                           This is relative to the :attr:`~Flask.root_path`
                           if a relative path is specified.
                           Alternatively a file object might be provided in
                           which case ``X-Sendfile`` might not work and fall
                           back to the traditional method.  Make sure that the
                           file pointer is positioned at the start of data to
                           send before calling :func:`send_file`.
    :param mimetype: the mimetype of the file if provided. If a file path is
                     given, auto detection happens as fallback, otherwise an
                     error will be raised.
    :param as_attachment: set to ``True`` if you want to send this file with
                          a ``Content-Disposition: attachment`` header.
    :param attachment_filename: the filename for the attachment if it
                                differs from the file's filename.
    :param add_etags: set to ``False`` to disable attaching of etags.
    :param conditional: set to ``True`` to enable conditional responses.

    :param cache_timeout: the timeout in seconds for the headers. When ``None``
                          (default), this value is set by
                          :meth:`~Flask.get_send_file_max_age` of
                          :data:`~flask.current_app`.
    :param last_modified: set the ``Last-Modified`` header to this value,
        a :class:`~datetime.datetime` or timestamp.
        If a file was passed, this overrides its mtime.
    t
__fspath__isapplication/octet-streams�Unable to infer MIME-type because no filename is available. Please set either `attachment_filename`, pass a filepath to `filename_or_fp` or set your own MIME-type via `mimetype`.s8filename unavailable, required for sending as attachmentsutf-8tasciitNFKDtignoretfilenames	UTF-8''%stsafets	filename*sContent-Dispositiont
attachments
X-SendfilesContent-Lengthtrbtmimetypetheaderstdirect_passthroughi����(twarns%s-%s-%sI����sEAccess %s failed, maybe it does not exist, so ignore etags in headerst
stacklevelit
accept_rangestcomplete_lengthi0s
x-sendfileN(<RR8Rt
isinstanceRRtpathtisabstjoinRt	root_pathtbasenamet	mimetypest
guess_typeRRRR=RtdecodetencodetUnicodeEncodeErrortunicodedatat	normalizeR
taddtuse_x_sendfileR5tgetsizetopentgetmtimetiotBytesIOt	getbuffertnbytestAttributeErrorRAtgetvalueRRRR@ROt
last_modifiedt
cache_controltpublictget_send_file_max_agetmax_agetintRtexpirestwarningsR�tset_etagRtOSErrortmake_conditionalRtstatus_codeR�RM(tfilename_or_fpR�t
as_attachmenttattachment_filenamet	add_etagst
cache_timeouttconditionalR�tmtimetfsizeR}tfileR�t	filenamestdataR_R�((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyt	send_file�s�b		





	





cs�|g}x�|D]���dkr4tj���nt�fd�tD��s}tjj��s}�dks}�jd�r�t��n|j	��qWtj
|�S(sjSafely join `directory` and zero or more untrusted `pathnames`
    components.

    Example usage::

        @app.route('/wiki/<path:filename>')
        def wiki_page(filename):
            filename = safe_join(app.config['WIKI_FOLDER'], filename)
            with open(filename, 'rb') as fd:
                content = fd.read()  # Read and process the file content...

    :param directory: the trusted base directory.
    :param pathnames: the untrusted pathnames relative to that directory.
    :raises: :class:`~werkzeug.exceptions.NotFound` if one or more passed
            paths fall out of its boundaries.
    Rc3s|]}|�kVqdS(N((RR(R}(s./tmp/pip-install-sTXtzD/flask/flask/helpers.pys	<genexpr>�ss..s../(t	posixpathtnormpathtanyt_os_alt_sepsRR�R�t
startswithRRlR�(t	directoryt	pathnamestparts((R}s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyt	safe_join�s	
cKs�t|�}t|�}t||�}tjj|�sTtjjtj|�}ny"tjj|�sut	��nWn t
tfk
r�t��nX|j
dt�t||�S(sSend a file from a given directory with :func:`send_file`.  This
    is a secure way to quickly expose static files from an upload folder
    or something similar.

    Example usage::

        @app.route('/uploads/<path:filename>')
        def download_file(filename):
            return send_from_directory(app.config['UPLOAD_FOLDER'],
                                       filename, as_attachment=True)

    .. admonition:: Sending files and Performance

       It is strongly recommended to activate either ``X-Sendfile`` support in
       your webserver or (if no authentication happens) to tell the webserver
       to serve files for the given path on its own without calling into the
       web application for improved performance.

    .. versionadded:: 0.5

    :param directory: the directory where all the files are stored.
    :param filename: the filename relative to that directory to
                     download.
    :param options: optional keyword arguments that are directly
                    forwarded to :func:`send_file`.
    R�(RR�RR�R�R�RR�tisfileRR=RRRt
setdefaultROR�(R�R}toptions((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pytsend_from_directory�s
cCstjj|�}|dk	rLt|d�rLtjjtjj|j	��St
j|�}|dkss|dkr}tj�St|d�r�|j
|�}nHt|�tj|}t|dd�}|dkr�td|��ntjjtjj|��S(s�Returns the path to a package or cwd if that cannot be found.  This
    returns the path of a package or the folder that contains a module.

    Not to be confused with the package path returned by :func:`find_package`.
    t__file__t__main__tget_filenamesNo root path can be found for the provided module "%s".  This can happen because the module came from an import hook that does not provide file name information or because it's a namespace package.  In this case the root path needs to be explicitly provided.N(tsystmodulesRRR8RR�tdirnametabspathR�tpkgutilt
get_loadertgetcwdR�t
__import__RbR7(timport_nametmodtloadertfilepath((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyt
get_root_paths 



cCs^t|d�r|j|�S|jjdkrD|jjdkrDtStd|jj��dS(s�Given the loader that loaded a module and the module this function
    attempts to figure out if the given module is actually a package.
    t
is_packaget_frozen_importlibtNamespaceLoaders�%s.is_package() method is missing but is required by Flask of PEP 302 import hooks.  If you do not use import hooks and you encounter this error please file a bug against Flask.N(R8R�t	__class__t
__module__R,ROR�(R�tmod_name((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyt)_matching_loader_thinks_module_is_package6s
cCs�tjd
kr�ddl}y1|jj|�}|dkrKtd��nWnttfk
req�X|jddhkr�t	j
jtt
|j���S|jr�t	j
jt	j
j|j��St	j
j|j�Sntj|�}|dks�|dkr	t	j�St|d�r*|j|�}n5t|d	�rE|j}nt|�tj|j}t	j
jt	j
j|��}t||�r�t	j
j|�}n|S(s/Find the path where the module's root exists iniii����Ns	not foundt	namespaceR�R�tarchive(ii(R�tversion_infotimportlib.utiltutilt	find_specRRRtImportErrortoriginRR�R�R>R<tsubmodule_search_locationsR�R�R�R8R�R�R�R�R�R�R�(t
root_mod_namet	importlibtspecR�R}tpackage_path((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyt_find_package_pathRs4	

c
Cs�|jd�\}}}t|�}tjj|�\}}tjjtj�}|j|�rj||fS|j	�dkr�tjj|�\}}|j	�dkr�|}	n9tjj
|�j	�dkr�tjj|�}	n|}	|	|fSd|fS(s�Finds a package and returns the prefix (or None if the package is
    not installed) as well as the folder that contains the package or
    module as a tuple.  The package path returned is the module that would
    have to be added to the pythonpath in order to make it possible to
    import the module.  The prefix is the path below which a UNIX like
    folder structure exists (lib, share etc.).
    RCs
site-packagestlibN(
t	partitionR�RR�tsplitR�R�tprefixR�R%R�R�R(
R�R�t_R�tsite_parenttsite_foldert	py_prefixtparenttfoldertbase_dir((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pytfind_package�s
	
tlocked_cached_propertycBs)eZdZddd�Zdd�ZRS(s#A decorator that converts a function into a lazy property.  The
    function wrapped is called the first time to retrieve the result
    and then that calculated result is used the next time you access
    the value.  Works like the one in Werkzeug but has a lock for
    thread safety.
    cCsI|p|j|_|j|_|p*|j|_||_t�|_dS(N(R,R�t__doc__tfuncRtlock(tselfR�tnametdoc((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyt__init__�s
	cCsn|dkr|S|j�O|jj|jt�}|tkr`|j|�}||j|j<n|SWdQXdS(N(RR�t__dict__RR,t_missingR�(R�tobjttypetvalue((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyt__get__�s
N(R,R�R�RR�R(((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyR��st_PackageBoundObjectcBs�eZdZdZdZddd�Zed��Zej	d��Zed��Z
e
j	d��Z
ed��Zed��Z
d�Zd�Zd	d
�ZRS(cCsk||_||_|dkr0t|j�}n||_d|_d|_ddlm}|�|_dS(Ni(tAppGroup(	R�ttemplate_folderRR�R�t_static_foldert_static_url_pathtcliR(R�R�RR�R((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyR��s					cCs,|jdk	r(tjj|j|j�SdS(s2The absolute path to the configured static folder.N(RRRR�R�R�(R�((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyt
static_folder�scCs+|dk	r|jd�}n||_dS(Ns/\(RtrstripR(R�R((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyR�scCsO|jdk	r|jS|jdk	rKtjj|j�}d|jd�SdS(s�The URL prefix that the static route will be accessible from.

        If it was not configured during init, it is derived from
        :attr:`static_folder`.
        RN(R	RRRR�R�R(R�R�((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pytstatic_url_path�s
cCs+|dk	r|jd�}n||_dS(NR(RRR	(R�R((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyR
�scCs
|jdk	S(s�This is ``True`` if the package bound object's container has a
        folder for static files.

        .. versionadded:: 0.5
        N(RR(R�((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pythas_static_folderscCs2|jdk	r.ttjj|j|j��SdS(sWThe Jinja loader for this package bound object.

        .. versionadded:: 0.5
        N(RRRRR�R�R�(R�((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pytjinja_loader
scCs
ttj�S(s�Provides default cache_timeout for the :func:`send_file` functions.

        By default, this function returns ``SEND_FILE_MAX_AGE_DEFAULT`` from
        the configuration of :data:`~flask.current_app`.

        Static file functions such as :func:`send_from_directory` use this
        function, and :func:`send_file` calls this function on
        :data:`~flask.current_app` when the given cache_timeout is ``None``. If a
        cache_timeout is given in :func:`send_file`, that timeout is used;
        otherwise, this method is called.

        This allows subclasses to change the behavior when sending files based
        on the filename.  For example, to set the cache timeout for .js files
        to 60 seconds::

            class MyFlask(flask.Flask):
                def get_send_file_max_age(self, name):
                    if name.lower().endswith('.js'):
                        return 60
                    return flask.Flask.get_send_file_max_age(self, name)

        .. versionadded:: 0.9
        (t
total_secondsRtsend_file_max_age_default(R�R}((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyR�scCs=|jstd��n|j|�}t|j|d|�S(s�Function used internally to send static files from the static
        folder to the browser.

        .. versionadded:: 0.5
        s No static folder for this objectR�(RR7R�R�R(R�R}R�((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pytsend_static_file0s
	R�cCsC|dddhkr$td��nttjj|j|�|�S(s:Opens a resource from the application's resource folder.  To see
        how this works, consider the following folder structure::

            /myapplication.py
            /schema.sql
            /static
                /style.css
            /templates
                /layout.html
                /index.html

        If you want to open the :file:`schema.sql` file you would do the
        following::

            with app.open_resource('schema.sql') as f:
                contents = f.read()
                do_something_with(contents)

        :param resource: the name of the resource.  To access resources within
                         subfolders use forward slashes as separator.
        :param mode: Open file in this mode. Only reading is supported,
            valid values are "r" (or "rt") and "rb".
        trtrtR�s(Resources can only be opened for reading(RRR�RR�R�R�(R�tresourcetmode((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyt
open_resource?sN(R,R�RR�RR�R�tpropertyRtsetterR
RR�RR�RR(((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyR�s				cCs|jddd|jS(s�Returns the total seconds from a timedelta object.

    :param timedelta td: the timedelta to be converted in seconds

    :returns: number of seconds
    :rtype: int
    i<i(tdaystseconds(ttd((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyR]scCs�trEtjdkrEytj|�tSWqEtjk
rAtSXnxItjtj	fD]5}ytj
||�Wntjk
r�qXXtSqXWtS(sDetermine if the given string is an IP address.

    Python 2 on Windows doesn't provide ``inet_pton``, so this only
    checks IPv4 addresses in that environment.

    :param value: value to check
    :type value: str

    :return: True if string is an IP address
    :rtype: bool
    tnt(R
RR�tsockett	inet_atonROR`RNtAF_INETtAF_INET6t	inet_pton(Rtfamily((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pytis_iphs
((JR�R�R�RR�R�RR�R�t	functoolsRt	threadingRRtzlibRtjinja2Rtwerkzeug.datastructuresRtwerkzeug.exceptionsRRRtwerkzeug.routingR	t
werkzeug.urlsR
t
werkzeug.wsgiRt_compatRR
RRtglobalsRRRRRtsignalsRtobjectRRtR�RtaltsepR�RR'ROR*R.R/RBRaRhRpRNRxRR�R�R�R�R�R�R�R�RRR$(((s./tmp/pip-install-sTXtzD/flask/flask/helpers.pyt<module>
sx	%				L	1	�	*�	%	)	0		:	�	

https://t.me/AnonymousX5 - 2025