
    osj              	          d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	m
Z
mZ d dlmZ d dlmZmZmZ  e	d      Z ee      Z ee      Z ee      Z ee      Z	 dd
ed	z  deeef   fdZdded
ed	z  ded	z  fdZ	 ddeded
ed	z  defdZdded
ed	z  defdZdd
ed	z  defdZdd
ed	z  deeef   fdZ dede!fdZ"dede!fdZ#dedede!fdZ$y	)    )Mapping)	getLogger)compile)MappingProxyType)
create_key	get_value	set_value)Context)_BAGGAGE_PROPERTY_FORMAT_KEY_FORMAT_VALUE_FORMATbaggageNcontextreturnc                 ,    t        t        |             S )zReturns the name/value pairs in the Baggage

    Args:
        context: The Context to use. If not set, uses current Context

    Returns:
        The name/value pairs in the Baggage
    r   )r   _get_baggage_valuer   s    Q/root/.hermes/venv/lib/python3.12/site-packages/opentelemetry/baggage/__init__.pyget_allr      s     .w?@@    namec                 8    t        |      j                  |       S )a=  Provides access to the value for a name/value pair in the
    Baggage

    Args:
        name: The name of the value to retrieve
        context: The Context to use. If not set, uses current Context

    Returns:
        The value associated with the given name, or null if the given name is
        not present.
    r   )r   get)r   r   s     r   get_baggager   '   s     g.22488r   valuec                 d    t        |      j                         }||| <   t        t        ||      S )zSets a value in the Baggage

    Args:
        name: The name of the value to set
        value: The value to set
        context: The Context to use. If not set, uses current Context

    Returns:
        A Context with the value updated
    r   )r   copyr	   _BAGGAGE_KEY)r   r   r   r   s       r   set_baggager   6   s/     !1668GGDM\7G<<r   c                 ~    t        |      j                         }|j                  | d       t        t        ||      S )zRemoves a value from the Baggage

    Args:
        name: The name of the value to remove
        context: The Context to use. If not set, uses current Context

    Returns:
        A Context with the name/value removed
    r   N)r   r   popr	   r   )r   r   r   s      r   remove_baggager"   H   s4     !1668GKKd\7G<<r   c                 &    t        t        i |       S )zRemoves all values from the Baggage

    Args:
        context: The Context to use. If not set, uses current Context

    Returns:
        A Context with all baggage entries removed
    r   )r	   r   r   s    r   clearr$   X   s     \2w77r   c                 L    t        t        |       }t        |t              r|S i S )Nr   )r   r   
isinstancedict)r   r   s     r   r   r   d   s"    g6G'4 Ir   c                 B    t         j                  t        |             d uS N)_KEY_PATTERN	fullmatchstr)r   s    r   _is_valid_keyr-   k   s    !!#d),D88r   c                     t        |       j                  d      }t        j                  |d         d u}t	        |      dkD  r$|dd  D ]  }t
        j                  |      d} |S  |S )N;r      F)r,   split_VALUE_PATTERNr+   len_PROPERT_PATTERN)r   partsis_valid_valuepropertys       r   _is_valid_valuer8   o   sv    JS!E#--eAh7tCN
5zA~ab	 	H))(3;!&		 r   keyc                 2    t        |       xr t        |      S r)   )r-   r8   )r9   r   s     r   _is_valid_pairr;   z   s    8/%"88r   r)   )%collections.abcr   loggingr   rer   typesr   opentelemetry.contextr   r   r	   opentelemetry.context.contextr
   opentelemetry.util.rer   r   r   r   __name___loggerr*   r2   r4   r,   objectr   r   r   r"   r$   r'   r   boolr-   r8   r;    r   r   <module>rH      sk   $   " B B 1  )$
H
{#'34  #At^AS&[A9c 9GdN 9ftm 9  9==
=='.~==$= =w~ = = 	87T> 	8W 	8$ $sF{:K 9 9 96 d 9 9C 9D 9r   