a
    d=ica  ã                   @   s8   d Z ddlmZ dZG dd„ deƒZdd„ Zdd	„ Zd
S )zRequest-scoped context.é    )Úauthztensorboard.request_contextc                   @   sR   e Zd ZdZddd„Zedd„ ƒZedd„ ƒZed	d
„ ƒZedd„ ƒZ	dd„ Z
dS )ÚRequestContexta  Container of request-scoped values.

    This context is for cross-cutting concerns: authentication,
    authorization, auditing, internationalization, logging, and so on.
    It is not simply for passing commonly used parameters to functions.

    `RequestContext` values are to be treated as immutable.

    Fields:
      auth: An `AuthContext`, which may be empty but is never `None`.
      remote_ip: An `ipaddress.IPv4Address` or `ipaddress.IPv6Address` or None.
        Best guess of the IP Address of the end user.
      x_forwarded_for: A tuple of `ipaddress.IPv4Address` or `ipaddress.IPv6Address`,
        which may be empty but is never None. This should be parsed value of X-Forwarded-For
        HTTP header from the request.
      client_feature_flags: A dict of string to arbitrary type. These represent
        feature flag key/value pairs sent by the client application. Usage of
        client_feature_flags should know the name of the feature flag key and
        should know and validate the type of the value.
    Nc                 C   s6   |dur|nt j ¡ | _|| _|p$d| _|p.i | _dS )aY  Create a request context.

        The argument list is sorted and may be extended in the future;
        therefore, callers must pass only named arguments to this
        initializer.

        Args:
          See "Fields" on class docstring. All arguments are optional
          and will be replaced with default values if appropriate.
        N© )Úauth_libZAuthContextÚemptyÚ_authÚ
_remote_ipÚ_x_forwarded_forÚ_client_feature_flags)Úselfr   Ú	remote_ipÚx_forwarded_forÚclient_feature_flagsr   r   úd/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/tensorboard/context.pyÚ__init__.   s    
zRequestContext.__init__c                 C   s   | j S ©N)r   ©r   r   r   r   r   D   s    zRequestContext.authc                 C   s   | j S r   )r   r   r   r   r   r   H   s    zRequestContext.remote_ipc                 C   s   | j S r   )r	   r   r   r   r   r   L   s    zRequestContext.x_forwarded_forc                 C   s   | j S r   )r
   r   r   r   r   r   P   s    z#RequestContext.client_feature_flagsc                 K   sJ   |  d| j¡ |  d| j¡ |  d| j¡ |  d| j¡ t| ƒf i |¤ŽS )ay  Create a copy of this context with updated key-value pairs.

        Analogous to `namedtuple._replace`. For example, to create a new
        request context like `ctx` but with auth context `auth`, call
        `ctx.replace(auth=auth)`.

        Args:
          As to `__init__`.

        Returns:
          A new context like this one but with the specified updates.
        r   r   r   r   )Ú
setdefaultr   r   r   r   Útype)r   Úkwargsr   r   r   ÚreplaceT   s
    zRequestContext.replace)NNNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   r   r   r   r   r   r   r   r   r      s       û




r   c                 C   s   |   t¡}|dur|S tƒ S )a  Get a `RequestContext` from a WSGI environment.

    See also `set_in_environ`.

    Args:
      environ: A WSGI environment (see PEP 3333).

    Returns:
      The `RequestContext` stored in the WSGI environment, or an empty
      `RequestContext` if none is stored.
    N)ÚgetÚ	_WSGI_KEYr   )ÚenvironÚresultr   r   r   Úfrom_environh   s    
r    c                 C   s   || t < dS )zúSet the `RequestContext` in a WSGI environment.

    After `set_in_environ(e, ctx)`, `from_environ(e) is ctx`. The input
    environment is mutated.

    Args:
      environ: A WSGI environment to update.
      ctx: A new `RequestContext` value.
    N)r   )r   Úctxr   r   r   Úset_in_environx   s    
r"   N)	r   Ztensorboardr   r   r   Úobjectr   r    r"   r   r   r   r   Ú<module>   s
   P