
    hvL                       S SK Jr  S SKrS SKrS SKJr  S SKJr  SSK	J
r
  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr   S SKJr  \RB                  (       a>  S SKr"S SK#J$r$  \RJ                  \RL                  \'   \\4   r( " S S\"RR                  5      r*\RV                  " S\RX                  S\RZ                  4   S9r. S$         S%S jjr/       S&SS.                   S'S jjjr0 " S S 5      r1 " S! S"5      r2S(S# jr3g! \ a    S SKJ r   Sr Nf = f))    )annotationsN)BytesIO)	parse_qsl   )
_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    \ rS rSr S         SS jjrSrg)TStreamFactory&   Nc                    g N )selftotal_content_lengthcontent_typefilenamecontent_lengths        hC:\Users\ROHAN GUPTA\OneDrive\Desktop\mathbuddy-assessment\venv\Lib\site-packages\werkzeug/formparser.py__call__TStreamFactory.__call__'   s         r   r   
r   
int | Noner    
str | Noner!   r)   r"   r(   returnt.IO[bytes])__name__
__module____qualname____firstlineno__r$   __static_attributes__r   r&   r#   r   r   &   sA     *.	",	 %	 !		
 '	 	 	r&   r   F.)boundc                
   Sn[         b4  [        R                  " [        R                  [           [        USS95      $ U b  X:  a5  [        R                  " [        R                  [           [        S5      5      $ [        5       $ )Ni  zrb+)max_sizemode)r   tcastIObytesr   r   )r   r    r!   r"   r4   s        r#   default_stream_factoryr:   4   sc     H'vvadd5k#7PU#VWW		%)=)Hvvadd5k=#7889r&   max_form_partsc               @    [        UUUUUUUUS9R                  U 5      $ )a?  Parse the form data in the environ and return it as tuple in the form
``(stream, form, files)``.  You should only call this method if the
transport method is `POST`, `PUT`, or `PATCH`.

If the mimetype of the data transmitted is `multipart/form-data` the
files multidict will be filled with `FileStorage` objects.  If the
mimetype is unknown the input stream is wrapped and returned as first
argument, else the stream is empty.

This is a shortcut for the common usage of :class:`FormDataParser`.

:param environ: the WSGI environment to be used for parsing.
:param stream_factory: An optional callable that returns a new read and
                       writeable file descriptor.  This callable works
                       the same as :meth:`Response._get_file_stream`.
:param max_form_memory_size: the maximum number of bytes to be accepted for
                       in-memory stored form data.  If the data
                       exceeds the value specified an
                       :exc:`~exceptions.RequestEntityTooLarge`
                       exception is raised.
:param max_content_length: If this is provided and the transmitted data
                           is longer than this value an
                           :exc:`~exceptions.RequestEntityTooLarge`
                           exception is raised.
:param cls: an optional dict class to use.  If this is not specified
                   or `None` the default :class:`MultiDict` is used.
:param silent: If set to False parsing errors will not be caught.
:param max_form_parts: The maximum number of multipart parts to be parsed. If this
    is exceeded, a :exc:`~exceptions.RequestEntityTooLarge` exception is raised.
:return: A tuple in the form ``(stream, form, files)``.

.. versionchanged:: 2.3
    Added the ``max_form_parts`` parameter.

.. versionchanged:: 2.3
    The ``charset`` and ``errors`` parameters are deprecated and will be removed in
    Werkzeug 3.0.

.. versionadded:: 0.5.1
   Added the ``silent`` parameter.

.. versionadded:: 0.5
   Added the ``max_form_memory_size``, ``max_content_length``, and ``cls``
   parameters.
)stream_factorycharseterrorsmax_form_memory_sizemax_content_lengthr<   silentcls)FormDataParserparse_from_environ)	environr>   r?   r@   rA   rB   rD   rC   r<   s	            r#   parse_form_datarH   D   s7    r %1-%	 !	"r&   c                      \ rS rSr% Sr       SSS.                 SS jjjr      SS jrSS jr S         SS jjr          SS	 jr	          SS
 jr
0 rS\S'   Srg)rE      a  This class implements parsing of form data for Werkzeug.  By itself
it can parse multipart and url encoded form data.  It can be subclassed
and extended but for most mimetypes it is a better idea to use the
untouched stream and expose it as separate attributes on a request
object.

