
    G)f)              	          d dl mZ d dlmZ d dlmZ d dlmZ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e   deeef   fdZdded
ee   dee   fdZddeded
ee   defdZdded
ee   defdZdd
ee   de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	)    )	getLogger)compile)MappingProxyType)MappingOptional)
create_key	get_value	set_value)Context)_BAGGAGE_PROPERTY_FORMAT_KEY_FORMAT_VALUE_FORMATbaggageNcontextreturnc                 p    t        t        |       }t        |t              rt	        |      S t	        i       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	   _BAGGAGE_KEY
isinstancedictr   )r   r   s     a/var/www/html/flask-app/venv/lib/python3.12/site-packages/mysql/opentelemetry/baggage/__init__.pyget_allr   $   s0     g6G'4 ((B    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   5   s     7#''--r   valuec                 Z    t        t        |            }||| <   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   r   r
   r   )r   r   r   r   s       r   set_baggager    D   s+     77+,GGDM\7G<<r   c                 t    t        t        |            }|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#   T   s0     77+,G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%   d   s     \2w77r   c                 B    t         j                  t        |             d uS N)_KEY_PATTERN	fullmatchstr)r   s    r   _is_valid_keyr+   p   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_valuer6   t   sv    JS!E#--eAh7tCN
5zA~ab	 	H))(3;!&		 r   keyc                 2    t        |       xr t        |      S r'   )r+   r6   )r7   r   s     r   _is_valid_pairr9      s    8/%"88r   r'   )$loggingr   rer   typesr   typingr   r   mysql.opentelemetry.contextr   r	   r
   #mysql.opentelemetry.context.contextr   mysql.opentelemetry.util.rer   r   r   r   __name___loggerr(   r0   r2   r*   objectr   r   r    r#   r%   boolr+   r6   r9    r   r   <module>rF      sF     " $ H H 7  )$
H
{#'34  "& g S&[ ".c .HW$5 .&AQ .=c =& =8G3D =PW = = =x'8 =G = 	88G$ 	8 	89 9 96 d 9 9C 9D 9r   