Team Ai
Datasetpublic

codekingpro/portable-devtools

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

2��j�=���SSKJr SSKrSSKJr SSKJr SSKJ	r	 SSK3Jr SSK4Jr SS	K5J
r
 SS6KJr SSKJr SSKJr SS
KJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr \R@(a>SSKr!SSK"J#r# \$\RJ\&\
\'\'4\
\'\44r("SS\!RR5r*\RV"S\RXS\RZ4S9r.S$S%Sjjr/S&SS.S'Sjjjr0"SS 5r1"S!S"5r2S(S#jr3g!\a SSKJr SrN�f=f))�)�annotationsN)�BytesIO)�	parse_qsl�)�7_plain_int)�FileStorage)�Headers)�	MultiDict)�RequestEntityTooLarge)�parse_options_header)�Data)�Epilogue)�Field)�File)�MultipartDecoder)�NeedData)�get_content_length)�get_input_stream)�SpooledTemporaryFile)�
TemporaryFile)�WSGIEnvironmentc�6�\rSrSrSSSjjrSrg)�TStreamFactory�(Nc��g�N�)�self�total_content_length�content_type�filename�content_lengths     �YD:\code\apps\devtools\python\user_packages\Python313\site-packages\werkzeug/formparser.py�__call__�TStreamFactory.__call__)s���rr�8r�9int | Noner �10str | Noner!r)r"r(�return�t.IO[bytes])�__name__�11__module__�__qualname__�__firstlineno__r$�__static_attributes__rr&r#rr(sA��*.�	�",�	�%�	�!�		�12'�	��
	�	r&r�F.)�boundc�13�Sn[b4[R"[R[[USS95$UbX:�a5[R"[R[[S55$[
5$)Ni�zrb+)�max_size�mode)r�t�cast�IO�bytesrr)rr r!r"r4s     r#�default_stream_factoryr:5sc���H��'��v�v�a�d�d�5�k�#7��PU�#V�W�W�	�	%�)=�)H��v�v�a�d�d�5�k�=��#7�8�8��9�r&��max_form_partsc	�<�[UUUUUUS9RU5$)aParse the form data in the environ and return it as tuple in the form14``(stream, form, files)``.  You should only call this method if the15transport method is `POST`, `PUT`, or `PATCH`.16 17If the mimetype of the data transmitted is `multipart/form-data` the18files multidict will be filled with `FileStorage` objects.  If the19mimetype is unknown the input stream is wrapped and returned as first20argument, else the stream is empty.21 22This is a shortcut for the common usage of :class:`FormDataParser`.23 24:param environ: the WSGI environment to be used for parsing.25:param stream_factory: An optional callable that returns a new read and26                       writeable file descriptor.  This callable works27                       the same as :meth:`Response._get_file_stream`.28:param max_form_memory_size: the maximum number of bytes to be accepted for29                       in-memory stored form data.  If the data30                       exceeds the value specified an31                       :exc:`~exceptions.RequestEntityTooLarge`32                       exception is raised.33:param max_content_length: If this is provided and the transmitted data34                           is longer than this value an35                           :exc:`~exceptions.RequestEntityTooLarge`36                           exception is raised.37:param cls: an optional dict class to use.  If this is not specified38                   or `None` the default :class:`MultiDict` is used.39:param silent: If set to False parsing errors will not be caught.40:param max_form_parts: The maximum number of multipart parts to be parsed. If this41    is exceeded, a :exc:`~exceptions.RequestEntityTooLarge` exception is raised.42:return: A tuple in the form ``(stream, form, files)``.43 44.. versionchanged:: 3.045    The ``charset`` and ``errors`` parameters were removed.46 47.. versionchanged:: 2.348    Added the ``max_form_parts`` parameter.49 50.. versionadded:: 0.5.151   Added the ``silent`` parameter.52 53.. versionadded:: 0.554   Added the ``max_form_memory_size``, ``max_content_length``, and ``cls``55   parameters.56)�stream_factory�max_form_memory_size�max_content_lengthr<�silent�cls)�FormDataParser�parse_from_environ)�environr>r?r@rBrAr<s       r#�parse_form_datarFEs1��l�%�1�-�%���
����!�"r&c��\rSrSrSrSSS.SSjjjrS
SjrSSSjjrSSjrSS	jr	S57r58g)rC�a�This class implements parsing of form data for Werkzeug.  By itself59it can parse multipart and url encoded form data.  It can be subclassed60and extended but for most mimetypes it is a better idea to use the61untouched stream and expose it as separate attributes on a request62object.63 64:param stream_factory: An optional callable that returns a new read and65                       writeable file descriptor.  This callable works66                       the same as :meth:`Response._get_file_stream`.67:param max_form_memory_size: the maximum number of bytes to be accepted for68                       in-memory stored form data.  If the data69                       exceeds the value specified an70                       :exc:`~exceptions.RequestEntityTooLarge`71                       exception is raised.72:param max_content_length: If this is provided and the transmitted data73                           is longer than this value an74                           :exc:`~exceptions.RequestEntityTooLarge`75                           exception is raised.76:param cls: an optional dict class to use.  If this is not specified77                   or `None` the default :class:`MultiDict` is used.78:param silent: If set to False parsing errors will not be caught.79:param max_form_parts: The maximum number of multipart parts to be parsed. If this80    is exceeded, a :exc:`~exceptions.RequestEntityTooLarge` exception is raised.81 82.. versionchanged:: 3.083    The ``charset`` and ``errors`` parameters were removed.84 85.. versionchanged:: 3.086    The ``parse_functions`` attribute and ``get_parse_func`` methods were removed.87 88.. versionchanged:: 2.2.389    Added the ``max_form_parts`` parameter.90 91.. versionadded:: 0.892Nr;c��Uc[nXlX lX0lX`lUc"S[5nX@lXPl	g�Nztype[MultiDict[str, t.Any]])94r:r>r?r@r<r6r7r95rBrA)rr>r?r@rBrAr<s       r#�__init__�FormDataParser.__init__�sG���!�3�N�,��$8�!�"4��,���;��&�&�6�	�B�C����r&c��[XRS9n[U5n[UR	S55upEURUUUUS9$)z�Parses the information from the environment as form data.96 97:param environ: the WSGI environment to be used for parsing.98:return: A tuple in the form ``(stream, form, files)``.99)r@�CONTENT_TYPE)r"�mimetype�options)rr@rr�get�parse)rrE�streamr"rOrPs      r#rD�!FormDataParser.parse_from_environ�sV��"�'�>U�>U�V��+�G�4��0����^�1L�M����z�z��)���	�100�	101r&c�0�US:Xa
URnO3US:Xa
URnO XR5UR54$Uc0nU"XX45$![a UR(deOf=fXR5UR54$)aParses the information from the given stream, mimetype,102content length and mimetype parameters.103 104:param stream: an input stream105:param mimetype: the mimetype of the data106:param content_length: the content length of the incoming data107:param options: optional mimetype parameters (used for108                the multipart boundary for instance)109:return: A tuple in the form ``(stream, form, files)``.110 111.. versionchanged:: 3.0112    The invalid ``application/x-url-encoded`` content type is not113    treated as ``application/x-www-form-urlencoded``.114zmultipart/form-dataz!application/x-www-form-urlencoded)�_parse_multipart�_parse_urlencodedrB�115ValueErrorrA)rrSrOr"rP�116parse_funcs      r#rR�FormDataParser.parse�s���*�,�,��.�.�J�
�<�
<��/�/�J��8�8�:�t�x�x�z�1�1��?��G�	��f��H�H���	��;�;���	���x�x�z�4�8�8�:�-�-s�
A�A5�4A5c��[URURURURS9nURSS5R
S5nU(d[S5eURXU5upxXU4$)N)r>r?r<rB�boundary��asciizMissing boundary)	�MultiPartParserr>r?r<rBrQ�encoderXrR)	rrSrOr"rP�parserr\�form�filess	         r#rV�FormDataParser._parse_multipart�sy��!��.�.�!%�!:�!:��.�.����	117���;�;�z�2�.�5�5�g�>����/�0�0��l�l�6�^�D����U�"�"r&c���URbUbX0R:�a118[5e[UR5R	5SSS9nXRU5UR54$)NTzwerkzeug.url_quote)�keep_blank_values�errors)r?rr�read�decoderB)rrSrOr"rP�itemss      r#rW� FormDataParser._parse_urlencodedsh��
�%�%�1��*��!:�!:�:�'�)�)���K�K�M� � �"�"�'�119��120�x�x������121�2�2r&)rBr@r?r<rAr>�NNNNT)r>�TStreamFactory | Noner?r(r@r(rB�"type[MultiDict[str, t.Any]] | NonerA�boolr<r(r*�None)rErr*�t_parse_resultr)122rSr+rO�strr"r(rPzdict[str, str] | Noner*rq)123rSr+rOrrr"r(rPzdict[str, str]r*rq)r,r-r.r/�__doc__rKrDrRrVrWr0rr&r#rCrC�s��"�L15�+/�)-�26��
�&*��-��)��'�	�1240���
�#��125��0126�**.�%.��%.��%.�#�	%.�127'�%.�128�
%.�N#��#��#�#�	#�129 �#�130�
#�*3��3��3�#�	3�131 �3�132�
3r&rCc��\rSrSrS	S133SjjrSSjrSSjrS
SjrSSjrSr	g)r_i$Nc��X lXPlUc[nXlUc[R134"S[5nX0lX@lgrJ)	r?r<r:r>r6r7r135rB�buffer_size)rr>r?rBrvr<s      r#rK�MultiPartParser.__init__%sB��%9�!�,���!�3�N�,���;��&�&�6�	�B�C���&�r&c��[U5er)rX)r�messages  r#�fail�MultiPartParser.fail;s
����!�!r&c��URS5nU(a6[U5SnURSS5R5nUS;aU$g)N�content-typer�charsetr]>r^�utf-8�us-ascii�136iso-8859-1r)rQr�lower)r�headersr �137parameters�138ct_charsets     r#�get_part_charset� MultiPartParser.get_part_charset>sO���{�{�>�2���-�l�;�A�>�J�#���	�2�6�<�<�>�J��I�I�!�!�r&c���URRS5n[URS5nURUURUUS9nU$![[4a SnN2f=f)Nr}zcontent-lengthr)rr!r r")r�rQr�KeyErrorrXr>r!)r�eventrr r"�	containers      r#�start_file_streaming�$MultiPartParser.start_file_streamingMs{���}�}�(�(��8��	�'��
�
�6F�(G�H�N��'�'�!5��^�^�%�)�	(�139�	�����*�%�	��N�	�s�A�A(�'A(c�N�Sn[UURURS9n/n/n[URUR1405GH:nUR
U5 UR5n	[U	[[45(aMB[U	[5(aU	n141Sn/nURnGO�[U	[5(a#U	n142SnURX�5nURnGOi[U	[ 5(GaSURb4Ub1U[#U	R$5-
nX@R:�a143['5eW"U	R$5 U	R((d�[W144[5(aXSR+W5R-UR/U145R05S5n
URU146R2U
45 O�[4R6"[4R8[:W5nUR=S5 URU147R2[?UU148R@U149R2U150R0S945 UR5n	[U	[[45(dGM�GM= URCU5URCU54$)N)r?�	max_partsrr&�replace)r�)"rr?r<�_chunk_iterrhrv�receive_data�151next_event�152isinstancerrr�appendrr��writer
�len�datar�	more_data�joinrir�r��namer6r7r8r9�seekrr!rB)rrSr\r"�153field_sizera�fieldsrcr�r��current_partr��_write�values              r#rR�MultiPartParser.parse_s-��"&�154�"��!%�!:�!:��)�)�155����������T�-=�-=�>�D�����%��%�%�'�E� ���8�(<�=�=��e�U�+�+�#(�L�!"�J� "�I�&�-�-�F���t�,�,�#(�L�!%�J� $� 9� 9�%� P�I�&�_�_�F���t�,�,��0�0�<��AW�#�c�%�*�*�o�5�156�%�(A�(A�A�"7�"9�9��5�:�:�&� �?�?�%�l�E�:�:�$'�H�H�Y�$7�$>�$>� $� 5� 5�l�6J�6J� K�Y�%�E�#�M�M�<�+<�+<�e�*D�E�()���q�t�t�E�{�I�(F�I�%�N�N�1�-�!�L�L�$0�$5�$5�$/�(1�(4�(=�(=�(4�(9�(9�0<�0D�0D�	%&�!"�157��)�)�+��U!���8�(<�=�=�?�^�x�x������%��0�0r&)rvrBr?r<r>)NNNiN)r>rmr?r(rBrnrv�intr<r(r*rp)ryrrr*zte.NoReturn)r�r	r*rr)r�rrr(r*r+)rSr+r\r9r"r(r*z7tuple[MultiDict[str, str], MultiDict[str, FileStorage]])158r,r-r.r/rKrzr�r�rRr0rr&r#r_r_$s���15�+/�26�$�%)�
'�-�'�)�'�0�	'�159�'�#�
'�160�'�,"�
����1;��	��$@1�!�@1�-2�@1�DN�@1�	@�@1r&r_c#�B# �U"U5nU(dOUv� MSv� g7f)z�Read data in chunks for multipart/form-data parsing. Stop if no data is read.161Yield ``None`` at the end to signal end of parsing.162Nr)rh�sizer�s   r#r�r��s*�����D�z�����163�
��J�s�rr'rl)rErr>rmr?r(r@r(rBrnrAror<r(r*rq)rhzt.Callable[[int], bytes]r�r�r*zt.Iterator[bytes | None])4�164__future__r�typingr6�ior�urllib.parser�	_internalr�datastructuresrr	r165�166exceptionsr�httpr�sansio.multipartr
rrrrr�wsgirr�tempfiler�ImportErrorr�
TYPE_CHECKING�te�_typeshed.wsgir�tupler8r9rrrq�Protocolr�TypeVar�Callable�Anyr1r:rFrCr_r�rr&r#�<module>r�s���"���"�!�'�#�%�-�&�"�&�#�"�.�&�$�"� �-��?�?��.��	���U��Y�s�C�x�(�)�C��4D�*E�E��N�������I�I�c����C����J�/�0��"&�	
�$�
��
��
��	
�167�
�$-1�'+�%)�.2��
="�"&�="�
�="�)�="�%�="�#�	="�168169,�="�
�
="��="��="�@\3�\3�~{1�{1�|��Q� �&��� �s�,D5�5E�E
codekingpro/portable-devtools · Team Ai