zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
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
U
Þ=®d%ã@sNddlmZGdd„dƒZGdd„dƒZdd„ZGdd    „d    ƒZd
d lmZd S) é)Ú annotationsc@s2eZdZdZd dd„Zdd„Zdd„Zd    d
„ZdS) ÚIfRangez½Very simple object that represents the `If-Range` header in parsed
    form.  It will either have neither a etag or date or one of either but
    never both.
 
    .. versionadded:: 0.7
    NcCs||_||_dS©N)ÚetagÚdate)Úselfrr©rúTd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\werkzeug/datastructures/range.pyÚ__init__ szIfRange.__init__cCs0|jdk    rt |j¡S|jdk    r,t |j¡SdS)ú-Converts the object back into an HTTP header.NÚ)rÚhttpZ    http_daterZ
quote_etag©rrrr    Ú    to_headers
 
 
 zIfRange.to_headercCs| ¡Sr©rrrrr    Ú__str__szIfRange.__str__cCsdt|ƒj›dt|ƒ›dS©Nú<ú ú>©ÚtypeÚ__name__Ústrrrrr    Ú__repr__szIfRange.__repr__)NN)rÚ
__module__Ú __qualname__Ú__doc__r
rrrrrrr    rs
 
rc@sHeZdZdZdd„Zdd„Zdd„Zdd    „Zd
d „Zd d „Z    dd„Z
dS)ÚRangeaXRepresents a ``Range`` header. All methods only support only
    bytes as the unit. Stores a list of ranges if given, but the methods
    only work if only one range is provided.
 
    :raise ValueError: If the ranges provided are invalid.
 
    .. versionchanged:: 0.15
        The ranges passed in are validated.
 
    .. versionadded:: 0.7
    cCsP||_||_|D]:\}}|dks8|dk    r|dks8||krt||f›dƒ‚qdS)Nrz is not a valid range.)ÚunitsÚrangesÚ
ValueError)rrr ÚstartÚendrrr    r
/s
  zRange.__init__cCsn|jdks |dks t|jƒdkr$dS|jd\}}|dkrN|}|dkrN||7}t |||¡rj|t||ƒfSdS)z·If the range is for bytes, the length is not None and there is
        exactly one range and it is satisfiable it returns a ``(start, stop)``
        tuple, otherwise `None`.
        ÚbytesNér)rÚlenr r Úis_byte_range_validÚmin)rÚlengthr"r#rrr    Úrange_for_length:s zRange.range_for_lengthcCs.| |¡}|dk    r*t|j|d|d|ƒSdS)zCreates a :class:`~werkzeug.datastructures.ContentRange` object
        from the current range and given content length.
        Nrr%)r*Ú ContentRanger)rr)Úrngrrr    Úmake_content_rangeJs
zRange.make_content_rangecCslg}|jD]J\}}|dkr<| |dkr0|›dnt|ƒ¡q
| |›d|d›¡q
|j›dd |¡›S)r Nrú-r%ú=ú,)r ÚappendrrÚjoin)rr Úbeginr#rrr    rSs "zRange.to_headercCs>| |¡}|dk    r:|j›d|d›d|dd›d|›SdS)z\Converts the object into `Content-Range` HTTP header,
        based on given length
        Nrrr.r%ú/)r*r)rr)Úrangerrr    Úto_content_range_header]s
(zRange.to_content_range_headercCs| ¡Srrrrrr    rfsz Range.__str__cCsdt|ƒj›dt|ƒ›dSrrrrrr    riszRange.__repr__N) rrrrr
r*r-rr6rrrrrr    r"s      
    rcs"‡fdd„}‡fdd„}t||ƒS)Ncs
t|ˆƒSr)Úgetattrr©Únamerr    Úfgetnsz _callback_property.<locals>.fgetcs$t|ˆ|ƒ|jdk    r | |¡dSr)ÚsetattrÚ    on_update)rÚvaluer8rr    Úfsetqs 
z _callback_property.<locals>.fset)Úproperty)r9r:r>rr8r    Ú_callback_propertyms  r@c@sleZdZdZddd„ZedƒZedƒZedƒZedƒZ    dd
d „Z
d d „Z dd„Z dd„Z dd„Zdd„ZdS)r+zDRepresents the content range header.
 
    .. versionadded:: 0.7
    NcCs0t |||¡stdƒ‚||_| ||||¡dS)NúBad range provided)r r'ÚAssertionErrorr<Úset)rrr"Ústopr)r<rrr    r
szContentRange.__init__Ú_unitsÚ_startÚ_stopÚ_lengthr$cCsFt |||¡stdƒ‚||_||_||_||_|jdk    rB| |¡dS)z#Simple method to update the ranges.rAN)r r'rBrErFrGrHr<)rr"rDr)rrrr    rCŽs
zContentRange.setcCs|jdddddS)zcSets the units to `None` which indicates that the header should
        no longer be used.
        N©r)rCrrrr    Úunset˜szContentRange.unsetcCsb|jdkrdS|jdkrd}n|j}|jdkr>|j›d|›S|j›d|j›d|jd›d|›S)Nr Ú*z */rr.r%r4)rr)r"rD)rr)rrr    ržs
 
 
zContentRange.to_headercCs
|jdk    SrrIrrrr    Ú__bool__©szContentRange.__bool__cCs| ¡Srrrrrr    r¬szContentRange.__str__cCsdt|ƒj›dt|ƒ›dSrrrrrr    r¯szContentRange.__repr__)NN)Nr$)rrrrr
r@rr"rDr)rCrJrrLrrrrrr    r+ys
 
 
 r+é)r N)Ú
__future__rrrr@r+r r rrrr    Ú<module>s
K ;