:param stream_factory: An optional callable that returns a new read and
                       writeable file descriptor.  This callable works
                       the same as :meth:`Response._get_file_stream`.
:param max_form_memory_size: the maximum number of bytes to be accepted for
                       in-memory stored form data.  If the data
                       exceeds the value specified an
                       :exc:`~exceptions.RequestEntityTooLarge`
                       exception is raised.
:param max_content_length: If this is provided and the transmitted data
                           is longer than this value an
                           :exc:`~exceptions.RequestEntityTooLarge`
                           exception is raised.
:param cls: an optional dict class to use.  If this is not specified
                   or `None` the default :class:`MultiDict` is used.
:param silent: If set to False parsing errors will not be caught.
:param max_form_parts: The maximum number of multipart parts to be parsed. If this
    is exceeded, a :exc:`~exceptions.RequestEntityTooLarge` exception is raised.

.. versionchanged:: 2.3
    The ``charset`` and ``errors`` parameters are deprecated and will be removed in
    Werkzeug 3.0.

.. versionchanged:: 2.3
    The ``parse_functions`` attribute and ``get_parse_func`` methods are deprecated
    and will be removed in Werkzeug 3.0.

.. versionchanged:: 2.2.3
    Added the ``max_form_parts`` parameter.

.. versionadded:: 0.8
Nr;   c                  Uc  [         nXl        Ub  [        R                  " S[        SS9  OSnX l        Ub  [        R                  " S[        SS9  OSnX0l        X@l        XPl        Xl	        Uc  [        nX`l        Xpl        g NzJThe 'charset' parameter is deprecated and will be removed in Werkzeug 3.0.   
stacklevelutf-8zIThe 'errors' parameter is deprecated and will be removed in Werkzeug 3.0.replace)r:   r>   warningswarnDeprecationWarningr?   r@   rA   rB   r<   r
   rD   rC   )	r   r>   r?   r@   rA   rB   rD   rC   r<   s	            r#   __init__FormDataParser.__init__   s     !3N,MM,"	 GMM,"	 F$8!"4,;Cr&   c                ~   [         R                  " S[        SS9  US:X  a  [        U 5      R                  $ US:X  a  [        U 5      R
                  $ US:X  a/  [         R                  " S[        SS9  [        U 5      R
                  $ XR                  ;   a)  [         R                  " S[        SS9  U R                  U   $ g )	NzNThe 'get_parse_func' method is deprecated and will be removed in Werkzeug 3.0.rM   rN   multipart/form-data!application/x-www-form-urlencodedapplication/x-url-encodedThe 'application/x-url-encoded' mimetype is invalid, and will not be treated as 'application/x-www-form-urlencoded' in Werkzeug 3.0.lThe 'parse_functions' attribute is deprecated and will be removed in Werkzeug 3.0. Override 'parse' instead.)rR   rS   rT   type_parse_multipart_parse_urlencodedparse_functions)r   mimetypeoptionss      r#   get_parse_funcFormDataParser.get_parse_func   s     	(		
 ,,:...<<:///44MMS"	 :///---MM;"	 ''11r&   c                    [        XR                  S9n[        U5      n[        UR	                  S5      5      u  pEU R                  UUUUS9$ )zParses the information from the environment as form data.

:param environ: the WSGI environment to be used for parsing.
:return: A tuple in the form ``(stream, form, files)``.
)rB   CONTENT_TYPE)r"   ra   rb   )r   rB   r   r   getparse)r   rG   streamr"   ra   rb   s         r#   rF   !FormDataParser.parse_from_environ  sV     "'>U>UV+G40^1LMzz)	  
 	
r&   c                .   US:X  a  U R                   nOUS:X  a  U R                  nOUS:X  a'  [        R                  " S[        SS9  U R                  nOrX R
                  ;   aC  [        R                  " S[        SS9  U R
                  U   R                  U [        U 5      5      nO XR                  5       U R                  5       4$ Uc  0 n U" XX45      $ ! [         a    U R                  (       d  e  Of = fXR                  5       U R                  5       4$ )a=  Parses the information from the given stream, mimetype,
content length and mimetype parameters.

:param stream: an input stream
:param mimetype: the mimetype of the data
:param content_length: the content length of the incoming data
:param options: optional mimetype parameters (used for
                the multipart boundary for instance)
:return: A tuple in the form ``(stream, form, files)``.

.. versionchanged:: 2.3
    The ``application/x-url-encoded`` content type is deprecated and will not be
    treated as ``application/x-www-form-urlencoded`` in Werkzeug 3.0.
rX   rY   rZ   r[   rM   rN   r\   )r^   r_   rR   rS   rT   r`   __get__r]   rD   
ValueErrorrC   )r   ri   ra   r"   rb   
parse_funcs         r#   rh   FormDataParser.parse  s
   * ,,..J<<//J44MMS"	 //J---MM;"	 --h7??d4jQJ88:txxz11?G	fHH 	;; 	 xxz488:--s   C C43C4c           	     |   U R                   S:w  a  U R                   OS nU R                  S:w  a  U R                  OS n[        U R                  UUU R                  U R
                  U R                  S9nUR                  SS5      R                  S5      nU(       d  [        S5      eUR                  XU5      u  pXU
4$ )NrP   rQ   )r>   r?   r@   rA   r<   rD   boundary asciizMissing boundary)r?   r@   MultiPartParserr>   rA   r<   rD   rg   encoderm   rh   )r   ri   ra   r"   rb   r?   r@   parserrq   formfiless              r#   r^   FormDataParser._parse_multipartO  s     #',,'"9$,,t $y 8d ..!%!:!:..
 ;;z2.55g>/00ll6^DU""r&   c                6   U R                   b  Ub  X0R                   :  a
  [        5       e [        UR                  5       R	                  5       SU R
                  SS9nXR                  U5      U R                  5       4$ ! [         a  n[        5       UeS nAff = f)NTzwerkzeug.url_quote)keep_blank_valuesencodingr@   )rA   r   r   readdecoder?   rm   rD   )r   ri   ra   r"   rb   itemses          r#   r_    FormDataParser._parse_urlencodedh  s     %%1*!:!::'))	1$$&"&+	E xx
