ó
    Ö›‘hÚ   ã            
       óþ  • S r SSKJrJr  SSKJrJrJrJrJ	r	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  SS	KJr  SS
KJr  SSKJr  SSKJr  \" 5       r\\\4   rS\S\4S jr S\S\4S jr!S \" S5      S S 4S \" S5      \ \!4/r"\" V VVVs0 s H  u  pp#X_M
     snnnn r#S\S\$4S jr%S\$S\4S jr&S\S\4S jr'S\S\4S jr( S'S \\   S!\S\4S" jjr)  S(S$\\   S!\
\   S%\*S\	\   4S& jjr+g#s  snnnn f ))zA
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Úreturnc                 ó’   • [        U R                  5       [        U R                  R                  U R                  R                  S9S9$ )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__r   r   r   )r   s    ÚXC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/logger/_json.pyÚfailureAsJSONr       s?   € ô Ø×ÑÓÜØ—|‘|×.Ñ.Ø—\‘\×*Ñ*ñ
ñð ó    ÚfailureDictc                 óŒ   • [         R                  " [         5      nU S   n[        US   SU5      U S'   UR                  U 5        U$ )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}
r   r   © )r   Ú__new__r   Ú__setstate__)r"   ÚfÚtypeInfos      r   ÚfailureFromJSONr)   .   sE   € ô 	�ŠœÓ €AØ˜6Ñ"€HÜ˜x¨
Ñ3°R¸ÓB€K�ÑØ‡N�N�;ÔØ€Hr!   c                 ój   • [        U [        5      =(       a    [        [        U R                  S 5      U L $ ©N)Ú
isinstancer   Úgetattrr   Úname©Úlevels    r   Ú<lambda>r1   @   s+   € Ü�uœmÓ,÷ =Üœ %§*¡*¨dÓ3°uÐ<ð=r!   z$02E59486-F24D-46AD-8224-3ACDF2A5732Ac                 ó(   • [        U R                  S9$ )N)r.   )r   r.   r/   s    r   r1   r1   E   s   € ”d §
¡
Ò+r!   c                 ó*   • [        [        U S   S 5      $ )Nr.   )r-   r   r/   s    r   r1   r1   F   s   € ”gœh¨¨f©°tÔ<r!   c                 ó"   • [        U [        5      $ r+   )r,   r   )Úos    r   r1   r1   I   s   € ”*˜Q¤Ô(r!   z$E76887E2-20ED-49BF-A8F8-BA25CC586F2DÚaDictc                 óH   • SU ;   a  [         [        U S   5         " U 5      $ U $ )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   )r6   s    r   ÚobjectLoadHookr:   T   s,   € ð ˜5Ó ÜœD Ð'7Ñ!8Ó9Ò:¸5ÓAÐAØ€Lr!   ÚpythonObjectc                 óx   • [          H-  u  pp4U" U 5      (       d  M  U" U 5      n[        U5      US'   Us  $    SS0$ )am  
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.
r8   ÚunpersistableT)Ú	classInfoÚstr)r;   Ú	predicateÚuuidÚsaverÚloaderÚresults         r   ÚobjectSaveHookrE   d   sI   € ÷ +4Ñ&ˆ	˜Ù�\×"Ó"Ù˜<Ó(ˆFÜ'*¨4£yˆFÐ#Ñ$ØŠMñ	 +4ð
 ˜TÐ"Ð"r!   Úeventc                 óh   • S[         S[        [        [        4   4S jn[	        U 5        [        XSS9$ )at  
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.
Úunencodabler   c                 ód   • [        U [        5      (       a  U R                  S5      $ [        U 5      $ )zŽ
Serialize an object not otherwise serializable by L{dumps}.

@param unencodable: An unencodable object.

@return: C{unencodable}, serialized
Úcharmap)r,   ÚbytesÚdecoderE   )rH   s    r   ÚdefaultÚeventAsJSON.<locals>.defaultˆ   s-   € ô �k¤5×)Ñ)Ø×%Ñ% iÓ0Ð0Ü˜kÓ*Ð*r!   T)rM   Úskipkeys)Úobjectr   ÚJSONDictr?   r   r   )rF   rM   s     r   ÚeventAsJSONrR   y   s5   € ð
+œVð 
+¬¬h¼¨mÑ(<ô 
+ô �ÔÜ�°$Ñ7Ð7r!   Ú	eventTextc                 ó:   • [        [        [        U [        S95      $ )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)r   rQ   r   r:   )rS   s    r   ÚeventFromJSONrV   ˜   s   € ô ”œ% 	´~ÑFÓGÐGr!   ÚoutFileÚrecordSeparatorc                 ó$   ^• [        U U4S j5      $ )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.
c                 ó$   >• T [        U 5       S3$ )NÚ
)rR   )rF   rX   s    €r   r1   Ú%jsonFileLogObserver.<locals>.<lambda>º   s   ø€  /Ð!2´;¸uÓ3EÐ2FÀbÑIr!   r   )rW   rX   s    `r   ÚjsonFileLogObserverr]   £   s   ø€ ô, ØÔIóð r!   NÚinFileÚ
bufferSizec              #   ó0  ^#   • S[         S[        4S jnS[        S[        [           4S jmUc#  U" U R                  S5      5      nUS:X  a  UnOS	nO
U" U5      nS	nUS	:X  a  S
nTnOS[        S[        [           4U4S jjn[        U5      n U R                  U5      nU(       d  [        U5      S:”  a  U" U5      n	U	b  U	v •  gXs" U5      -  nUR                  U5      n
U
SS  H%  n[        U5      S:”  d  M  U" U5      n	U	c  M!  U	v •  M'     U
S   nM‡  7f)a!  
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}.
Úsr   c                 óR   • [        U [        5      (       a  U $ U R                  S5      $ )Núutf-8)r,   rK   Úencode)ra   s    r   ÚasBytesÚ&eventsFromJSONLogFile.<locals>.asBytesÒ   s#   € Ü�aœ×ÑØˆHà—8‘8˜GÓ$Ð$r!   Úrecordc                 ó  •  [        U 5      R                  S5      n [        U5      $ ! [         a     [        R	                  S[        U 5      S9   g f = f! [         a     [        R	                  S[        U 5      S9   g f = f)Nrc   z2Unable to decode UTF-8 for JSON record: {record!r}©rg   z&Unable to read JSON record: {record!r})rK   rL   ÚUnicodeDecodeErrorÚlogÚerrorrV   Ú
ValueError)rg   Útexts     r   ÚeventFromBytearrayÚ1eventsFromJSONLogFile.<locals>.eventFromBytearrayØ   s„   € ð	Ü˜“=×'Ñ'¨Ó0ˆDð	Ü  Ó&Ð&øô "ó 	Ü�I‰IØDÜ˜V“}ð ñ ñ ð	ûô ó 	Ü�I‰IÐ>ÄuÈVÃ}ˆIÑUÙð	ús    ‚( �
A ¨'AÁAÁ'A?Á>A?Nr   ó   r!   ó   
c                 ót   >• U S   [        S5      :X  a  T" U 5      $ [        R                  S[        U 5      S9  g )Néÿÿÿÿr[   z0Unable to read truncated JSON record: {record!r}ri   )Úordrk   rl   rK   )rg   ro   s    €r   ÚeventFromRecordÚ.eventsFromJSONLogFile.<locals>.eventFromRecordþ   s>   ø€ Ø�b‰zœS ›YÓ&Ù)¨&Ó1Ð1ä—	‘	ØFÜ  ›=ð ñ ð r!   r   rt   )r   rK   Ú	bytearrayr
   r   ÚreadÚlenÚsplit)r^   rX   r_   re   ÚfirstÚrecordSeparatorBytesrv   ÚbufferÚnewDatarF   Úrecordsrg   ro   s               @r   ÚeventsFromJSONLogFiler�   ¾   s?  øé € ð(%”6ð %œeô %ð¤9ð ´¼(Ñ1Cô ð  ÑÙ˜Ÿ™ A›Ó'ˆà�GÓà#(Ñ ð $'Ñ ñ  ' Ó7ÐØˆà˜sÓ"Ø$Ðà,‰ð	¤Ið 	´(¼8Ñ2D÷ 	ô �uÓ€Fà
Ø—+‘+˜jÓ)ˆæÜ�6‹{˜Q‹Ù'¨Ó/�ØÑ$Ø’KØà�'˜'Ó"Ñ"ˆØ—,‘,Ð3Ó4ˆà˜c˜r“lˆFÜ�6‹{˜Q�Ù'¨Ó/�ØÓ$Ø”Kñ	 #ð ˜‘ˆñ' ùs   ƒC3DÃ:	DÄD)Ú)Ni   ),Ú__doc__Újsonr   r   Útypingr   r   r   r   r	   r
   r   r   rA   r   Ú
constantlyr   Útwisted.python.failurer   Ú_filer   Ú_flattenr   Ú_interfacesr   Ú_levelsr   Ú_loggerr   rk   r?   rQ   r    r)   r>   r9   rP   r:   rE   rR   rV   r]   Úintr�   )r@   rA   rB   rC   s   0000r   Ú<module>rŽ      s…  ðñ
÷ ß I× IÓ IÝ å $å *Ý "Ý "Ý !Ý Ý áƒh€ð ��S�‰>€ð˜7ð  xô ð$ ð ¨gô ñ$	
ñ 	Ð3Ó4Ù+Ù<ðñ 	)ÙÐ3Ó4ØØð	ð€	ñ& FOÖOÂYÑ!A )°5�’ÁYÔO€ð˜(ð  vô ð # ð #¨Hô #ð*8�xð 8 Cô 8ð>H˜Sð H Xô Hð .4ñØ�‰WðØ'*ðàõð: &*Øñ_Øˆs‰Gð_à˜c‘]ð_ð ð_ð ˆhÑö	_ùõ[ Ps   ÂC7
