
    Xj                         d dl Z d dlZd dlZd dlmZ d dlmZmZ dedefdZ	 G d deej
        eef                            Z G d	 d
eeeef                            ZdS )    N)MutableMapping)GetterSetterkeyreturnc                     t          j        dd|                                           }|r|d                                         rd|z   }|S )Nz[^A-Za-z0-9_]_r   )resubupperisdigit)r   results     b/var/www/FlaskApp/flask-venv/lib/python3.11/site-packages/opentelemetry/propagators/_envcarrier.py_normalize_keyr      sO    V$c3//5577F &)##%% vM    c                       e Zd ZdZd Zdej        eef         dedee         dz  fdZ	dej        eef         dee         fdZ
dS )	EnvironmentGettera  Getter implementation for extracting context and baggage from environment variables.

    EnvironmentGetter creates a normalized 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                 `    d t           j                                        D             | _        d S )Nc                 4    i | ]\  }}t          |          |S  r   ).0kvs      r   
<dictcomp>z.EnvironmentGetter.__init__.<locals>.<dictcomp>&   s3     (
 (
 (
%)QN1q(
 (
 (
r   )osenvironitemscarrier)selfs    r   __init__zEnvironmentGetter.__init__#   s4    (
 (
-/Z-=-=-?-?(
 (
 (
r   r   r   r   Nc                 ^    | j                             t          |                    }|d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   )r    r   r   vals       r   r#   zEnvironmentGetter.get*   s2     l~c2233;4ur   c                 N    t          | 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 (normalized).
        )listr   keys)r    r   s     r   r'   zEnvironmentGetter.keys;   s      DL%%''(((r   )__name__
__module____qualname____doc__r!   typingMappingstrr&   r#   r'   r   r   r   r   r      s         
 
 
~c3h/69	cT	   "	)FN384 	)c 	) 	) 	) 	) 	) 	)r   r   c                   :    e Zd ZdZdeeef         dededdfdZdS )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          |          <   dS )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
        Nr   )r    r   r   r1   s       r   setzEnvironmentSetter.setT   s     (-s##$$$r   )r(   r)   r*   r+   r   r.   r3   r   r   r   r0   r0   G   s[        
 

-%c3h/
-69
-BE
-	
- 
- 
- 
- 
- 
-r   r0   )r   r
   r,   collections.abcr   !opentelemetry.propagators.textmapr   r   r.   r   r-   r   r0   r   r   r   <module>r6      s    
			 				  * * * * * * < < < < < < < <     1) 1) 1) 1) 1)v~c3h78 1) 1) 1)h- - - - -~c3h78 - - - - -r   