zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
U
Þ=®d(ã@s~ddlmZddlZddlmZddlmZddlmZddlm    Z    dd    l
m Z Gd
d „d ƒZ Gd d „d e ƒZ ddlmZdS)é)Ú annotationsN)ÚBytesIO)Úfsdecode)Úfspathé)Ú
_plain_inté)Ú    MultiDictc@s„eZdZdZddd„Zdd„Zedd„ƒZed    d
„ƒZed d „ƒZ    ed d„ƒZ
ddd„Z dd„Z dd„Z dd„Zdd„Zdd„ZdS)Ú FileStoragea@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()``.
    NcCs®||_|ptƒ|_|dkrXt|ddƒ}|dk    r6t|ƒ}|r`|ddkr`|ddkr`d}nt|ƒ}||_|dkr€ddlm}|ƒ}||_|dk    r–||d<|dk    rªt|ƒ|d    <dS)
NÚnamerú<éÿÿÿÿú>r)ÚHeadersz Content-TypezContent-Length)    r rÚstreamÚgetattrrÚfilenameÚheadersrÚstr)Úselfrrr Ú content_typeÚcontent_lengthrr©rú[d:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\werkzeug/datastructures/file_storage.pyÚ__init__s$       zFileStorage.__init__cCst|dƒst |j¡|_dS)NÚ_parsed_content_type)ÚhasattrÚhttpZparse_options_headerrr©rrrrÚ_parse_content_type:s
zFileStorage._parse_content_typecCs |j d¡S)z;The content-type sent in the header.  Usually not availablez content-type)rÚgetrrrrr>szFileStorage.content_typecCs4d|jkr0zt|jdƒWStk
r.YnXdS)z=The content-length sent in the header.  Usually not availablezcontent-lengthr)rrÚ
ValueErrorrrrrrCs 
zFileStorage.content_lengthcCs| ¡|jd ¡S)aLike :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)rrÚlowerrrrrÚmimetypeNs    zFileStorage.mimetypecCs| ¡|jdS)zÇThe 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)rrrrrrÚmimetype_paramsZszFileStorage.mimetype_paramsé@cCs`ddlm}d}t|dƒr"t|ƒ}t|tƒr:t|dƒ}d}z||j||ƒW5|rZ| ¡XdS)anSave 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)    Úshutilr&rrÚ
isinstancerÚopenÚcloser)rÚdstÚ buffer_sizer&Z    close_dstrrrÚsavees 
 
 
zFileStorage.savecCs(z|j ¡Wntk
r"YnXdS)z&Close the underlying file if possible.N)rr,Ú    Exceptionrrrrr,†szFileStorage.closecCs
t|jƒS©N)ÚboolrrrrrÚ__bool__szFileStorage.__bool__cCsHzt|j|ƒWStk
rBt|jdƒr<t|jj|ƒYS‚YnXdS)NÚ_file)rrÚAttributeErrorrr4)rr rrrÚ __getattr__s  zFileStorage.__getattr__cCs
t|jƒSr1)ÚiterrrrrrÚ__iter__›szFileStorage.__iter__cCs"dt|ƒj›d|j›d|j›dS)Nr z: z (z)>)ÚtypeÚ__name__rrrrrrÚ__repr__žszFileStorage.__repr__)NNNNNN)r%)r:Ú
__module__Ú __qualname__Ú__doc__rrÚpropertyrrr#r$r/r,r3r6r8r;rrrrr
s.    ù
&
 
 
 
 
 
 
! r
c@seZdZdZddd„ZdS)Ú FileMultiDictzÅA 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
    NcCslt|tƒr|}nLt|tƒr0|dkr&|}t|dƒ}|rN|dkrNt |¡dpLd}t||||ƒ}| ||¡dS)aPAdds 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Úrbrzapplication/octet-stream)r*r
rr+Ú    mimetypesÚ
guess_typeÚadd)rr ÚfilerrÚvaluerrrÚadd_fileªs    
 
 
 ÿzFileMultiDict.add_file)NN)r:r<r=r>rGrrrrr@¢sr@)r)Ú
__future__rrBÚiorÚosrrÚ    _internalrÚ
structuresr    r
r@ÚrrrrrÚ<module>s      "