
    Kib                         d dl Z d dlZd dlmZ d dlmZmZ  G d deej                  eef            Z	 G d deeeef            Z
y)    N)MutableMapping)GetterSetterc                       e Zd ZdZd Zdej                  eef   dedej                  ej                  e      fdZ
dej                  eef   dej                  e   fdZy)	EnvironmentGettera  Getter implementation for extracting context and baggage from environment variables.

    EnvironmentGetter creates a case-insensitive lookup from the current environment
    variables at initialization time and provides simple data access without validation.

    Per the OpenTelemetry specification, environment variables are treated as immutable
    within a process. For environments where context-carrying environment variables
    change between logical requests (e.g., AWS Lambda's _X_AMZN_TRACE_ID), create a
    new EnvironmentGetter instance at the start of each request.

    Example usage:
        getter = EnvironmentGetter()
        traceparent = getter.get({}, "traceparent")
    c                     t         j                  j                         D ci c]  \  }}|j                         | c}}| _        y c c}}w )N)osenvironitemslowercarrier)selfkvs      q/home/jay/workspace/scripts/.codegraph-venv/lib/python3.12/site-packages/opentelemetry/propagators/_envcarrier.py__init__zEnvironmentGetter.__init__&   s;     &(ZZ%5%5%7/
!QAGGIqL/
 /
s   Ar   keyreturnc                     | j                   j                  |j                               }|yt        |t        j
                        rt        |t              st        |      S |gS )aI  Get a value from the environment carrier for the given key.

        Args:
            carrier: Not used; maintained for interface compatibility with Getter[CarrierT]
            key: The key to look up (case-insensitive)

        Returns:
            A list with a single string value if the key exists, None otherwise.
        N)r   getr   
isinstancetypingIterablestrlist)r   r   r   vals       r   r   zEnvironmentGetter.get-   sN     llsyy{+;c6??+JsC4H9u    c                 H    t        | j                  j                               S )zGet all keys from the environment carrier.

        Args:
            carrier: Not used; maintained for interface compatibility with Getter[CarrierT]

        Returns:
            List of all environment variable keys (lowercase).
        )r   r   keys)r   r   s     r   r   zEnvironmentGetter.keys@   s     DLL%%'((r   N)__name__
__module____qualname____doc__r   r   Mappingr   OptionalListr   r    r   r   r   r      sq    
~~c3h/69	S)	*&	)FNN384 	)S9I 	)r   r   c                   2    e Zd ZdZdeeef   dededdfdZy)EnvironmentSettera  Setter implementation for building environment variable dictionaries.

    EnvironmentSetter builds a dictionary of environment variables that
    can be passed to utilities like subprocess.run()

    Example usage:
        setter = EnvironmentSetter()
        env_vars = {}
        setter.set(env_vars, "traceparent", "00-trace-id-span-id-01")
        subprocess.run(myCommand, env=env_vars)
    r   r   valuer   Nc                 *    |||j                         <   y)zSet a value in the carrier dictionary for the given key.

        Args:
            carrier: Dictionary to store environment variables
            key: The key to set (will be converted to uppercase)
            value: The value to set
        N)upper)r   r   r   r*   s       r   setzEnvironmentSetter.setY   s      %		r   )r    r!   r"   r#   r   r   r-   r'   r   r   r)   r)   L   s5    

%%c3h/
%69
%BE
%	
%r   r)   )r	   r   collections.abcr   !opentelemetry.propagators.textmapr   r   r$   r   r   r)   r'   r   r   <module>r0      sL    
  * <3)v~~c3h78 3)l%~c3h78 %r   