o
    ßý°jï%  ã                   @  s²   d dl mZ d dlmZ d dlZd dlmZ ddl	m
Z
 ddlmZ ddœddd„ZG dd„ deeeje f ƒZG dd„ de
eeje f eƒZG dd„ deƒZddlmZ dS )é    )ÚannotationsN)Úcleandocé   )ÚImmutableDictMixin)ÚCallbackDict©ÚdocÚkeyÚstrÚemptyút.AnyÚtypeútype[t.Any] | Noner   ú
str | NoneÚreturnc                  s²   |du r@dˆ› d�g}ˆt u r| d¡ n&ˆdu r| d¡ n
| dˆj› d�¡ ˆ dur6| dˆ ›d	�¡ | d
¡ d |¡}t‡ ‡‡fdd„‡‡fdd„‡fdd„t|ƒd�S )a±  Return a new property object for a cache header. Useful if you
    want to add support for a cache extension in a subclass.

    :param key: The attribute name present in the parsed cache-control header dict.
    :param empty: The value to use if the key is present without a value.
    :param type: The type to convert the string value to instead of a string. If
        conversion raises a ``ValueError``, the returned value is ``None``.
    :param doc: The docstring for the property. If not given, it is generated
        based on the other params.

    .. versionchanged:: 3.1
        Added the ``doc`` param.

    .. versionchanged:: 2.0
        Renamed from ``cache_property``.
    NzThe ``z`` attribute.z"A ``bool``, either present or not.z
A ``str``,zA ``z``,z``z`` if present with no value,zor ``None`` if not present.ú c                   s   |   ˆˆ ˆ¡S ©N)Ú_get_cache_value©Úx©r   r	   r   © ú˜/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/werkzeug/datastructures/cache_control.pyÚ<lambda>1   ó    z(cache_control_property.<locals>.<lambda>c                   s   |   ˆ |ˆ¡S r   )Ú_set_cache_value)r   Úv)r	   r   r   r   r   2   r   c                   s
   |   ˆ ¡S r   )Ú_del_cache_valuer   )r	   r   r   r   3   s   
 r   )ÚboolÚappendÚ__name__ÚjoinÚpropertyr   )r	   r   r   r   Úpartsr   r   r   Úcache_control_property   s"   


ür$   c                      s¾   e Zd ZU dZeddeƒZded< eddeƒZ	ded< ed	deƒZ
ded
< eddeƒZded< 		d)d*‡ fdd„Zd+dd„Zd,dd „Zd-d!d"„Zd.d#d$„Zd.d%d&„Zd.d'd(„ZeeƒZ‡  ZS )/Ú_CacheControla¸  Subclass of a dict that stores values for a Cache-Control header.  It
    has accessors for all the cache-control directives specified in RFC 2616.
    The class does not differentiate between request and response directives.

    Because the cache-control directives in the HTTP header use dashes the
    python descriptors use underscores for that.

    To get a header of the :class:`CacheControl` object again you can convert
    the object into a string or call the :meth:`to_header` method.  If you plan
    to subclass it and add your own items have a look at the sourcecode for
    that class.

    .. versionchanged:: 3.1
        Dict values are always ``str | None``. Setting properties will
        convert the value to a string. Setting a non-bool property to
        ``False`` is equivalent to setting it to ``None``. Getting typed
        properties will return ``None`` if conversion raises
        ``ValueError``, rather than the string.

    .. versionchanged:: 2.1
        Setting int properties such as ``max_age`` will convert the
        value to an int.

    .. versionchanged:: 0.4
       Setting ``no_cache`` or ``private`` to ``True`` will set the
       implicit value ``"*"``.
    zno-storeNr   Úno_storezmax-ageú
