AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/twisted/logger/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /usr/lib/python3/dist-packages/twisted/logger/__pycache__/_flatten.cpython-310.pyc
o

�b��@s�dZddlmZddlmZddlmZmZmZddl	m
Z
e�ZGdd�d�Zd	e
d
dfdd
�Z
ded	e
d
efdd�Zd	e
d
efdd�ZdS)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@s<eZdZdZddd�Zdedeedeedefd	d
�ZdS)�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}.
    �returnNcCstdd��|_dS)z/
        Initialize a L{KeyFlattener}.
        cSsdS)Nr�rrr�9/usr/lib/python3/dist-packages/twisted/logger/_flatten.py�<lambda>sz'KeyFlattener.__init__.<locals>.<lambda>N)r�keys)�selfrrr�__init__szKeyFlattener.__init__�	fieldName�
formatSpec�
conversioncCsf|durd}|durd}dj|||d�}|j|d7<|j|}|dkr1|dt|j|�7}|S)a�
        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.
        N�z%{fieldName}!{conversion}:{formatSpec})rrrr�/)�formatr�str)rrrr�result�nrrr�flatKey s�
zKeyFlattener.flatKey)r
N)�__name__�
__module__�__qualname__�__doc__rrrrrrrrr	s
����r	�eventr
NcCs|�dd�dur
dSd|vr|d}ni}t�}t�|d�D]Y\}}}}|dur*q|dkr0d}|�|||�}|�||d�}||vrCq|�d�rQ|dd�}d	}	nd
}	t�|d|�}
|
d}|dkret}nt}|	rl|�}||�}
|
||<|||<q|r�||d<dSdS)
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�srz()���TFrr)	�getr	�
aFormatter�parser�endswith�	get_field�reprr)r�fields�keyFlattener�literalTextrrr�flattenedKey�
structuredKey�callit�field�
fieldValue�conversionFunction�flattenedValuerrr�flattenEvent@sD
�

�r5r1cCsXt�}t�d|d�\\}}}}|dusJ�|�|||�}d|vr&t|�|d|S)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.
    �{�}Nr!)r	r&r'rr5)r1rr,r-rrr�keyrrr�extractField{s
�r9c	Csn|d}t�}g}t�|d�D]!\}}}}|�|�|dur1|�|||p&d�}|�t||��qd�|�S)z�
    Format an event which has been flattened with L{flattenEvent}.

    @param event: A logging event.

    @return: A formatted string.
    r!r Nr#r)r	r&r'�appendrr�join)	r�fieldValuesr,r#r-rrrr8rrr�
flatFormat�s�
�
r=)r�collectionsr�stringr�typingrrr�_interfacesrr&r	r5rr9r=rrrr�<module>s,;

Anon7 - 2022
AnonSec Team