
    2iO                     .   S SK Jr  S SKJr  S SKJrJrJrJrJ	r	  S SK
JrJr  S SKJrJrJr  S SKJr  S SKJr  S SKJr  S S	KJr  \" \5      r " S
 S\R6                  5      rS\\\4   S\4S jrS\\\R@                        S\\R@                     4S jr!g)    )	getLogger)split)IterableListMappingOptionalSet)
quote_plusunquote_plus)_is_valid_pairget_allset_baggage)get_current)Context)textmap)_DELIMITER_PATTERNc            	       B   \ rS rSrSrSrSrSrSrS\	R                  4S\	R                  S	\\   S
\	R                  \	R                     S\4S jjrS\	R                   4S\	R                  S	\\   S\	R"                  \	R                     SS4S jjr\S\\   4S j5       rSrg)W3CBaggagePropagator   zAExtracts and injects Baggage which is used to annotate telemetry.i    i      baggageNcarriercontextgetterreturnc                 V   Uc
  [        5       n[        UR                  XR                  5      5      nU(       d  U$ [	        U5      U R
                  :  a  [        R                  SU5        U$ [        [        U5      nU R                  n[	        U5      U R                  :  a  [        R                  SU5        U H  n[	        U5      U R                  :  a  [        R                  SU5        M4  U(       d  M=   UR                  SS5      u  p[        X5      (       d  [        R                  SU5        Mz  [        U5      R                  5       n[        U	5      R                  5       n	[!        UU	US9nUS-  nUS	:X  d  M    U$    U$ ! [         a    [        R                  SU5         M  f = f)
zeExtract Baggage from the carrier.

See
`opentelemetry.propagators.textmap.TextMapPropagator.extract`
zKBaggage header `%s` exceeded the maximum number of bytes per baggage-stringz?Baggage header `%s` exceeded the maximum number of list-memberszGBaggage entry `%s` exceeded the maximum number of bytes per list-member=   z1Baggage list-member `%s` doesn't match the formatzInvalid baggage entry: `%s`r   r   )r   _extract_first_elementget_BAGGAGE_HEADER_NAMElen_MAX_HEADER_LENGTH_loggerwarningr   r   
_MAX_PAIRS_MAX_PAIR_LENGTH	Exceptionr   r   stripr   )
selfr   r   r   headerbaggage_entriestotal_baggage_entriesentrynamevalues
             d/home/james-whalen/.local/lib/python3.13/site-packages/opentelemetry/baggage/propagation/__init__.pyextractW3CBaggagePropagator.extract%   s    ?!mG'JJw 9 9:
 Nv;000OO] N%*+=v%F $$//1OOQ
 %E5zD111] #kk#q1 "$.. =uE%++-D '--/E!G
 "Q&!$)C %B -  G 	s   7F F('F(setterc                 t    [        US9nU(       d  g[        U5      nUR                  XR                  U5        g)zdInjects Baggage into the carrier.

See
`opentelemetry.propagators.textmap.TextMapPropagator.inject`
r   N)r   _format_baggagesetr"   )r+   r   r   r5   r-   baggage_strings         r2   injectW3CBaggagePropagator.injectn   s2     "'2(9

755~F    c                     U R                   1$ )z.Returns a set with the fields set in `inject`.)r"   )r+   s    r2   fieldsW3CBaggagePropagator.fields   s     ))**r<    )__name__
__module____qualname____firstlineno____doc__r$   r(   r'   r"   r   default_getterCarrierTr   r   Getterr3   default_setterSetterr:   propertyr	   strr>   __static_attributes__r@   r<   r2   r   r      s    KJ$
 &*3:3I3I	G!!G '"G w//0	G
 
GX &*3:3I3I	G!!G '"G w//0	G
 
G$ +C + +r<   r   r-   r   c                 N    SR                  S U R                  5        5       5      $ )N,c              3   ~   #    U  H3  u  p[        [        U5      5      S -   [        [        U5      5      -   v   M5     g7f)r   N)r
   rL   ).0keyr1   s      r2   	<genexpr>"_format_baggage.<locals>.<genexpr>   s5      1JC 	3s8s"ZE
%;;1s   ;=)joinitems)r-   s    r2   r7   r7      s)    88 )//1  r<   rV   c                 4    U c  g [        [        U 5      S 5      $ )N)nextiter)rV   s    r2   r    r       s     }UT""r<   N)"loggingr   rer   typingr   r   r   r   r	   urllib.parser
   r   opentelemetry.baggager   r   r   opentelemetry.contextr   opentelemetry.context.contextr   opentelemetry.propagatorsr   opentelemetry.util.rer   rA   r%   TextMapPropagatorr   rL   objectr7   rG   r    r@   r<   r2   <module>re      s      9 9 1 F F - 1 - 4
H
f+744 f+RWS&[%9 c #HW--./#g#r<   