ó
    Ö›‘h1  ã                   óð  • % S r SSKrSSKrSSKrSSKrSSKrSSKJr	  SSK
Jr  SSKJrJr  SSKJr  0 r\\\R&                  4   \S'   \R*                  rS rS	 rS
 r\R
                  " \R4                  \5        S rS r\R
                  " \R:                  \5        S rS r\R
                  " \R&                  \5        S r S r!S r"S r# " S S5      r$0 q%\\&S4   \S'   0 q'S r(S r)S r* " S S5      r+g)z(
Different styles of persisted objects.
é    N)ÚStringIO)ÚDict)ÚlogÚreflect)Ú_PYPYÚ
oldModulesc                 óh   • [         U R                  U R                  U R                  R                  44$ )z3support function for copy_reg to pickle method refs)ÚunpickleMethodÚ__name__Ú__self__Ú	__class__)Úmethods    Ú\C:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/persisted/styles.pyÚpickleMethodr      s-   € ô 	Ø	�‰˜&Ÿ/™/¨6¯?©?×+DÑ+DÐEðð ó    c                 ó   • [        X5      nU$ )a�  
Retrieve the function object implementing a method name given the class
it's on and a method name.

@param classObject: A class to retrieve the method's function from.
@type classObject: L{type}

@param methodName: The name of the method whose function to retrieve.
@type methodName: native L{str}

@return: the function object corresponding to the given method name.
@rtype: L{types.FunctionType}
)Úgetattr)ÚclassObjectÚ
methodNameÚmethodObjects      r   Ú_methodFunctionr   "   s   € ô ˜;Ó3€LØÐr   c                 ó  • Uc  [        X 5      $  [        X 5      nSn[        R                  " X1/UQ76 nU$ ! [         aL    [
        R                  " SU SU5        Uc   S5       eUR                  UL a  e [        XUR                  5      s $ f = f)a3  
Support function for copy_reg to unpickle method refs.

@param im_name: The name of the method.
@type im_name: native L{str}

@param im_self: The instance that the method was present on.
@type im_self: L{object}

@param im_class: The class where the method was declared.
@type im_class: L{type} or L{None}
© ÚMethodznot on classz'No recourse: no instance to guess from.)	r   r   ÚtypesÚ
MethodTypeÚAttributeErrorr   Úmsgr   r
   )Úim_nameÚim_selfÚim_classÚmethodFunctionÚ
maybeClassÚbounds         r   r
   r
   4   s¡   € ð �Ü�xÓ)Ð)ðÜ(¨Ó;ˆð ˆ
Ü× Ò  ÐF¸:ÒFˆØˆøô ó CÜ�Š�˜' >°8Ô<ØÑ"ÐMÐ$MÓMÐ"ð ×Ñ Ò(ØÜ˜g°×0AÑ0AÓBÒBðCús   �6 ¶ABÂBc                 ó¬   • U R                   S:X  a  [        SU  35      e[        [        SR	                  U R
                  U R                  /5      /5      4$ )aw  
Reduce, in the sense of L{pickle}'s C{object.__reduce__} special method, a
function object into its constituent parts.

@param f: The function to reduce.
@type f: L{types.FunctionType}

@return: a 2-tuple of a reference to L{_unpickleFunction} and a tuple of
    its arguments, a 1-tuple of the function's fully qualified name.
