Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/werkzeug/middleware/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/werkzeug/middleware/__pycache__/profiler.cpython-312.pyc

�

'ٜg����dZddlmZddlZddlZddlZddlZddl	m
Z
	ddlmZejrddlmZddlmZddlmZGd	�d
�Zy#e
$r	ddlmZY�6wxYw)a9
Application Profiler
====================

This module provides a middleware that profiles each request with the
:mod:`cProfile` module. This can help identify bottlenecks in your code
that may be slowing down your application.

.. autoclass:: ProfilerMiddleware

:copyright: 2007 Pallets
:license: BSD-3-Clause
�)�annotationsN)�Stats)�Profile)�
StartResponse)�WSGIApplication)�WSGIEnvironmentc�f�eZdZdZej
ddddf													dd�Z						d	d�Zy)
�ProfilerMiddlewarea	Wrap a WSGI application and profile the execution of each
    request. Responses are buffered so that timings are more exact.

    If ``stream`` is given, :class:`pstats.Stats` are written to it
    after each request. If ``profile_dir`` is given, :mod:`cProfile`
    data files are saved to that directory, one file per request.

    The filename can be customized by passing ``filename_format``. If
    it is a string, it will be formatted using :meth:`str.format` with
    the following fields available:

    -   ``{method}`` - The request method; GET, POST, etc.
    -   ``{path}`` - The request path or 'root' should one not exist.
    -   ``{elapsed}`` - The elapsed time of the request in milliseconds.
    -   ``{time}`` - The time of the request.

    If it is a callable, it will be called with the WSGI ``environ`` and
    be expected to return a filename string. The ``environ`` dictionary
    will also have the ``"werkzeug.profiler"`` key populated with a
    dictionary containing the following fields (more may be added in the
    future):
    -   ``{elapsed}`` - The elapsed time of the request in milliseconds.
    -   ``{time}`` - The time of the request.

    :param app: The WSGI application to wrap.
    :param stream: Write stats to this stream. Disable with ``None``.
    :param sort_by: A tuple of columns to sort stats by. See
        :meth:`pstats.Stats.sort_stats`.
    :param restrictions: A tuple of restrictions to filter stats by. See
        :meth:`pstats.Stats.print_stats`.
    :param profile_dir: Save profile data files to this directory.
    :param filename_format: Format string for profile data file names,
        or a callable returning a name. See explanation above.

    .. code-block:: python

        from werkzeug.middleware.profiler import ProfilerMiddleware
        app = ProfilerMiddleware(app)

    .. versionchanged:: 3.0
        Added the ``"werkzeug.profiler"`` key to the ``filename_format(environ)``
        parameter with the  ``elapsed`` and ``time`` fields.

    .. versionchanged:: 0.15
        Stats are written even if ``profile_dir`` is given, and can be
        disable by passing ``stream=None``.

    .. versionadded:: 0.15
        Added ``filename_format``.

    .. versionadded:: 0.9
        Added ``restrictions`` and ``profile_dir``.
    )�time�calls�Nz/{method}.{path}.{elapsed:.0f}ms.{time:.0f}.profc�X�||_||_||_||_||_||_y�N)�_app�_stream�_sort_by�
_restrictions�_profile_dir�_filename_format)�self�app�stream�sort_by�restrictions�profile_dir�filename_formats       �G/usr/local/lib/python3.12/site-packages/werkzeug/middleware/profiler.py�__init__zProfilerMiddleware.__init__Ys1����	������
�)���'��� /���c�������g�d��fd�	�d����fd�}t�}tj�}|j|�dj��}tj�|z
}�j��t�j�r/|dztj�d��d<�j
��}n]�jj�d�djd	�jd	d
�xsd|dztj���}tjj�j|�}|j|��j��t|�j�
�}	|	j�j �t#d�j���j%dd�}
t#d|
���j��|	j&�j(�t#d�d��j��|gS)Nc�0���|||��jSr)�append)�status�headers�exc_info�
response_body�start_responses   ��r�catching_start_responsez<ProfilerMiddleware.__call__.<locals>.catching_start_responsens����6�7�H�5� �'�'�'rc����j�tjd���}�j|�t	|d�r|j�yy)Nr�close)r�t�cast�extend�hasattrr*)�app_iterr(�environr&rs ����r�runappz+ProfilerMiddleware.__call__.<locals>.runapprsK����y�y������1H�I��H�
� � ��*��x��)���� �*rrg@�@)�elapsedrzwerkzeug.profiler�REQUEST_METHOD�	PATH_INFO�/�.�root)�method�pathr2r)rzP--------------------------------------------------------------------------------)�file�zPATH: �
r)�return�None)rr�runcall�joinr�callabler�format�strip�replace�osr9�
dump_statsrr�
sort_statsr�print�get�print_statsr)
rr0r'r1�profile�start�bodyr2�filename�stats�	path_infor(r&s
```        @@r�__call__zProfilerMiddleware.__call__is����&(�
�	(�	!�	!��)���	�	���������x�x�
�&���)�)�+��%�����(���-�-�.�&��/� �I�I�K�0��+�,� �0�0��9���0�0�7�7�"�#3�4� ��-�3�3�C�8�@�@��c�J�T�f�#�f�,�����	8����w�w�|�|�D�$5�$5�x�@�H����x�(��<�<�#��'�$�,�,�7�E��E���d�m�m�,��(����.����K��4�I��F�9�-�(�t�|�|�<��E���t�1�1�2��X�J�b�/����5��v�
r)rrrzt.IO[str] | Nonerzt.Iterable[str]rzt.Iterable[str | int | float]rz
str | Noner�strr=r>)r0rr'rr=zt.Iterable[bytes])�__name__�
__module__�__qualname__�__doc__�sys�stdoutrrQr
rrr
r
"s���4�r$'�:�:�#4�68�"&�P�0�
�0�!�0�!�	0�
4�0� �
0��0�
�0� 2�&�2�8E�2�	�2rr
)rV�
__future__r�os.pathrErWr�typingr+�pstatsr�cProfiler�ImportErrorrK�
TYPE_CHECKING�_typeshed.wsgirrrr
r
rr�<module>rasX���#��
���� � ��?�?�,�.�.�y�y��� �� �s�A�A�A

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists