Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
utils.cpython-313.pyc332 linesDownload Raw Back to __pycache__
1�

2��j'`���SSKJr SSKrSSKrSSKrSSKrSSKrSSKrSSKr	SSK3r4SSKJr SSKJr SSK
Jr SSKJr SSKJr SS	KJr SS5KJr SSKJr SSKJr SS
KJr SSKJr SSKJr SSKJr SSKJ r  \	RB(aSSK"J#r# SSK$J%r% SSK&J'r' \	RP"S5r)\RT"S5r+\RT"S5r,"SS\-\	R\\)5r/"SS\\5r0"SS\\5r11Skr2S)Sjr3S*S jr4S+S,S!jjr5S-S.S"jjr6S/S0S#jjr7S1S$jr8S2S3S%jjr9S4S5S&jjr:"S'S(\;5r<g)6�)�annotationsN)�datetime)�time)�quote)�adler32)�escape�)�_DictAccessorProperty)�_missing)�_TAccessorValue)�Headers)�NotFound)�RequestedRangeNotSatisfiable)�_windows_device_files)�	safe_join)�	wrap_file)�WSGIEnvironment)�Request��Response�_Tz	&([^;]+);z[^A-Za-z0-9_.-]c�h^�\rSrSrSrSS	U4SjjjrS6SjrSSSjjrS
SjrSr	U=r7$)�cached_property�(a"A :func:`property` that is only evaluated once. Subsequent access8returns the cached value. Setting the property sets the cached9value. Deleting the property clears the cached value, accessing it10again will evaluate it again.11 12.. code-block:: python13 14    class Example:15        @cached_property16        def value(self):17            # calculate something important here18            return 4219 20    e = Example()21    e.value  # evaluates22    e.value  # uses cache23    e.value = 16  # sets cache24    del e.value  # clears cache25 26If the class defines ``__slots__``, it must add ``_cache_{name}`` as27a slot. Alternatively, it can add ``__dict__``, but that's usually28not desirable.29 30.. versionchanged:: 2.131    Works with ``__slots__``.32 33.. versionchanged:: 2.034    ``del obj.name`` clears the cached value.35c�>�[TU]XS9 U=(d URUlSUR3UlURUlg)N)�doc�_cache_)�super�__init__�__name__�	slot_name�36__module__)�self�fget�namer�	__class__s    ��TD:\code\apps\devtools\python\user_packages\Python313\site-packages\werkzeug/utils.pyr�cached_property.__init__GsB���	�����'��-��
�
��
�"�4�=�=�/�2����/�/���c��[US5(aX!RUR'g[XRU5 g�N�__dict__)�hasattrr,r �setattrr!)r#�obj�values   r'�__set__�cached_property.__set__Rs-���3�37�#�#�*/�L�L����'��C����/r)c�@�UcU$[USS5nUb!URUR[5nO[XR[5nU[LaDURU5nUbXARUR'U$[XRU5 U$r+)�getattr�getr rr!r$r,r.)r#r/�type�obj_dictr0s     r'�__get__�cached_property.__get__Xs����;��K��3�38�D�1���� ���T�]�]�H�=�E��C����:�E��H���I�I�c�N�E��#�.3���T�]�]�+�����^�^�U�3��r)c��[US5(aURUR	g[XR[395 gr+)r-r,r r.r!r�r#r/s  r'�40__delete__�cached_property.__delete__ms-���3�41�#�#����T�]�]�+��C����2r))r"r r!)NN)r$zt.Callable[[t.Any], _T]r%�42str | Nonerr>�return�None)r/�objectr0rr?r@�N)r/rAr6r6r?r)r/rAr?r@)r r"�__qualname__�__firstlineno__�__doc__rr1r8r<�__static_attributes__�
__classcell__�r&s@r'rr(sU����B ��		*�%�	*��	*��		*�4344�	*�	*�0��*3�3r)rc�&�\rSrSrSrSrSSjrSrg)�environ_property�ta�Maps request attributes to environment variables. This works not only45for the Werkzeug request object, but also any other class with an46environ attribute:47 48>>> class Test(object):49...     environ = {'key': 'value'}50...     test = environ_property('key')51>>> var = Test()52>>> var.test53'value'54 55If you pass it a second value it's used as default if the key does not56exist, the third one can be a converter that takes a value and converts57it.  If it raises :exc:`ValueError` or :exc:`TypeError` the default value58is used. If no default value is provided `None` is used.59 60Per default the property is read only.  You have to explicitly enable it61by passing ``read_only=False`` to the constructor.62Tc��UR$rB)�environr;s  r'�lookup�environ_property.lookup�����{�{�r)�N)r/rr?r)r r"rCrDrE�	read_onlyrNrFrQr)r'rJrJts���(�I�r)rJc�"�\rSrSrSrSSjrSrg)�header_property�z(Like `environ_property` but for headers.c��UR$rB)�headersr;s  r'rN�header_property.lookup�rPr)rQN)r/zRequest | Responser?r
)r r"rCrDrErNrFrQr)r'rTrT�s63��2�r)rT>�application/sql�application/xml�application/xml-dtd�application/ecmascript�application/javascript�&application/xml-external-parsed-entityc��URS5(d U[;dURS5(aUSU3-
nU$)a$Returns the full content type string with charset for a mimetype.64 65If the mimetype represents text, the charset parameter will be66appended, otherwise the mimetype is returned unchanged.67 68:param mimetype: The mimetype to be used as content type.69:param charset: The charset to be appended for text mimetypes.70:return: The content type.71 72.. versionchanged:: 0.1573    Any type that ends with ``+xml`` gets a charset, not just those74    that start with ``application/``. Known text types such as75    ``application/javascript`` are also given charsets.76ztext/z+xmlz77; charset=)�78startswith�_charset_mimetypes�endswith)�mimetype�charsets  r'�get_content_typere�sE�� 	���G�$�$��)�)����V�$�$��j��	�*�*���Or)c	�8�[R"SU5nURSS5RS5n[R79[RR4HnU(dMURUS5nM  [[RSSRUR5555RS5n[RS:Xa6U(a/URS	5S80R!5[";aSU3nU$)a0Pass it a filename and it will return a secure version of it.  This81filename can then safely be stored on a regular file system and passed82to :func:`os.path.join`.  The filename returned is an ASCII only string83for maximum portability.84 85On windows systems the function also makes sure that the file is not86named after one of the special device files.87 88>>> secure_filename("My cool movie.mov")89'My_cool_movie.mov'90>>> secure_filename("../../../etc/passwd")91'etc_passwd'92>>> secure_filename('i contain cool \xfcml\xe4uts.txt')93'i_contain_cool_umlauts.txt'94 95The function might return an empty filename.  It's your responsibility96to ensure that the filename is unique and that you abort or97generate a random filename if the function returned an empty one.98 99.. versionadded:: 0.5100 101:param filename: the filename to secure102�NFKD�ascii�ignore� ��_z._�nt�.r)�unicodedata�	normalize�encode�decode�os�sep�path�altsep�replace�str�_filename_ascii_strip_re�sub�join�split�stripr%�upperr)�filenamerts  r'�secure_filenamer��s���0�$�$�V�X�6�H����w��1�8�8��A�H��v�v�r�w�w�~�~�%���3��'�'��S�1�H�&��+�/�/��C�H�H�X�^�^�=M�4N�O�P�V�V���H�	���4����N�N�3���"�(�(�*�.C�C��x�j�>���Or)c�h�UcSSKJn [U5nU"SUSUS3USS9nXRS'U$)	a%Returns a response object (a WSGI application) that, if called,103redirects the client to the target location. Supported codes are104301, 302, 303, 305, 307, and 308. 300 is not supported because105it's not a real redirect and 304 because it's the answer for a106request with a request with defined If-Modified-Since headers.107 108.. versionadded:: 0.6109   The location can now be a unicode string that is encoded using110   the :func:`iri_to_uri` function.111 112.. versionadded:: 0.10113    The class used for the Response object can now be passed in.114 115:param location: the location the response should redirect to.116:param code: the redirect status code. defaults to 302.117:param class Response: a Response class to use when instantiating a118    response. The default is :class:`werkzeug.wrappers.Response` if119    unspecified.120r	rz�<!doctype html>121<html lang=en>122<title>Redirecting...</title>123<h1>Redirecting...</h1>124<p>You should be redirected automatically to the target URL: <a href="z">z</a>. If not, click the link.125z	text/html)rc�Location)�wrappersrrrW)�location�coder�
html_location�responses     r'�redirectr��sY��,��&��8�$�M��	�126"�?�"�]�O�3R�	T�	
��	�H�$,���Z� ��Or)c��USRS5SnU(dSnOUS3nURS5nU(aUSU3n[X15$)aRedirect to the current URL with a slash appended.127 128If the current URL is ``/user/42``, the redirect URL will be129``42/``. When joined to the current URL during response130processing or by the browser, this will produce ``/user/42/``.131 132The behavior is undefined if the path ends with a slash already. If133called unconditionally on a URL, it may produce a redirect loop.134 135:param environ: Use the path and query from this WSGI environment136    to produce the redirect URL.137:param code: the status code for the redirect.138 139.. versionchanged:: 2.1140    Produce a relative URL that only modifies the last segment.141    Relevant when the current path has multiple segments.142 143.. versionchanged:: 2.1144    The default status code is 308 instead of 301. This preserves145    the request method and body.146�	PATH_INFO�/�z./�QUERY_STRING�?)�147rpartitionr5r�)rMr��tail�new_path�query_strings     r'�append_slash_redirectr�s]��,�;��*�*�3�/��2�D�����V�1�:���;�;�~�.�L���Z�q���/���H�#�#r)c���U148cSSKJn Un149Sn
SnSnSn[5n[U[R150[45(d[US5(a�[R"SU5nUb [RRX�5n
O[RRU5n
[R"U
5nURnURnOUnUc"U
b[RR!U
5nUcHUc[#S5e[$R&"U5unnUcSnUbU(dUR)SU5 Ub6UR+S	5 S151U0nU(aSOSnUR("SU40UD6 OU(a[#S5eU	(aU
bU
US'SnOUc
[7U
S5nOd[U[8R:5(aUR=5R>nO*[U[8R@5(a[CS5e[EX5nU152"UUUSS9nUbUUl#UbUUl$O153UbUUl$SURJl&[OU5(aU"U
5nUbTUS:�a"SURJl&SURJl(UURJl)[U[W5U-5Ul,[U[5(aUR[U5 O?U(a8U
b5[]U
R+55S-nUR[USUSU35 U(a>UR_USUS9nURdS:XaURfRiSS5 U$![,aN [.R0"SU5nUR+S	S5R3S	5n[5US
S9nUSU3S.nGNof=f![`a UbURc5 ef=f) a?
Send the contents of a file to the client.154 155The first argument can be a file path or a file-like object. Paths156are preferred in most cases because Werkzeug can manage the file and157get extra information from the path. Passing a file-like object158requires that the file is opened in binary mode, and is mostly159useful when building a file in memory with :class:`io.BytesIO`.160 161Never pass file paths provided by a user. The path is assumed to be162trusted, so a user could craft a path to access a file you didn't163intend. Use :func:`send_from_directory` to safely serve user-provided paths.164 165If the WSGI server sets a ``file_wrapper`` in ``environ``, it is166used, otherwise Werkzeug's built-in wrapper is used. Alternatively,167if the HTTP server supports ``X-Sendfile``, ``use_x_sendfile=True``168will tell the server to send the given path, which is much more169efficient than reading it in Python.170 171:param path_or_file: The path to the file to send, relative to the172    current working directory if a relative path is given.173    Alternatively, a file-like object opened in binary mode. Make174    sure the file pointer is seeked to the start of the data.175:param environ: The WSGI environ for the current request.176:param mimetype: The MIME type to send for the file. If not177    provided, it will try to detect it from the file name.178:param as_attachment: Indicate to a browser that it should offer to179    save the file instead of displaying it.180:param download_name: The default name browsers will use when saving181    the file. Defaults to the passed file name.182:param conditional: Enable conditional and range responses based on183    request headers. Requires passing a file path and ``environ``.184:param etag: Calculate an ETag for the file, which requires passing185    a file path. Can also be a string to use instead.186:param last_modified: The last modified time to send for the file,187    in seconds. If not provided, it will try to detect it from the188    file path.189:param max_age: How long the client should cache the file, in190    seconds. If set, ``Cache-Control`` will be ``public``, otherwise191    it will be ``no-cache`` to prefer conditional caching.192:param use_x_sendfile: Set the ``X-Sendfile`` header to let the193    server to efficiently send the file. Requires support from the194    HTTP server. Requires passing a file path.195:param response_class: Build the response using this class. Defaults196    to :class:`~werkzeug.wrappers.Response`.197:param _root_path: Do not use. For internal use only. Use198    :func:`send_from_directory` to safely send files under a path.199 200.. versionchanged:: 2.0.2201    ``send_file`` only sets a detected ``Content-Encoding`` if202    ``as_attachment`` is disabled.203 204.. versionadded:: 2.0205    Adapted from Flask's implementation.206 207.. versionchanged:: 2.0208    ``download_name`` replaces Flask's ``attachment_filename``209     parameter. If ``as_attachment=False``, it is passed with210     ``Content-Disposition: inline`` instead.211 212.. versionchanged:: 2.0213    ``max_age`` replaces Flask's ``cache_timeout`` parameter.214    ``conditional`` is enabled and ``max_age`` is not set by215    default.216 217.. versionchanged:: 2.0218    ``etag`` replaces Flask's ``add_etags`` parameter. It can be a219    string to use instead of generating one.220 221.. versionchanged:: 2.0222    If an encoding is returned when guessing ``mimetype`` from223    ``download_name``, set the ``Content-Encoding`` header.224Nr	r�225__fspath__�os.PathLike[str] | strz�Unable to detect the MIME type because a file name is not available. Either set 'download_name', pass a path instead of a file, or set 'mimetype'.zapplication/octet-streamzContent-Encodingrhrrgriz!#$&+-.^_`|~)�safezUTF-8'')rz	filename*�226attachment�inlinezContent-Dispositionz]No name provided for attachment. Either set 'download_name' or pass a path instead of a file.z227X-Sendfile�rbz3Files must be opened in binary mode or use BytesIO.T)rcrW�direct_passthroughrl���-)�
accept_ranges�complete_lengthi0z228x-sendfile)5r�rr
�229isinstancers�PathLikerxr-�t�castrur{�abspath�stat�st_size�st_mtime�basename�	TypeError�	mimetypes�230guess_type�setrq�UnicodeEncodeErrorrorprrr�open�io�BytesIO�	getbuffer�nbytes�231TextIOBase�232ValueErrorr�content_length�
last_modified�
cache_control�no_cache�callable�public�max_age�intr�expires�set_etagr�make_conditionalr�close�status_coderW�pop)�path_or_filerMrc�
as_attachment�
download_name�conditional�etagr�r��use_x_sendfile�response_class�233_root_pathrru�file�size�mtimerWr��encoding�names�simple�quotedr0�data�rv�checks                           r'�	send_filer�8s���l��&�!���D�#�D��D��E��i�G��,����c� 2�3�3�w��l�8�8��v�v�6��E���!��7�7�<�<�234�9�D��7�7�?�?�<�0�D��w�w�t�}���|�|���
�
�������!1����(�(��.�
���� ��>��
�'�1�1�-�@���(���1�H���
��K�K�*�H�5�� �		0�� � ��)� ��/�E� -��8�����)�5�:�E�:�	��
A�235�	236�237�$�*� $�������<���d�#�D�
��b�j�j�
)�
)��>�>�#�*�*�D�
��b�m�m�
,�
,��R�S�S���'��	��x��T�238�B��� ���� �(���	�	� ��� $�B���������$�-�����Q�;�(,�B���%�&*�B���#�#*���� ����'�)�*��239��$����240���D��	
�$�"�����
�&��3��241���u�g�Q�t�f�A�e�W�-�.��	��$�$�W�D�RV�$�W�B��>�>�S� ��J�J�N�N�<��.�
�I��["�	J� �*�*�6�=�A�F��]�]�7�H�5�<�<�W�E�F��=�~�>�F�!'���x�6H�I�E�	J��D,�	����242�243���		�s�M?�O�?AO�O�O9c�J�[[R"U5[R"U55nUc244[5eSU;a#[RRUSU5n[RR
U5(d245[5e[XB40UD6$)a�Send a file from within a directory using :func:`send_file`.246 247This is a secure way to serve files from a folder, such as static248files or uploads. Uses :func:`~werkzeug.security.safe_join` to249ensure the path coming from the client is not maliciously crafted to250point outside the specified directory.251 252If the final path does not point to an existing regular file,253returns a 404 :exc:`~werkzeug.exceptions.NotFound` error.254 255:param directory: The directory that ``path`` must be located under. This *must not*256    be a value provided by the client, otherwise it becomes insecure.257:param path: The path to the file to send, relative to ``directory``. This is the258    part of the path provided by the client, which is checked for security.259:param environ: The WSGI environ for the current request.260:param kwargs: Arguments to pass to :func:`send_file`.261 262.. versionadded:: 2.0263    Adapted from Flask's implementation.264r�)rrs�fspathrrur{�isfiler�)�	directoryrurM�kwargs�path_strs     r'�send_from_directoryr�s}��4����9�-�r�y�y���?�H����j���v���7�7�<�<��|� 4�h�?��
�7�7�>�>�(�#�#��j���X�1�&�1�1r)c���URSS5n[U5 [RU$![a265 SU;aeOf=fURSS5up#[U[
5[5U/5n[XC5$![an[	U5SeSnAff=f![aBnU(d1[X5R[R"5S5SeSnAgSnAff=f)aImports an object based on a string.  This is useful if you want to266use import paths as endpoints or something similar.  An import path can267be specified either in dotted notation (``xml.sax.saxutils.escape``)268or with a colon as object delimiter (``xml.sax.saxutils:escape``).269 270If `silent` is True the return value will be `None` if the import fails.271 272:param import_name: the dotted name for the object to import.273:param silent: if set to `True` import errors are ignored and274               `None` is returned instead.275:return: imported object276�:rnr	Nr�)
rw�277__import__�sys�modules�ImportError�rsplit�globals�localsr4�AttributeError�ImportStringError�with_traceback�exc_info)�import_name�silent�module_name�obj_name�module�es      r'�
import_stringr�=s����%�%�c�3�/�K��	,��{�#�278�;�;�{�+�+��	�	��+�%��&�	��!,� 2� 2�3�� :����K���F�H�x�j�I��	+��6�,�,���	+��a�.�d�*��	+�����#�K�3�B�B�����q�!���
��279��
�sP�3�B'�A�B'�A�6B'�>280B	�	281B$�B�B$�$B'�'282C3�18C.�.C3c#�4# �[U5n[USS5nUc[U<S35eURS3n[R283"U5H?upgnXW-nU(a*U(aUv� U(a[
XqS5Shv�N M9M;Uv� MA gN7f)a�Finds all the modules below a package.  This can be useful to284automatically import all views / controllers so that their metaclasses /285function decorators have a chance to register themselves on the286application.287 288Packages are not returned unless `include_packages` is `True`.  This can289also recursively list modules but in that case it will import all the290packages to get the correct load path of that module.291 292:param import_path: the dotted name for the package to find child modules.293:param include_packages: set to `True` if packages should be returned, too.294:param recursive: set to `True` if recursion should happen.295:return: generator296�__path__Nz is not a packagernT)r�r4r�r �pkgutil�iter_modules�find_modules)	�import_path�include_packages�	recursiver�rur��	_importer�modname�ispkgs	         r'r�r�ds����"�;�
'�F��6�:�t�,�D��|��K�?�*;�<�=�=��/�/�"�!�$�H�%,�%9�%9�$�%?�!�	�E��$�����
��'��4�H�H�H���M�&@�I�s�BB�B�Bc�P^�\rSrSr%SrS\S'S\S'S297U4SjjrSSjrS	rU=r	$)r�i�zBProvides information about a failed :func:`import_string` attempt.rxr��
BaseException�	exceptionc298��>�XlX lUnSn/nURSS5RS5H�nU(aUSU3OUn[	USS9nU(a URU[
USS545 MDUVV	s/sHup�SU<SU	<S3PM n299nn	U300RSU<S	35 S301RU3025nSU<SUS
[U5RSU3n O [TU]-U5 gs sn	nf)Nrkr�rnT)r��__file__z- z303 found in z not found.�304zimport_string() failed for z�. Possible reasons are:305 306- missing __init__.py in a package;307- package or module path not included in sys.path;308- duplicated package or module name taking precedence in sys.path;309- missing module, class, function or variable;310 311Debugged import:312 313z314 315Original exception:316 317z: )r�r�rwr|r��appendr4r{r6r rr)
r#r�r��msgr%�tracked�part�imported�n�i�track�	track_strr&s
            �r'r�ImportStringError.__init__�s���&��"���������'�'��S�1�7�7��<�D�'+�d�V�1�T�F�#��D�$�T�$�7�H������g�h�318�D�&I�J�K�@G�H����2�a�U�*�Q�E��3���H����r�$���5�6� �I�I�e�,�	�1�+��A+�,5�+�6.�.2�9�o�.F�.F�-G�r�)��V���)=�,	������!Is�>C5c�l�S[U5RSUR<SUR<S3$)N�<�(z, z)>)r6r r�r�)r#s r'�__repr__�ImportStringError.__repr__�s5���4��:�&�&�'�q��)9�)9�(<�B�t�~�~�>P�PR�S�Sr))r�r�)r�rxr�r�r?r@)r?rx)319r r"rCrDrE�__annotations__rrrFrGrHs@r'r�r��s%���L������<T�Tr)r�)rcrxrdrxr?rx)rrxr?rx)i.N)r�rxr�r�r�type[Response] | Noner?r)i4)rMrr�r�r?r)320NFNTTNNFNN)r�z$os.PathLike[str] | str | t.IO[bytes]rMrrcr>r��boolr�r>r�rr�z321bool | strr�zdatetime | int | float | Noner�z3None | (int | t.Callable[[str | None], int | None])r�rr�rr�zos.PathLike[str] | str | Noner?r)322r�r�rur�rMrr��t.Anyr?r)F)r�rxr�rr?r)FF)r�rxr�rr�rr?zt.Iterator[str])=�323__future__rr�r�rsr��rer��typingr�rorr�urllib.parser�zlibr�324markupsafer�	_internalr325rr�datastructuresr
�326exceptionsrr�securityrr�wsgir�
TYPE_CHECKING�_typeshed.wsgir�wrappers.requestr�wrappers.responser�TypeVarr�compile�327_entity_rery�property�GenericrrJrTrarer�r�r�r�r�r�r�r�r�rQr)r'�<module>r(s0��"�	��	��	�328��������,��&�#� �4�+����?�?�.�)�+��Y�Y�t�_��
�Z�Z��
%�329��:�:�&8�9��I3�h��	�	�"�
�I3�X�,�_�=��6�+�O�<�����2,�`GK�%��%��%�.C�%�
�%�P"$�P �� $���37�CG� �,0�04�X�6�X�
�X��X��	X�330�X��
X��X�1�X�A�X��X�*�X�.�X��X�v'2�%�'2�331 �'2��'2��	'2�332�'2�T$�PIN����(,��AE����B'T��'Tr)
codekingpro/portable-devtools · Team Ai