@rtype: 2-tuple of C{callable, native string}
z<lambda>zCannot pickle lambda function: Ú.)r   Ú_UniversalPicklingErrorÚ_unpickleFunctionÚtupleÚjoinÚ
__module__Ú__qualname__)Úfs    r   Ú_pickleFunctionr.   W   sL   € ð 	‡z�z�ZÓÜ%Ð(GÈÀsÐ&KÓLÐLÜœu c§h¡h°·±¸a¿n¹nÐ/MÓ&NÐ%OÓPÐQÐQr   c                 ó   • SSK Jn  U" U 5      $ )aÕ  
Convert a function name into a function by importing it.

This is a synonym for L{twisted.python.reflect.namedAny}, but imported
locally to avoid circular imports, and also to provide a persistent name
that can be stored (and deprecated) independently of C{namedAny}.

@param fullyQualifiedName: The fully qualified name of a function.
@type fullyQualifiedName: native C{str}

@return: A function object imported from the given location.
@rtype: L{types.FunctionType}
r   )ÚnamedAny)Útwisted.python.reflectr0   )ÚfullyQualifiedNamer0   s     r   r(   r(   h   s   € õ 0áÐ&Ó'Ð'r   c                 ó(   • [         U R                  44$ )z3support function for copy_reg to pickle module refs)ÚunpickleModuler   )Úmodules    r   ÚpickleModuler6   ~   s   € ä˜FŸO™OÐ-Ð-Ð-r   c                 ó¢   • U [         ;   a8  [        R                  " SU -  5        [         U    n [        R                  " U 5        [        U 0 0 S5      $ )z5support function for copy_reg to unpickle module refszModule has moved: %sÚx)r   r   r   Ú
__import__)Únames    r   r4   r4   ƒ   sB   € àŒzÓÜ�ŠÐ&¨Ñ-Ô.Ü˜$ÑˆÜ�Š�ŒÜ�d˜B  CÓ(Ð(r   c                 óP   •  [         U R                  5       U R                  5       44$ )zÉ
Reduce the given cStringO.

This is only called on Python 2, because the cStringIO module only exists
on Python 2.

@param stringo: The string output to pickle.
@type stringo: C{cStringIO.OutputType}
)ÚunpickleStringOÚgetvalueÚtell)Ústringos    r   ÚpickleStringOr@   �   s'   € ð CÜ˜W×-Ñ-Ó/°·±³Ð@Ð@Ð@r   c                 ó^   • [        5       nUR                  U 5        UR                  U5        U$ )a²  
Convert the output of L{pickleStringO} into an appropriate type for the
current python version.  This may be called on Python 3 and will convert a
cStringIO into an L{io.StringIO}.

@param val: The content of the file.
@type val: L{bytes}

@param sek: The seek position of the file.
@type sek: L{int}

@return: a file-like object which you can write bytes to.
@rtype: C{cStringIO.OutputType} on Python 2, L{io.StringIO} on Python 3.
)Ú
_cStringIOÚwriteÚseek©ÚvalÚsekr8   s      r   r<   r<   �   s&   € ô 	‹€AØ‡G�GˆC„LØ‡F�Fˆ3„KØ€Hr   c                 óN   • [         U R                  5       U R                  5       44$ )a1  
Reduce the given cStringI.

This is only called on Python 2, because the cStringIO module only exists
on Python 2.

@param stringi: The string input to pickle.
@type stringi: C{cStringIO.InputType}

@return: a 2-tuple of (C{unpickleStringI}, (bytes, pointer))
@rtype: 2-tuple of (function, (bytes, int))
)ÚunpickleStringIr=   r>   )Ústringis    r   ÚpickleStringIrK   ²   s#   € ô ˜W×-Ñ-Ó/°·±³Ð@Ð@Ð@r   c                 ó>   • [        U 5      nUR                  U5        U$ )a³  
Convert the output of L{pickleStringI} into an appropriate type for the
current Python version.

This may be called on Python 3 and will convert a cStringIO into an
L{io.StringIO}.

@param val: The content of the file.
@type val: L{bytes}

@param sek: The seek position of the file.
@type sek: L{int}

@return: a file-like object which you can read bytes from.
@rtype: C{cStringIO.OutputType} on Python 2, L{io.StringIO} on Python 3.
)rB   rD   rE   s      r   rI   rI   Â   s   € ô" 	�3‹€AØ‡F�Fˆ3„KØ€Hr   c                   ó*   • \ rS rSrSrS rS rS rSrg)Ú	EphemeraléØ   z\
This type of object is never persisted; if possible, even references to it
are eliminated.
c                 ó   • [         S4$ )z]
Serialize any subclass of L{Ephemeral} in a way which replaces it with
L{Ephemeral} itself.
r   )rN   )Úselfs    r   Ú
__reduce__ÚEphemeral.__reduce__Þ   s   € ô
 ˜2ˆÐr   c                 óÚ   • [         R                  " SU -  5        [        (       dG  SS Kn[	        USS 5      (       a1  UR                  U 5       H  n[         R                  " SU 35        M     g )Nz!WARNING: serializing ephemeral %sr   Úget_referrersz referred to by )r   r   r   Úgcr   rU   )rQ   rV   Úrs      r   Ú__getstate__ÚEphemeral.__getstate__å   sW   € Ü�ŠÐ3°dÑ:Ô;ßŠuÛä�r˜?¨D×1Ñ1Ø×)Ñ)¨$Ö/�AÜ—G’GÐ.¨q¨cÐ2Ö3ñ 0àr   c                 ó`   • [         R                  " SU R                  -  5        [        U l        g )Nz#WARNING: unserializing ephemeral %s)r   r   r   rN   ©rQ   Ústates     r   Ú__setstate__ÚEphemeral.__setstate__ï   s   € Ü�ŠÐ5¸¿¹ÑFÔGÜ"ˆ�r   )r   N)	r   r+   r,   Ú__firstlineno__Ú__doc__rR   rX   r]   Ú__static_attributes__r   r   r   rN   rN   Ø   s   † ñò
òõ#r   rN   Ú	VersionedÚversionedsToUpgradec                  ój   • [        [        R                  5       5       H  n [        U 5        M     0 q0 qg ©N)Úlistrc   ÚvaluesÚrequireUpgradeÚupgraded)Ú	versioneds    r   Ú	doUpgraderk   ø   s.   € äÔ-×4Ñ4Ó6Ö7ˆ	Ü�yÖ!ñ 8àÐØ�Hr   c                 óz   • [        U 5      nU[        ;   a&  U[        ;  a  S[        U'   U R                  5         U $ gg)z?Require that a Versioned instance be upgraded completely first.é   N)Úidrc   ri   ÚversionUpgrade)ÚobjÚobjIDs     r   rh   rh      s=   € äˆs‹G€EØÔ#Ó#¨´XÓ(=ØŒ�‰Ø×ÑÔØˆ
ð )>Ð#r   c                 ó´   • U [         /n[        R                  " U 5       H2  nX!;  d  M
  [        U[         5      (       d  M!  UR	                  U5        M4     USS $ )z�
Get all of the parent classes of C{c}, not including C{c} itself, which are
strict subclasses of L{Versioned}.

@param c: a class
@returns: list of classes
é   N)rb   ÚinspectÚgetmroÚ
issubclassÚappend)ÚcÚlÚbs      r   Ú_aybabtur{   	  sI   € ð 
ŒIˆ€AÜ�^Š^˜AÖˆØ�:œ* Q¬	×2Ó2Ø�H‰H�QŽKñ ð ˆQˆRˆ5€Lr   c                   ó6   • \ rS rSrSrSrSrS rS
S jrS r	S	r
g)rb   i  az  
This type of object is persisted with versioning information.

I have a single class attribute, the int persistenceVersion.  After I am
unserialized (and styles.doUpgrade() is called), self.upgradeToVersionX()
will be called for each version upgrade I must undergo.

For example, if I serialize an instance of a Foo(Versioned) at version 4
and then unserialize it when the code is at version 9, the calls::

  self.upgradeToVersion5()
  self.upgradeToVersion6()
  self.upgradeToVersion7()
  self.upgradeToVersion8()
  self.upgradeToVersion9()

will be made.  If any of these methods are undefined, a warning message
will be printed.
r   r   c                 ó4   • U [         [        U 5      '   Xl        g re   )rc   rn   Ú__dict__r[   s     r   r]   ÚVersioned.__setstate__3  s   € Ø(,ÔœB˜t›HÑ%Ø�r   Nc                 ó²  • [         R                   " U=(       d    U R                  5      n[        U R                  5      nUR	                  5         UR                  U R                  5        U Hg  nSUR                  ;   a  UR                   H  nXR;   d  M
  X%	 M     SUR                  ;   d  MA  UR                  U[        R                  " U5       S3'   Mi     U$ )z8Get state, adding a version number to it on its way out.ÚpersistenceForgetsÚpersistenceVersionz.persistenceVersion)
Úcopyr~   r{   r   Úreverserw   r�   r‚   r   Úqual)rQ   ÚdictÚdctÚbasesÚbaseÚslots         r   rX   ÚVersioned.__getstate__7  s¯   € ä�iŠi˜×- §¡Ó.ˆÜ˜Ÿ™Ó(ˆØ�‰ŒØ�‰�T—^‘^Ô$ÛˆDØ# t§}¡}Ó4Ø ×3Ô3�DØ•{ØšIñ 4ð $ t§}¡}Õ4ð ×+Ñ+ð Ü—|’| DÓ)Ð*Ð*=Ð>óñ ð ˆ
r   c                 óx  • [        U R                  5      nUR                  5         UR                  U R                  5        SU R                  ;   aˆ  U R                  S   nU R                  S	 SnSnU H5  nSUR                  ;  a  M  UR
                  U:”  d  M'  UnUR
                  nM7     U(       a&  UU R                  S[        R                  " U5      -  '   U GH[  n[        UR                  ;  a  SUR                  ;  a  M*  UR
                  nS[        R                  " U5      -  nU R                  R                  U5      =(       d    SnU(       a  U R                  U	 X†::  d   S5       eX†:  d  Mš  US-   nUR                  R                  SU-  S5      n	U	(       aj  [        R                  " S[        R                  " U5      < S	[        R                  " U R                  5      < S
[        U 5      < SU< 35        U	" U 5        O%[        R                  " SR                  XX5      5        X†:  a  MÁ  GM^     g)z (internal) Do a version upgrade.r‚   r   Nz%s.persistenceVersionz"Sorry, can't go backwards in time.rm   zupgradeToVersion%sz
Upgrading z (of z @ z) to version z(Warning: cannot upgrade {} to version {})r{   r   r„   rw   r~   r‚   r   r…   rb   Ú	__bases__Úgetr   r   rn   Úformat)
rQ   rˆ   ÚpverÚhighestVersionÚhighestBaser‰   ÚcurrentVersÚpverNameÚpersistVersr   s
             r   ro   ÚVersioned.versionUpgradeH  sØ  € ä˜Ÿ™Ó(ˆð 	�‰ŒØ�‰�T—^‘^Ô$à 4§=¡=Ó0ð —=‘=Ð!5Ñ6ˆDØ—‘Ð2Ð3ØˆNØˆKÛ�Ø'¨t¯}©}Ó<ÙØ×*Ñ*¨^Õ;Ø"&�KØ%)×%<Ñ%<’Nñ ö ð ð —‘Ø+¬g¯lªl¸;Ó.GÑGñô ˆDô  §¡Ó/Ø(°·±Ó=áØ×1Ñ1ˆKØ.´·²¸dÓ1CÑCˆHØŸ-™-×+Ñ+¨HÓ5×:¸ˆKÞØ—M‘M (Ð+ØÓ-ÐSÐ/SÓSÐ-ØÕ+Ø)¨A™o�ØŸ™×*Ñ*Ð+?À+Ñ+MÈtÓT�ÞÜ—G“Gô $ŸLšL¨Ö.Ü#ŸLšL¨¯©Ö8Ü˜tžHÚ'ðôñ ˜4•Lä—G’GØB×IÑIØ óôð ×+Ð+ò r   )r~   re   )r   r+   r,   r_   r`   r‚   r�   r]   rX   ro   ra   r   r   r   rb   rb     s$   † ñð( ÐØÐòôõ"?r   ),r`   rƒ   ÚcopyregÚcopy_regrt   Úpickler   Úior   rB   Útypingr   Útwisted.pythonr   r   Útwisted.python.compatr   r   ÚstrÚ
ModuleTypeÚ__annotations__ÚPicklingErrorr'   r   r   r
   r   r.   r(   ÚFunctionTyper6   r4   r@   r<   rK   rI   rN   rc   Úintri   rk   rh   r{   rb   r   r   r   Ú<module>r¤      s  ðò
ó Û Û Û Û Ý %Ý ç 'Ý 'à*,€
ˆD��e×&Ñ&Ð&Ñ'Ó ,ð !×.Ñ.Ð òòò$ð@ 	‡‚�× Ñ  ,Ô /òRò"(ð& 	‡‚�×"Ñ" OÔ 4ò.ò
)ð 	‡‚�× Ñ  ,Ô /òAòò*Aò ÷,#ñ #ð8 /1Ð �T˜#˜{Ð*Ñ+Ó 0Ø€òòò÷$lò lr   