
    iKjc                         d dl Z d dlZd dlmZmZ d dlmZmZ dedefdZ	dede
fdZ G d d	eeeef            Z G d
 deeeef            Zy)    N)MappingMutableMapping)GetterSetterkeyreturnc                     | syt        j                  dd|       j                         }|r|d   j                         rd|z   }|S )N_z[^A-Za-z0-9_]r   )resubupperisdigit)r   results     v/Users/ahmed/devFolder/Ultron/claude-voice/.venv/lib/python3.12/site-packages/opentelemetry/propagators/_envcarrier.py_normalize_keyr      sD    VV$c3/557F&)##%vM    c                 L    | syd| d   cxk  rdk  ry t        d | D              S )NF0r   9c              3   n   K   | ]-  }d |cxk  xr dk  nc xs d|cxk  xr dk  nc xs |dk(   / yw)AZr   r   r
   N ).0chars     r   	<genexpr>z%_is_normalized_key.<locals>.<genexpr>   s9      LODts?cT0S0?DCK?Cs   35)all)r   s    r   _is_normalized_keyr      s;    
c!f  LO  r   c                   `    e Zd ZdZd Zdeeef   dedee   dz  fdZdeeef   dee   fdZ	y)	EnvironmentGettera  Getter implementation for extracting context and baggage from environment variables.

    EnvironmentGetter creates a lookup from the current environment variables
    whose names are already normalized 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]  \  }}t        |      s|| c}}| _        y c c}}w )N)osenvironitemsr   carrier)selfkvs      r   __init__zEnvironmentGetter.__init__/   sB      ZZ--/(
/TQ3Ea3HAqD/(
 (
s
   AAr%   r   r   Nc                 V    | j                   j                  t        |            }|y|gS )aK  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 (will be normalized)

        Returns:
            A list with a single string value if the key exists, None otherwise.
        N)r%   getr   )r&   r%   r   vals       r   r+   zEnvironmentGetter.get5   s,     ll~c23;ur   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 already-normalized environment variable keys.
        )listr%   keys)r&   r%   s     r   r/   zEnvironmentGetter.keysD   s     DLL%%'((r   )
__name__
__module____qualname____doc__r)   r   strr.   r+   r/   r   r   r   r    r       sX     
738, 3 49t;K 	)GCH- 	)$s) 	)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                      ||t        |      <   y)zSet a value in the carrier dictionary for the given key.

        Args:
            carrier: Dictionary to store environment variables
            key: The key to set (normalized)
            value: The value to set
        N)r   )r&   r%   r   r7   s       r   setzEnvironmentSetter.set]   s     (-s#$r   )r0   r1   r2   r3   r   r4   r9   r   r   r   r6   r6   P   s5    

-%c3h/
-69
-BE
-	
-r   r6   )r"   r   collections.abcr   r   !opentelemetry.propagators.textmapr   r   r4   r   boolr   r    r6   r   r   r   <module>r=      sn    
 	 3 <  C D /)wsCx01 /)d-~c3h78 -r   