
    %h-                        S SK Jr  S SKJr  S SK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5      r " S S\\\4   5      rSSKJr  g)    )annotationsN)BytesIO)fsdecode)fspath   )
_plain_int   )Headers)	MultiDictc                      \ rS rSrSr      S           SS jjrSS jr\SS j5       r\SS j5       r	\SS j5       r
\SS	 j5       r S     SS
 jjrSS jrSS jrSS jrSS jrSS jrSrg)FileStorage   a,  The :class:`FileStorage` class is a thin wrapper over incoming files.
It is used by the request object to represent uploaded files.  All the
attributes of the wrapper stream are proxied by the file storage so
it's possible to do ``storage.read()`` instead of the long form
``storage.stream.read()``.
Nc                .   X0l         U=(       d
    [        5       U l        Uc7  [        USS 5      nUb  [	        U5      nU(       a  US   S:X  a  US   S:X  a  S nO[	        U5      nX l        Uc
  [        5       nX`l        Ub  XFS'   Ub  [        U5      US'   g g )Nnamer   <>zContent-TypezContent-Length)	r   r   streamgetattrr   filenamer
   headersstr)selfr   r   r   content_typecontent_lengthr   s          \/var/www/auris/envauris/lib/python3.13/site-packages/werkzeug/datastructures/file_storage.py__init__FileStorage.__init__   s     	)	
 vvt4H##H-HQK3.8B<33F)H ?iG#&2N#%(+N(;G$% &    c                r    [        U S5      (       d&  [        R                  " U R                  5      U l        g g )N_parsed_content_type)hasattrhttpparse_options_headerr   r!   r   s    r   _parse_content_typeFileStorage._parse_content_type<   s.    t344(,(A(A$BSBS(TD% 5r   c                8    U R                   R                  S5      $ )z;The content-type sent in the header.  Usually not availablezcontent-type)r   getr%   s    r   r   FileStorage.content_type@   s     ||//r   c                v    SU R                   ;   a   [        U R                   S   5      $ g! [         a     gf = f)z=The content-length sent in the header.  Usually not availablezcontent-lengthr   )r   r   
ValueErrorr%   s    r   r   FileStorage.content_lengthE   sF     t||+!$,,/?"@AA   s   + 
88c                \    U R                  5         U R                  S   R                  5       $ )zLike :attr:`content_type`, but without parameters (eg, without
charset, type etc.) and always lowercase.  For example if the content
type is ``text/HTML; charset=utf-8`` the mimetype would be
``'text/html'``.

.. versionadded:: 0.7
r   )r&   r!   lowerr%   s    r   mimetypeFileStorage.mimetypeP   s*     	  "((+1133r   c                @    U R                  5         U R                  S   $ )zThe mimetype parameters as dict.  For example if the content
type is ``text/html; charset=utf-8`` the params would be
``{'charset': 'utf-8'}``.

.. versionadded:: 0.7
r	   )r&   r!   r%   s    r   mimetype_paramsFileStorage.mimetype_params\   s!     	  "((++r   c                $   SSK Jn  Sn[        US5      (       a  [        U5      n[	        U[
        5      (       a  [        US5      nSn U" U R                  X5        U(       a  UR                  5         gg! U(       a  UR                  5         f f = f)a  Save the file to a destination path or file object.  If the
destination is a file object you have to close it yourself after the
call.  The buffer size is the number of bytes held in memory during
the copy process.  It defaults to 16KB.

For secure file saving also have a look at :func:`secure_filename`.

:param dst: a filename, :class:`os.PathLike`, or open file
    object to write to.
:param buffer_size: Passed as the ``length`` parameter of
    :func:`shutil.copyfileobj`.

.. versionchanged:: 1.0
    Supports :mod:`pathlib`.
r   )copyfileobjF
__fspath__wbTN)	shutilr6   r"   r   
isinstancer   openr   close)r   dstbuffer_sizer6   	close_dsts        r   saveFileStorage.saveg   su    $ 	'	3%%+Cc3sD/CI	S6		 y		 s   	A5 5Bc                Z     U R                   R                  5         g! [         a     gf = f)z&Close the underlying file if possible.N)r   r<   	Exceptionr%   s    r   r<   FileStorage.close   s)    	KK 		s    
**c                ,    [        U R                  5      $ N)boolr   r%   s    r   __bool__FileStorage.__bool__   s    DMM""r   c                     [        U R                  U5      $ ! [         a?    [        U R                  S5      (       a"  [        U R                  R                  U5      s $ e f = f)N_file)r   r   AttributeErrorr"   rK   )r   r   s     r   __getattr__FileStorage.__getattr__   sT    	4;;-- 	 t{{G,,t{{00$77	s    AA!A!c                ,    [        U R                  5      $ rF   )iterr   r%   s    r   __iter__FileStorage.__iter__   s    DKK  r   c                l    S[        U 5      R                   SU R                  < SU R                  < S3$ )Nr   z: z (z)>)type__name__r   r   r%   s    r   __repr__FileStorage.__repr__   s5    4:&&'r$--):"T=N=N<QQSTTr   )r!   r   r   r   r   )NNNNNN)r   zt.IO[bytes] | Noner   
str | Noner   rX   r   rX   r   z
int | Noner   zHeaders | None)returnNone)rY   rX   )rY   int)rY   r   )rY   zdict[str, str])i @  )r=   z$str | os.PathLike[str] | t.IO[bytes]r>   r[   rY   rZ   )rY   rG   )r   r   rY   zt.Any)rY   zcabc.Iterator[bytes])rU   
__module____qualname____firstlineno____doc__r   r&   propertyr   r   r0   r3   r@   r<   rH   rM   rQ   rV   __static_attributes__ r   r   r   r      s     &*##'%)"&"<""< "< 	"<
 !"< #"<  "<HU 0 0   	4 	4 , , MR!7!FI!	!F#!Ur   r   c                  <    \ rS rSrSr  S         SS jjrSrg)FileMultiDict   zA special :class:`MultiDict` that has convenience methods to add
files to it.  This is used for :class:`EnvironBuilder` and generally
useful for unittesting.

.. versionadded:: 0.5
Nc           	     |   [        U[        5      (       a  U R                  X5        g[        U[        [        R
                  45      (       a&  Uc  [        R                  " U5      n[        US5      nOUnU(       a%  Uc"  [        R                  " U5      S   =(       d    SnU R                  U[        XSX5      5        g)a   Adds a new file to the dict.  `file` can be a file name or
a :class:`file`-like or a :class:`FileStorage` object.

:param name: the name of the field.
:param file: a filename or :class:`file`-like object
:param filename: an optional filename
:param content_type: an optional content type
Nrbr   zapplication/octet-stream)
r:   r   addr   osPathLiker   r;   	mimetypes
guess_type)r   r   filer   r   file_objs         r   add_fileFileMultiDict.add_file   s     dK((HHT dS"++.//99T?$(t$4HH,$$X.q1O5O  	{8tJKr   rb   )NN)
r   r   rm   z2str | os.PathLike[str] | t.IO[bytes] | FileStorager   rX   r   rX   rY   rZ   )rU   r\   r]   r^   r_   ro   ra   rb   r   r   rd   rd      sQ      $#' L L A L 	 L
 ! L 
 L  Lr   rd   )r#   )
__future__r   collections.abcabccabcrk   ri   typingtior   r   r   	_internalr   r   r
   
structuresr   r   r   rd    r#   rb   r   r   <module>r{      sS    "   	     "  !RU RUj(LIc;./ (LX r   