§
    Ètºf1  ã                   óÌ  — U d Z ddlZddlZddlZddlZddlZddlmZ	 ddl
mZ ddlmZmZ ddlmZ i Zeeej        f         ed<   ej        Zd„ Zd	„ Zd
„ Z ej        ej        e¦  «         d„ Zd„ Z ej        ej        e¦  «         d„ Zd„ Z ej        ej        e¦  «         d„ Z d„ Z!d„ Z"d„ Z# G d„ d¦  «        Z$i a%ee&df         ed<   i a'd„ Z(d„ Z)d„ Z* G d„ d¦  «        Z+dS )z(
Different styles of persisted objects.
é    N)ÚStringIO)ÚDict)ÚlogÚreflect)Ú_PYPYÚ
oldModulesc                 óB   — t           | j        | j        | j        j        ffS )z3support function for copy_reg to pickle method refs)ÚunpickleMethodÚ__name__Ú__self__Ú	__class__)Úmethods    úW/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/persisted/styles.pyÚpickleMethodr      s$   € õ 	Ø	Œ˜&œ/¨6¬?Ô+DÐEðð ó    c                 ó&   — t          | |¦  «        }|S )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Ô3€LØÐr   c                 ó  — |€t          || ¦  «        S 	 t          || ¦  «        }d}t          j        ||g|¢R Ž }|S # t          $ rF t          j        d| d|¦  «         |€
J d¦   «         ‚|j        |u r‚ t          | ||j        ¦  «        cY S w xY w)aS  
    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}
    N© Ú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 Ñ)Ô)Ð)ðÝ(¨°7Ñ;Ô;ˆð ˆ
ÝÔ  °ÐF¸:ÐFÐFÐFˆØˆøõ ð Cð Cð CÝŒ�˜' >°8Ñ<Ô<Ð<ØÐ"Ð"Ð$MÑ"Ô"Ð"ð Ô Ð(Ð(ØÝ˜g w°Ô0AÑBÔBÐBÐBÐBðCøøøs   ”; »ABÂ
Bc                 ó¨   — | j         dk    rt          d| › �¦  «        ‚t          t          d                     | j        | j        g¦  «        g¦  «        fS )a—  
    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   sS   € ð 	„z�ZÒÐÝ%Ð&KÈÐ&KÐ&KÑLÔLÐLÝ�u c§h¢h°´¸a¼nÐ/MÑ&NÔ&NÐ%OÑPÔPÐQÐQr   c                 ó$   — ddl m}  || ¦  «        S )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Ð/Ð/Ð/Ð/Ð/àˆ8Ð&Ñ'Ô'Ð'r   c                 ó    — t           | j        ffS )z3support function for copy_reg to pickle module refs)ÚunpickleModuler   )Úmodules    r   ÚpickleModuler6   ~   s   € å˜FœOÐ-Ð-Ð-r   c                 ó¨   — | t           v r8t          j        d| z  ¦  «         t           |          } t          j        | ¦  «         t          | i i d¦  «        S )z5support function for copy_reg to unpickle module refszModule has moved: %sÚx)r   r   r   Ú
