
    1VhY                     8    d Z ddlmZ dZ G d d      Zd Zd Zy)	zRequest-scoped context.    )authztensorboard.request_contextc                   f    e Zd ZdZ	 	 	 	 d	dZed        Zed        Zed        Zed        Z	d Z
y)
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                     ||nt         j                  j                         | _        || _        |xs d| _        |xs i | _        y)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_libAuthContextempty_auth
_remote_ip_x_forwarded_for_client_feature_flags)selfr   	remote_ipx_forwarded_forclient_feature_flagss        C/home/dcms/DCMS/lib/python3.12/site-packages/tensorboard/context.py__init__zRequestContext.__init__.   sB    " "-T83G3G3M3M3O
# / 52%9%?R"    c                     | j                   S N)r   r   s    r   r   zRequestContext.authD   s    zzr   c                     | j                   S r   )r   r   s    r   r   zRequestContext.remote_ipH   s    r   c                     | j                   S r   )r   r   s    r   r   zRequestContext.x_forwarded_forL   s    $$$r   c                     | j                   S r   )r   r   s    r   r   z#RequestContext.client_feature_flagsP   s    )))r   c                    |j                  d| j                         |j                  d| j                         |j                  d| j                         |j                  d| j                          t        |       d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   r   )
setdefaultr   r   r   r   type)r   kwargss     r   replacezRequestContext.replaceT   sn     	&$)),+t~~6+T-A-AB0$2K2KLtDz#F##r   )NNNN)__name__
__module____qualname____doc__r   propertyr   r   r   r   r    r   r   r   r   r      sp    . !@,     % % * *$r   r   c                 H    | j                  t              }||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.
    )get	_WSGI_KEYr   )environresults     r   from_environr+   h   s%     [[#F'6=^-==r   c                     || t         <   y)zSet 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)   ctxs     r   set_in_environr.   x   s     GIr   N)r$   tensorboardr   r   r(   r   r+   r.   r   r   r   <module>r0      s+     ( *	M$ M$`> 
r   