
    i                         S SK r S SKrS SKJr  SSKJr  \(       a  S SKJrJr  \" SSS9r " S	 S
\\   5      r	 " S S5      r
 " S S5      rg)    N)TYPE_CHECKING   )DecodeError)ProtocolTypeVar	_T_contraT)contravariantc                   &    \ rS rSrS\S\4S jrSrg)SupportsWrite   _SupportsWrite__breturnc                     g N )selfr   s     a/var/www/html/qgis-automation/mouza_env/lib/python3.13/site-packages/python_multipart/decoders.pywriteSupportsWrite.write   s    3    r   N)__name__
__module____qualname____firstlineno__r   objectr   __static_attributes__r   r   r   r   r      s    6Y666r   r   c                   V    \ rS rSrSrSS jrS\S\4S jrSS jr	SS	 jr
S\4S
 jrSrg)Base64Decoder   aP  This object provides an interface to decode a stream of Base64 data.  It
is instantiated with an "underlying object", and whenever a write()
operation is performed, it will decode the incoming data as Base64, and
call write() on the underlying object.  This is primarily used for decoding
form data encoded as Base64, but can be used for other purposes::

    from python_multipart.decoders import Base64Decoder
    fd = open("notb64.txt", "wb")
    decoder = Base64Decoder(fd)
    try:
        decoder.write("Zm9vYmFy")       # "foobar" in Base64
        decoder.finalize()
    finally:
        decoder.close()

    # The contents of "notb64.txt" should be "foobar".

This object will also pass all finalize() and close() calls to the
underlying object, if the underlying object supports them.

Note that this class maintains a cache of base64 chunks, so that a write of
arbitrary size can be performed.  You must call :meth:`finalize` on this
object after all writes are completed to ensure that all data is flushed
to the underlying object.

:param underlying: the underlying object to pass writes to
r   Nc                 .    [        5       U l        Xl        g r   )	bytearraycache
underlyingr   r#   s     r   __init__Base64Decoder.__init__2   s    [
$r   datac                    [        U R                  5      S:  a  U R                  U-   n[        U5      S-  S-  nUSU n[        U5      S:  a2   [        R                  " U5      nU R                  R                  U5        [        U5      S-  nUS:  a  X* S U R                  SS& OSU R                  SS& [        U5      $ ! [        R
                   a    [        S5      ef = f)a  Takes any input data provided, decodes it as base64, and passes it
on to the underlying object.  If the data provided is invalid base64
data, then this method will raise
a :class:`python_multipart.exceptions.DecodeError`

:param data: base64 data to decode
r      Nz=There was an error raised while decoding base64-encoded data.r   )	lenr"   base64	b64decodebinasciiErrorr   r#   r   )r   r'   
decode_lenvaldecodedremaining_lens         r   r   Base64Decoder.write6   s     tzz?Q::$D $i1n)
;J s8a<c **3/ OO!!'* D	A1 1DJJqMDJJqM 4y >> c!"abbcs   C  C!c                 p    [        U R                  S5      (       a  U R                  R                  5         ggzbClose this decoder.  If the underlying object has a `close()`
method, this function will call it.
closeNhasattrr#   r6   r   s    r   r6   Base64Decoder.closeZ   *     4??G,,OO!!# -r   c                     [        U R                  5      S:  a!  [        S[        U R                  5      -  5      e[        U R                  S5      (       a  U R                  R                  5         gg)a+  Finalize this object.  This should be called when no more data
should be written to the stream.  This function can raise a
:class:`python_multipart.exceptions.DecodeError` if there is some remaining
data in the cache.

If the underlying object has a `finalize()` method, this function will
call it.
r   zQThere are %d bytes remaining in the Base64Decoder cache when finalize() is calledfinalizeN)r*   r"   r   r8   r#   r=   r9   s    r   r=   Base64Decoder.finalizea   s^     tzz?Qcfijnjtjtfuu  4??J//OO$$& 0r   c                 P    U R                   R                   SU R                  < S3$ Nz(underlying=)	__class__r   r#   r9   s    r   __repr__Base64Decoder.__repr__r   %    ..))*,t6IKKr   r"   r#   r#   zSupportsWrite[bytes]r   Nr   Nr   r   r   r   __doc__r%   bytesintr   r6   r=   strrD   r   r   r   r   r   r      s8    8%"% "C "H$'"L# Lr   r   c                   V    \ rS rSrSrSS jrS\S\4S jrSS jr	SS	 jr
S\4S
 jrSrg)QuotedPrintableDecoderv   au  This object provides an interface to decode a stream of quoted-printable
data.  It is instantiated with an "underlying object", in the same manner
as the :class:`python_multipart.decoders.Base64Decoder` class.  This class behaves
in exactly the same way, including maintaining a cache of quoted-printable
chunks.

:param underlying: the underlying object to pass writes to
r   Nc                     SU l         Xl        g )Nr   rG   r$   s     r   r%   QuotedPrintableDecoder.__init__   s    
$r   r'   c                 <   [        U R                  5      S:  a  U R                  U-   nUSS R                  S5      S:w  a
  USS USS p2OUnSn[        U5      S:  a/  U R                  R	                  [
        R                  " U5      5        X0l        [        U5      $ )zTakes any input data provided, decodes it as quoted-printable, and
passes it on to the underlying object.

:param data: quoted-printable data to decode
r   N   =r   )r*   r"   findr#   r   r-   a2b_qp)r   r'   encrests       r   r   QuotedPrintableDecoder.write   s     tzz?Q::$D
 9>>$2%Sb	49CD s8a<OO!!(//#"67 
4yr   c                 p    [        U R                  S5      (       a  U R                  R                  5         ggr5   r7   r9   s    r   r6   QuotedPrintableDecoder.close   r;   r   c                 "   [        U R                  5      S:  a@  U R                  R                  [        R
                  " U R                  5      5        SU l        [        U R                  S5      (       a  U R                  R                  5         gg)a<  Finalize this object.  This should be called when no more data
should be written to the stream.  This function will not raise any
exceptions, but it may write more data to the underlying object if
there is data remaining in the cache.

If the underlying object has a `finalize()` method, this function will
call it.
r   r   r=   N)r*   r"   r#   r   r-   rY   r8   r=   r9   s    r   r=   QuotedPrintableDecoder.finalize   sb     tzz?QOO!!(//$**"=>DJ 4??J//OO$$& 0r   c                 P    U R                   R                   SU R                  < S3$ r@   rB   r9   s    r   rD   QuotedPrintableDecoder.__repr__   rF   r   rG   rH   rI   rJ   r   r   r   rP   rP   v   s7    %% C 6$'$L# Lr   rP   )r+   r-   typingr   
exceptionsr   r   r   r   r   r   rP   r   r   r   <module>re      sQ        #(48I7+ 7^L ^LBCL CLr   