__import__)Únames    r   r4   r4   ƒ   sN   € à�zÐÐÝŒÐ&¨Ñ-Ñ.Ô.Ð.Ý˜$ÔˆÝŒ�‰ŒˆÝ�d˜B  CÑ(Ô(Ð(r   c                 ób   — 	 t           |                      ¦   «         |                      ¦   «         ffS )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                 óv   — t          ¦   «         }|                     | ¦  «         |                     |¦  «         |S )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<   �   s0   € õ 	‰Œ€AØ‡G‚GˆC�L„L€LØ‡F‚Fˆ3�K„K€KØ€Hr   c                 ó`   — t           |                      ¦   «         |                      ¦   «         ffS )aQ  
    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                 óN   — t          | ¦  «        }|                     |¦  «         |S )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„K€KØ€Hr   c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )Ú	Ephemeralzh
    This type of object is never persisted; if possible, even references to it
    are eliminated.
    c                 ó   — t           dfS )zu
        Serialize any subclass of L{Ephemeral} in a way which replaces it with
        L{Ephemeral} itself.
        r   )rN   )Úselfs    r   Ú
__reduce__zEphemeral.__reduce__Þ   s   € õ
 ˜2ˆÐr   c                 óÊ   — t          j        d| z  ¦  «         t          sDdd l}t	          |dd ¦  «        r/|                     | ¦  «        D ]}t          j        d|› �¦  «         Œd S )Nz!WARNING: serializing ephemeral %sr   Úget_referrersz referred to by )r   r   r   Úgcr   rS   )rP   rT   Úrs      r   Ú__getstate__zEphemeral.__getstate__å   s{   € ÝŒÐ3°dÑ:Ñ;Ô;Ð;Ýð 	4ØˆIˆIˆIå�r˜?¨DÑ1Ô1ð 4Ø×)Ò)¨$Ñ/Ô/ð 4ð 4�AÝ”GÐ2¨qÐ2Ð2Ñ3Ô3Ð3Ð3Øˆtr   c                 óV   — t          j        d| j        z  ¦  «         t          | _        d S )Nz#WARNING: unserializing ephemeral %s)r   r   r   rN   ©rP   Ústates     r   Ú__setstate__zEphemeral.__setstate__ï   s%   € ÝŒÐ5¸¼ÑFÑGÔGÐGÝ"ˆŒˆˆr   N)r   r+   r,   Ú__doc__rQ   rV   rZ   r   r   r   rN   rN   Ø   sK   € € € € € ðð ð
ð ð ðð ð ð#ð #ð #ð #ð #r   rN   Ú	VersionedÚversionedsToUpgradec                  ó~   — t          t                               ¦   «         ¦  «        D ]} t          | ¦  «         Œi ai ad S ©N)Úlistr]   ÚvaluesÚrequireUpgradeÚupgraded)Ú	versioneds    r   Ú	doUpgradere   ø   sF   € åÕ-×4Ò4Ñ6Ô6Ñ7Ô7ð "ð "ˆ	Ý�yÑ!Ô!Ð!Ð!ØÐØ€H€H€Hr   c                 óŒ   — t          | ¦  «        }|t          v r)|t          vr"dt          |<   |                      ¦   «          | S dS dS )z?Require that a Versioned instance be upgraded completely first.é   N)Úidr]   rc   ÚversionUpgrade)ÚobjÚobjIDs     r   rb   rb      sQ   € åˆs‰GŒG€EØÕ#Ð#Ð#¨µXÐ(=Ð(=Ø��‰Ø×ÒÑÔÐØˆ
ð $Ð#Ð(=Ð(=r   c                 ó²   — | t           g}t          j        | ¦  «        D ]0}||vr*t          |t           ¦  «        r|                     |¦  «         Œ1|dd…         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)r\   ÚinspectÚgetmroÚ
issubclassÚappend)ÚcÚlÚbs      r   Ú_aybabturu   	  sZ   € ð 
�Iˆ€AÝŒ^˜AÑÔð ð ˆØ�Aˆ:ˆ:�* Q­	Ñ2Ô2ˆ:Ø�HŠH�Q‰KŒKˆKøàˆQˆRˆRŒ5€Lr   c                   ó.   — e Zd ZdZdZdZd„ Zdd„Zd„ ZdS )	r\   a²  
    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                 óB   — | t           t          | ¦  «        <   || _        d S r_   )r]   rh   Ú__dict__rX   s     r   rZ   zVersioned.__setstate__3  s   € Ø(,Õ�B˜t™HœHÑ%ØˆŒˆˆr   Nc                 óN  — t          j         |p| j        ¦  «        }t          | j        ¦  «        }|                     ¦   «          |                     | j        ¦  «         |D ]D}d|j        v r|j        D ]	}||v r||= Œ
d|j        v r|j        |t          j	        |¦  «        › d�<   ŒE|S )z8Get state, adding a version number to it on its way out.ÚpersistenceForgetsÚpersistenceVersionz.persistenceVersion)
Úcopyrx   ru   r   Úreverserq   rz   r{   r   Úqual)rP   ÚdictÚdctÚbasesÚbaseÚslots         r   rV   zVersioned.__getstate__7  sÄ   € åŒi˜Ð- ¤Ñ.Ô.ˆÝ˜œÑ(Ô(ˆØ�Š‰ŒˆØ�Š�T”^Ñ$Ô$Ð$Øð 	,ð 	,ˆDØ# t¤}Ð4Ð4Ø Ô3ð &ð &�DØ˜s�{�{Ø ˜IøØ# t¤}Ð4Ð4ð Ô+ð Ý”| DÑ)Ô)Ð>Ð>Ð>ñøð ˆ
r   c                 ó²  — t          | j        ¦  «        }|                     ¦   «          |                     | j        ¦  «         d| j        v r]| j        d         }| j        d= d}d}|D ] }d|j        vrŒ|j        |k    r	|}|j        }Œ!|r|| j        dt          j        |¦  «        z  <   |D �]*}t          |j	        vr
d|j        vrŒ|j        }dt          j        |¦  «        z  }| j         
                    |¦  «        pd}|r| j        |= ||k    s
J d¦   «         ‚||k     rµ|dz   }|j         
                    d|z  d¦  «        }	|	rbt          j        dt          j        |¦  «        ›d	t          j        | j        ¦  «        ›d
t          | ¦  «        ›d|›�¦  «          |	| ¦  «         n(t          j        d                     ||¦  «        ¦  «         ||k     °µ�Œ,dS )z (internal) Do a version upgrade.r{   r   Nz%s.persistenceVersionz"Sorry, can't go backwards in time.rg   zupgradeToVersion%sz
Upgrading z (of z @ z) to version z(Warning: cannot upgrade {} to version {})ru   r   r}   rq   rx   r{   r   r~   r\   Ú	__bases__Úgetr   r   rh   Úformat)
rP   r�   ÚpverÚhighestVersionÚhighestBaser‚   ÚcurrentVersÚpverNameÚpersistVersr   s
             r   ri   zVersioned.versionUpgradeH  sB  € å˜œÑ(Ô(ˆð 	�Š‰ŒˆØ�Š�T”^Ñ$Ô$Ð$à 4¤=Ð0Ð0ð ”=Ð!5Ô6ˆDØ”Ð2Ð3ØˆNØˆKØð =ð =�Ø'¨t¬}Ð<Ð<ØØÔ*¨^Ò;Ð;Ø"&�KØ%)Ô%<�NøØð ð ð ”Ø+­g¬l¸;Ñ.GÔ.GÑGñð ð  	ñ  	ˆDõ  ¤Ð/Ð/Ø(°´Ð=Ð=àØÔ1ˆKØ.µ´¸dÑ1CÔ1CÑCˆHØœ-×+Ò+¨HÑ5Ô5Ð:¸ˆKØð ,Ø”M (Ð+Ø +Ò-Ð-Ð-Ð/SÑ-Ô-Ð-Ø Ò+Ð+Ø)¨A™o�Øœ×*Ò*Ð+?À+Ñ+MÈtÑTÔT�Øð Ý”G�Gõ $œL¨Ñ.Ô.Ð.Ð.Ý#œL¨¬Ñ8Ô8Ð8Ð8Ý˜t™HœH˜H˜HØ'˜Kðñô ð ð �F˜4‘L”L�L�Lå”GØB×IÒIØ  +ñô ñô ð ð  Ò+Ð+ùð 	ð  	r   r_   )	r   r+   r,   r[   r{   rz   rZ   rV   ri   r   r   r   r\   r\     s^   € € € € € ðð ð( ÐØÐðð ð ðð ð ð ð"?ð ?ð ?ð ?ð ?r   ),r[   r|   ÚcopyregÚcopy_regrn   Ú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   r]   Úintrc   re   rb   ru   r\   r   r   r   ú<module>r›      si  ðð
ð ð ð €€€Ø Ð Ð Ð Ø €€€Ø €€€Ø €€€Ø %Ð %Ð %Ð %Ð %Ð %Ø Ð Ð Ð Ð Ð à 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'à*,€
ˆD��eÔ&Ð&Ô'Ð ,Ð ,Ñ ,ð !Ô.Ð ðð ð ðð ð ð$ð ð ð@ €„�Ô  ,Ñ /Ô /Ð /ðRð Rð Rð"(ð (ð (ð& €„�Ô" OÑ 4Ô 4Ð 4ð.ð .ð .ð
)ð )ð )ð €„�Ô  ,Ñ /Ô /Ð /ðAð Að Aðð ð ð*Að Að Að ð ð ð,#ð #ð #ð #ð #ñ #ô #ð #ð8 /1Ð �T˜#˜{Ð*Ô+Ð 0Ð 0Ñ 0Ø€ðð ð ðð ð ðð ð ð$lð lð lð lð lñ lô lð lð lð lr   