+
    Dfj                         R t ^ RIHt ^ RIHt ^ RIHtHtHt ^RI	H
t
 ]! 4       t ! R R4      tR R ltR	 R
 ltR R ltR# )z
Code related to "flattening" events; that is, extracting a description of all
relevant fields from the format string and persisting them for later
examination.
)defaultdict)	Formatter)AnyDictOptionalLogEventc                   H   a  ] tR t^t o RtV 3R lR ltV 3R lR ltRtV tR# )KeyFlattenerz
A L{KeyFlattener} computes keys for the things within curly braces in
PEP-3101-style format strings as parsed by L{string.Formatter.parse}.
c                   < V ^8  d   QhRR/# )   returnN )format__classdict__s   "9/usr/lib/python3/dist-packages/twisted/logger/_flatten.py__annotate__KeyFlattener.__annotate__   s     ; ;$ ;    c                (    \        R 4      V n        R# )z
Initialize a L{KeyFlattener}.
c                      ^ # )    r   r   r   r   <lambda>'KeyFlattener.__init__.<locals>.<lambda>   s    r   N)r   keys)selfs   &r   __init__KeyFlattener.__init__   s     %0	$:	r   c                R   < V ^8  d   QhRS[ RS[S[ ,          RS[S[ ,          RS[ /# )r   	fieldName
formatSpec
conversionr   )strr   )r   r   s   "r   r   r       s5      *23-EMc]	r   c                   Vf   RpVf   RpRP                  VVVR7      pV P                  V;;,          ^,          uu&   V P                  V,          pV^8w  d+   VR\        V P                  V,          4      ,           ,          pV# )aZ  
Compute a string key for a given field/format/conversion.

@param fieldName: A format field name.
@param formatSpec: A format spec.
@param conversion: A format field conversion type.

@return: A key specific to the given field, format and conversion, as
    well as the occurrence of that combination within this
    L{KeyFlattener}'s lifetime.
 z%{fieldName}!{conversion}:{formatSpec})r   r    r!   /)r   r   r"   )r   r   r    r!   resultns   &&&&  r   flatKeyKeyFlattener.flatKey    s     JJ8??!! @ 

 			&QIIf6cC		& 1222Fr   )r   N)	__name__
__module____qualname____firstlineno____doc__r   r(   __static_attributes____classdictcell__)r   s   @r   r
   r
      s     
; ; r   r
   c                (    V ^8  d   QhR\         RR/# )r   eventr   Nr   )r   s   "r   r   r   @   s     8( 8( 8(T 8(r   c                2   V P                  RR4      f   R# RV 9   d   V R,          pM/ p\        4       p\        P                  V R,          4       F  w  r4rVVf   K  VR8w  d   RpVP	                  WEV4      pVP	                  WER4      pWq9   d   KA  VP                  R4      '       d	   VRR
 pRp	MR	p	\        P                  VRV 4      p
V
^ ,          pVR8X  d   \        pM\        pV	'       d   V! 4       pV! V4      pWV&   WV&   K  	  V'       d   WR&   R# R# )z
Flatten the given event by pre-associating format fields with specific
objects and callable results in a L{dict} put into the C{"log_flattened"}
key in the event.

@param event: A logging event.

log_formatNlog_flattenedrsr$   z()TFr   )	getr
   
aFormatterparser(   endswith	get_fieldreprr"   )r2   fieldskeyFlattenerliteralTextr   r    r!   flattenedKeystructuredKeycallitfield
fieldValueconversionFunctionflattenedValues   &             r   flattenEventrI   @   s,    yyt$,%'>L:D:J:Jl;6
 J#++I:N$,,YBG!d##!#2IFF$$YE:1X
!%!$#J+J7-| *}G;J !'o r   c                <    V ^8  d   QhR\         R\        R\        /# )r   rE   r2   r   )r"   r   r   )r   s   "r   r   r   {   s!     ' ' 'H ' 'r   c                    \        4       p\        P                  RV ,           R,           4      w  w  r4rVVf   Q hVP                  WEV4      pRV9  d   \	        V4       VR,          V,          # )a  
Extract a given format field from the given event.

@param field: A string describing a format field or log key.  This is the
    text that would normally fall between a pair of curly braces in a
    format string: for example, C{"key[2].attribute"}.  If a conversion is
    specified (the thing after the C{"!"} character in a format field) then
    the result will always be str.
@param event: A log event.

@return: A value extracted from the field.

@raise KeyError: if the field is not found in the given event.
{}r5   )r
   r:   r;   r(   rI   )rE   r2   r@   rA   r   r    r!   keys   &&      r   extractFieldrO   {   so      >L9C9I9Iec:65kj    


yj
ACe#U!#&&r   c                0    V ^8  d   QhR\         R\        /# )r   r2   r   )r   r"   )r   s   "r   r   r      s      h 3 r   c                @   V R,          p\        4       p. p\        P                  V R,          4       FY  w  rErgVP                  V4       Vf   K  TP	                  YVT;'       g    R4      pVP                  \        W,          4      4       K[  	  RP                  V4      # )z~
Format an event which has been flattened with L{flattenEvent}.

@param event: A logging event.

@return: A formatted string.
r5   r4   r7   r$   )r
   r:   r;   appendr(   r"   join)	r2   fieldValuesr@   r7   rA   r   r    r!   rN   s	   &        r   
flatFormatrU      s     (K>L
A:D:J:Jl;6
 	
 &&yj>O>OCPCHHS)*+; 771:r   N)r.   collectionsr   stringr   typingr   r   r   _interfacesr   r:   r
   rI   rO   rU   r   r   r   <module>rZ      s=   
 $  & & ![
) )X8(v'>r   