int | NoneÚmax_agezno-transformÚno_transformzstale-if-errorÚstale_if_errorr   ÚvaluesúBcabc.Mapping[str, t.Any] | cabc.Iterable[tuple[str, t.Any]] | NoneÚ	on_updateú+cabc.Callable[[_CacheControl], None] | Nonec                   s   t ƒ  ||¡ |d u| _d S r   )ÚsuperÚ__init__Úprovided)Úselfr+   r-   ©Ú	__class__r   r   r0   Z   s   z_CacheControl.__init__r	   r
   r   r   r   r   r   c                 C  s`   |t u r|| v S || vrdS | |  }du r|S |dur.z||ƒ}W |S  ty-   Y dS w |S ©ú+Used internally by the accessor properties.N)r   Ú
ValueError)r2   r	   r   r   Úvaluer   r   r   r   b   s   
ýÿz_CacheControl._get_cache_valuer8   ÚNonec                 C  s|   |t u r|rd| |< dS |  |d¡ dS |du s|du r$|  |d¡ dS |du r.d| |< dS |dur6||ƒ}t|ƒ| |< dS )r6   NFT)r   Úpopr
   )r2   r	   r8   r   r   r   r   r   w   s   z_CacheControl._set_cache_valuec                 C  s   || v r	| |= dS dS r5   r   )r2   r	   r   r   r   r   Š   s   
ÿz_CacheControl._del_cache_valuec                 C  s
   t  | ¡S )z6Convert the stored values into a cache control header.)ÚhttpÚdump_header©r2   r   r   r   Ú	to_header�   s   
z_CacheControl.to_headerc                 C  s   |   ¡ S r   )r>   r=   r   r   r   Ú__str__“   s   z_CacheControl.__str__c                 C  s4   d  dd„ t|  ¡ ƒD ƒ¡}dt| ƒj› d|› d�S )Nr   c                 s  s"   � | ]\}}|› d |›�V  qdS )ú=Nr   )Ú.0Úkr   r   r   r   Ú	<genexpr>—   s   €  z)_CacheControl.__repr__.<locals>.<genexpr>ú<ú>)r!   ÚsortedÚitemsr   r    )r2   Úkv_strr   r   r   Ú__repr__–   s   z_CacheControl.__repr__)r   N)r+   r,   r-   r.   )r	   r
   r   r   r   r   r   r   )r	   r
   r8   r   r   r   r   r9   )r	   r
   r   r9   )r   r
   )r    Ú
__module__Ú__qualname__Ú__doc__r$   r   r&   Ú__annotations__Úintr(   r)   r*   r0   r   r   r   r>   r?   rI   ÚstaticmethodÚcache_propertyÚ__classcell__r   r   r3   r   r%   8   s    
 ý





r%   c                   @  sb   e Zd ZU dZeddeƒZded< eddeƒZ	ded	< ed
deƒZ
ded< eddeƒZded< dS )ÚRequestCacheControla  A cache control for requests.  This is immutable and gives access
    to all the request-relevant cache control headers.

    To get a header of the :class:`RequestCacheControl` object again you can
    convert the object into a string or call the :meth:`to_header` method.  If
    you plan to subclass it and add your own items have a look at the sourcecode
    for that class.

    .. versionchanged:: 3.1
        Dict values are always ``str | None``. Setting properties will
        convert the value to a string. Setting a non-bool property to
        ``False`` is equivalent to setting it to ``None``. Getting typed
        properties will return ``None`` if conversion raises
        ``ValueError``, rather than the string.

    .. versionchanged:: 3.1
       ``max_age`` is ``None`` if present without a value, rather
       than ``-1``.

    .. versionchanged:: 3.1
        ``no_cache`` is a boolean, it is ``True`` instead of ``"*"``
        when present.

    .. versionchanged:: 3.1
        ``max_stale`` is ``True`` if present without a value, rather
        than ``"*"``.

    .. versionchanged:: 3.1
       ``no_transform`` is a boolean. Previously it was mistakenly
       always ``None``.

    .. versionchanged:: 3.1
       ``min_fresh`` is ``None`` if present without a value, rather
       than ``"*"``.

    .. versionchanged:: 2.1
        Setting int properties such as ``max_age`` will convert the
        value to an int.

    .. versionadded:: 0.5
        Response-only properties are not present on this request class.
    úno-cacheNr   Úno_cachez	max-staleTzint | t.Literal[True] | NoneÚ	max_stalez	min-freshr'   Ú	min_freshzonly-if-cachedÚonly_if_cached)r    rJ   rK   rL   r$   r   rT   rM   rN   rU   rV   rW   r   r   r   r   rR   �   s   
 +ýrR   c                   @  sÆ   e Zd ZU dZedddƒZded< eddeƒZded< ed	ddƒZ	ded	< ed
deƒZ
ded< eddeƒZded< eddeƒZded< eddeƒZded< eddeƒZded< eddeƒZded< dS )ÚResponseCacheControla  A cache control for responses.  Unlike :class:`RequestCacheControl`
    this is mutable and gives access to response-relevant cache control
    headers.

    To get a header of the :class:`ResponseCacheControl` object again you can
    convert the object into a string or call the :meth:`to_header` method.  If
    you plan to subclass it and add your own items have a look at the sourcecode
    for that class.

    .. versionchanged:: 3.1
        Dict values are always ``str | None``. Setting properties will
        convert the value to a string. Setting a non-bool property to
        ``False`` is equivalent to setting it to ``None``. Getting typed
        properties will return ``None`` if conversion raises
        ``ValueError``, rather than the string.

    .. versionchanged:: 3.1
        ``no_cache`` is ``True`` if present without a value, rather than
        ``"*"``.

    .. versionchanged:: 3.1
        ``private`` is ``True`` if present without a value, rather than
        ``"*"``.

    .. versionchanged:: 3.1
       ``no_transform`` is a boolean. Previously it was mistakenly
       always ``None``.

    .. versionchanged:: 3.1
        Added the ``must_understand``, ``stale_while_revalidate``, and
        ``stale_if_error`` properties.

    .. versionchanged:: 2.1.1
        ``s_maxage`` converts the value to an int.

    .. versionchanged:: 2.1
        Setting int properties such as ``max_age`` will convert the
        value to an int.

    .. versionadded:: 0.5
       Request-only properties are not present on this response class.
    rS   TNzstr | t.Literal[True] | NonerT   Úpublicr   Úprivatezmust-revalidateÚmust_revalidatezproxy-revalidateÚproxy_revalidatezs-maxager'   Ús_maxageÚ	immutablezmust-understandÚmust_understandzstale-while-revalidateÚstale_while_revalidate)r    rJ   rK   rL   r$   rT   rM   r   rY   rZ   r[   r\   rN   r]   r^   r_   r`   r   r   r   r   rX   Ó   s"   
 +ÿÿÿrX   é   )r;   )
r	   r
   r   r   r   r   r   r   r   r   )Ú
__future__r   Úcollections.abcÚabcÚcabcÚtypingÚtÚinspectr   Úmixinsr   Ú
structuresr   r$   r
   ÚOptionalr%   rR   rX   Ú r;   r   r   r   r   Ú<module>   s    ÿ- e6>