a
    0h%                     @  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
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strt.Anytype[t.Any] | Nonez
str | None)keyemptytyper   returnc                  s   |du rd dg}t u r*|d nLdu r>|d n|dj d  durl|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    S/var/www/auris/lib/python3.9/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   r   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dd fddZdddddddZdddddddZdddddZdd d!d"Zdd d#d$Zd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   zBcabc.Mapping[str, t.Any] | cabc.Iterable[tuple[str, t.Any]] | Nonez+cabc.Callable[[_CacheControl], None] | None)values	on_updatec                   s   t  || |d u| _d S r   )super__init__provided)selfr*   r+   	__class__r   r   r-   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 r0|S |durZz||}W n tyX   Y dS 0 |S +Used internally by the accessor properties.N)r   
ValueError)r/   r   r   r   valuer   r   r   r   b   s    z_CacheControl._get_cache_valueNone)r   r5   r   r   c                 C  st   |t u r$|rd| |< qp| |d nL|du s4|du rB| |d n.|du rTd| |< n|durd||}t|| |< dS )r3   NFT)r   popr	   )r/   r   r5   r   r   r   r   r   w   s    

z_CacheControl._set_cache_value)r   r   c                 C  s   || v r| |= dS r2   r   )r/   r   r   r   r   r      s    z_CacheControl._del_cache_value)r   c                 C  s
   t | S )z6Convert the stored values into a cache control header.)httpZdump_headerr/   r   r   r   	to_header   s    z_CacheControl.to_headerc                 C  s   |   S r   )r:   r9   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>   r   z)_CacheControl.__repr__.<locals>.<genexpr><>)r    sorteditemsr   r   )r/   Zkv_strr   r   r   __repr__   s    z_CacheControl.__repr__)r   N)r   
__module____qualname____doc__r#   r   r%   __annotations__intr'   r(   r)   r-   r   r   r   r:   r;   rD   staticmethodZcache_property__classcell__r   r   r0   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   rE   rF   rG   r#   r   rN   rH   rI   rO   rP   rQ   r   r   r   r   rL      s   
+rL   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.
    rM   TNzstr | t.Literal[True] | NonerN   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   rE   rF   rG   r#   rN   rH   r   rS   rT   rU   rV   rI   rW   rX   rY   rZ   r   r   r   r   rR      s    
+rR      )r8   )
__future__r   collections.abcabcZcabctypingtinspectr   Zmixinsr   
structuresr   r#   r	   Optionalr$   rL   rR    r8   r   r   r   r   <module>   s   -e 6>