22  	1')q0	1s   2A> >
BBBzedict[str, t.Callable[[FormDataParser, t.IO[bytes], str, int | None, dict[str, str]], t_parse_result]]r`   )r?   rD   r@   rB   rA   r<   rC   r>   NNNNNNT)r>   TStreamFactory | Noner?   r)   r@   r)   rA   r(   rB   r(   rD   type[MultiDict] | NonerC   boolr<   r(   r*   None)ra   strrb   dict[str, str]r*   zaNone | t.Callable[[FormDataParser, t.IO[bytes], str, int | None, dict[str, str]], t_parse_result])rG   r   r*   t_parse_resultr   )
ri   r+   ra   r   r"   r(   rb   zdict[str, str] | Noner*   r   )
ri   r+   ra   r   r"   r(   rb   r   r*   r   )r,   r-   r.   r/   __doc__rU   rc   rF   rh   r^   r_   r`   __annotations__r0   r   r&   r#   rE   rE      sf   $P 15"!+/)-&*0 &*0-0 0 	0
 )0 '0 $0 0 #0 
0d$$&4$
$L
* *.5.5. 5. #	5.
 '5. 
5.n## # #	#
  # 
#233 3 #	3
  3 
3@ 	   r&   rE   c                      \ rS rSr       S	               S
S jjrSS jrSS jr      SS jr        SS jrSr	g)rt   i  Nc                    Ub  [         R                  " S[        SS9  OSnX l        Ub  [         R                  " S[        SS9  OSnX0l        X@l        Xpl        Uc  [        nXl        Uc  [        nXPl
        X`l        g rL   )rR   rS   rT   r?   r@   rA   r<   r:   r>   r
   rD   buffer_size)r   r>   r?   r@   rA   rD   r   r<   s           r#   rU   MultiPartParser.__init__  s     MM,"	 GMM,"	 F$8!,!3N,;C&r&   c                    [        U5      er   )rm   )r   messages     r#   failMultiPartParser.fail  s    !!r&   c                    UR                  S5      nU(       a6  [        U5      S   nUR                  SS5      R                  5       nUS;   a  U$ U R                  $ )Ncontent-typer   r?   rr   >   rs   rP   us-ascii
iso-8859-1)rg   r   lowerr?   )r   headersr    
parameters
ct_charsets        r#   get_part_charset MultiPartParser.get_part_charset  sV    {{>2-l;A>J#	26<<>J II!!||r&   c                    UR                   R                  S5      n [        UR                   S   5      nU R                  UUR                  UUS9nU$ ! [        [        4 a    Sn N2f = f)Nr   zcontent-lengthr   )r   r!   r    r"   )r   rg   r   KeyErrorrm   r>   r!   )r   eventr   r    r"   	containers         r#   start_file_streaming$MultiPartParser.start_file_streaming  s{     }}((8	'6F(GHN ''!5^^%)	 ( 
	  *% 	N	s   A A('A(c                   [        UU R                  U R                  S9n/ n/ n[        UR                  U R
                  5       GH  nUR                  U5        UR                  5       n[        U[        [        45      (       a  MB  [        U[        5      (       a  Un	/ n
U
R                  nGOh[        U[        5      (       a!  Un	U R                  X5      n
U
R                  nGO2[        U[         5      (       Ga  W" UR"                  5        UR$                  (       d  [        W	[        5      (       ab  SR'                  W
5      R)                  U R+                  U	R,                  5      U R.                  5      nUR                  U	R0                  U45        O[2        R4                  " [2        R6                  [8           W
5      n
U
R;                  S5        UR                  U	R0                  [=        U
U	R>                  U	R0                  U	R,                  S945        UR                  5       n[        U[        [        45      (       d  GM  GM     U RA                  U5      U RA                  U5      4$ )N)rA   	max_partsr&   r   )r   )!r   rA   r<   _chunk_iterr}   r   receive_data
next_event
isinstancer   r   r   appendr   r   writer   data	more_datajoinr~   r   r   r@   namer6   r7   r8   r9   seekr   r!   rD   )r   ri   rq   r"   rv   fieldsrx   r   r   current_partr   _writevalues                r#   rh   MultiPartParser.parse  s    "!%!:!:))
 T-=-=>D%%%'E 8(<==eU++#(L "I&--Ft,,#(L $ 9 9% PI&__Ft,,5::& ??%lE::$'HHY$7$>$> $ 5 5l6J6J KT[[%E #MM<+<+<e*DE()qttE{I(FI%NN1-!LL$0$5$5$/(1(4(=(=(4(9(90<0D0D	%&!"
 ))+A !8(<== ?J xx%00r&   )r   r?   rD   r@   rA   r<   r>   )NNNNNi   N)r>   r   r?   r)   r@   r)   rA   r(   rD   r   r   intr<   r(   r*   r   )r   r   r*   zte.NoReturn)r   r	   r*   r   )r   r   r   r(   r*   r+   )ri   r+   rq   r9   r"   r(   r*   ztuple[MultiDict, MultiDict])
r,   r-   r.   r/   rU   r   r   r   rh   r0   r   r&   r#   rt   rt     s     15"!+/&*$%)-'--' -' 	-'
 )-' $-' -' #-' 
-'^"1;	$51!51-251DN51	$51r&   rt   c              #  B   #     U " U5      nU(       d  OUv   M  Sv   g7f)zRead data in chunks for multipart/form-data parsing. Stop if no data is read.
Yield ``None`` at the end to signal end of parsing.
Nr   )r}   sizer   s      r#   r   r     s*      Dz
  Js   r   r'   r   )rG   r   r>   r   r?   r)   r@   r)   rA   r(   rB   r(   rD   r   rC   r   r<   r(   r*   r   )r}   zt.Callable[[int], bytes]r   r   r*   zt.Iterator[bytes | None])4
__future__r   typingr6   rR   ior   urllib.parser   	_internalr   datastructuresr   r	   r
   
exceptionsr   httpr   sansio.multipartr   r   r   r   r   r   wsgir   r   tempfiler   ImportErrorr   TYPE_CHECKINGte_typeshed.wsgir   Tupler8   r9   r   Protocolr   TypeVarCallableAnyr1   r:   rH   rE   rt   r   r   r&   r#   <module>r      s   "    " ! ' # % - & " & # " . & $ " - ??.WWQTT%[)Y>?N  IIcCJ/0 "&	$  	
 $ -1'+%)"&B" "&B"B")B" B" 	B"
 %B" #B" 
 B" B" B" B"J DI1 I1Xy   & s   0D? ?EE