HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/root/usr/lib/python3/dist-packages/twisted/persisted/__pycache__/styles.cpython-38.pyc
U


W[�4�@sdZddlmZmZddlZddlZzddlZWnek
rLddlZYnXddl	Z	ddl
Z
ddlmZm
Z
ddlmZddlmZiZzddlZWnek
r�dZYnXedks�ejejkr�ejZnGdd�dejej�Zd	d
�Zdd�Zd
d�Ze�ejee�dd�Zdd�Ze�ejee�dd�Zdd�Ze�ejee�dd�Zdd�Z dd�Z!dd�Z"zddl#m$Z$m%Z%m&Z'Wn"ek
�r�dd l(m&Z'YnXe�e%ee �e�e$e!e"�Gd!d"�d"�Z)ia*ia+d#d$�Z,d%d&�Z-d'd(�Z.Gd)d*�d*�Z/dS)+z(
Different styles of persisted objects.
�)�division�absolute_importN)�_PY3�_PYPY)�log)�reflectc@seZdZdZdS)�_UniversalPicklingErrorzz
        A PicklingError catchable by both L{cPickle.PicklingError} and
        L{pickle.PicklingError} handlers.
        N)�__name__�
__module__�__qualname__�__doc__�r
r
�:/usr/lib/python3/dist-packages/twisted/persisted/styles.pyr&srcCs4trt|j|j|jjffSt|jj|j|jffSdS)z3support function for copy_reg to pickle method refsN)r�unpickleMethodr	�__self__�	__class__�im_func�im_self�im_class)�methodr
r
r�pickleMethod1s��rcCst||�}tr|S|jS)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} or L{types.ClassType}

    @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}
    )�getattrrr)ZclassObjectZ
methodNameZmethodObjectr
r
r�_methodFunction>s
rc	Cs�|dkrt||�Szt||�}WnNtk
rnt�d|d|�|dk	sPtd��|j|kr\�t|||j�YSXtrzd}n
t	|g�}t
j||f|��}|SdS)ai
    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{types.ClassType} or L{type} or L{None}
    NZMethodznot on classz'No recourse: no instance to guess from.r
)rr�AttributeErrorr�msg�AssertionErrorrrr�tuple�types�
MethodType)Zim_namerrZmethodFunctionZ
maybeClassZboundr
r
rrSs



rcCs4|jdkrtd�|���ttd�|j|jg�g�fS)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	r�format�_unpickleFunctionr�joinr
r)�fr
r
r�_pickleFunctionys
��r$cCsddlm}||�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)Ztwisted.python.reflectr%)ZfullyQualifiedNamer%r
r
rr!�sr!cCst|jffS)z3support function for copy_reg to pickle module refs)�unpickleModuler	)�moduler
r
r�pickleModule�sr(cCs6|tkr(t�d|�t|}t�|�t|iid�S)z5support function for copy_reg to unpickle module refszModule has moved: %s�x)�
oldModulesrr�
__import__)�namer
r
rr&�s

r&cCst|��|��ffS)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: L{cStringIO.OutputType}
    )�unpickleStringO�getvalue�tell)Zstringor
r
r�
pickleStringO�sr0cCst�}|�|�|�|�|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: L{cStringIO.OutputType} on Python 2, L{io.StringIO} on Python 3.
    )�
_cStringIO�write�seek��valZsekr)r
r
rr-�s

r-cCst|��|��ffS)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: L{cStringIO.InputType}

    @return: a 2-tuple of (C{unpickleStringI}, (bytes, pointer))
    @rtype: 2-tuple of (function, (bytes, int))
    )�unpickleStringIr.r/)Zstringir
r
r�
pickleStringI�s
r7cCst|�}|�|�|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: L{cStringIO.OutputType} on Python 2, L{io.StringIO} on Python 3.
    )r1r3r4r
r
rr6�s
r6)�	InputType�
OutputType�StringIO)r:c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�	Ephemeralzh
    This type of object is never persisted; if possible, even references to it
    are eliminated.
    cCstdfS)zu
        Serialize any subclass of L{Ephemeral} in a way which replaces it with
        L{Ephemeral} itself.
        r
)r;)�selfr
r
r�
__reduce__szEphemeral.__reduce__cCsJt�d|�tsFddl}t|dd�rF|�|�D]}t�d|f�q0dS)Nz!WARNING: serializing ephemeral %sr�
get_referrersz referred to by %s)rrr�gcrr>)r<r?�rr
r
r�__getstate__szEphemeral.__getstate__cCst�d|j�t|_dS)Nz#WARNING: unserializing ephemeral %s)rrrr;�r<�stater
r
r�__setstate__"szEphemeral.__setstate__N)r	r
rrr=rArDr
r
r
rr;s	r;cCs&tt���D]}t|�qiaiadS�N)�list�versionedsToUpgrade�values�requireUpgrade�upgraded)Z	versionedr
r
r�	doUpgrade*s
rKcCs0t|�}|tkr,|tkr,dt|<|��|SdS)zDRequire that a Versioned instance be upgraded completely first.
    �N)�idrGrJ�versionUpgrade)�objZobjIDr
r
rrI1s
rIcCs@|tg}t�|�D] }||krt|t�r|�|�q|dd�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)�	Versioned�inspectZgetmro�
issubclass�append)�c�l�br
r
r�_aybabtu:s

rXc@s2eZdZdZdZdZdd�Zddd�Zd	d
�ZdS)rQa�
    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.
    rr
cCs|tt|�<||_dSrE)rGrM�__dict__rBr
r
rrDbszVersioned.__setstate__NcCs~t�|p|j�}t|j�}|��|�|j�|D]F}d|jkrZ|jD]}||krF||=qFd|jkr2|j|dt�	|�<q2|S)zAGet state, adding a version number to it on its way out.
        �persistenceForgets�persistenceVersion�%s.persistenceVersion)
�copyrYrXr�reverserTrZr[r�qual)r<�dictZdct�bases�baseZslotr
r
rrAfs



zVersioned.__getstate__c
CsVt|j�}|��|�|j�d|jkr�|jd}|jd=d}d}|D]$}d|jkrVqF|j|krF|}|j}qF|r�||jdt�|�<|D]�}t|j	kr�d|jkr�q�|j}dt�|�}|j�
|�p�d}|r�|j|=||ks�td��||kr�|d}|j�
d|d�}	|	�r<t�
dt�|�t�|j�t|�|f�|	|�q�t�
d	||f�q�q�dS)
z)(internal) Do a version upgrade.
        r[rNr\z"Sorry, can't go backwards in time.rLzupgradeToVersion%sz'Upgrading %s (of %s @ %s) to version %sz(Warning: cannot upgrade %s to version %s)rXrr^rTrYr[rr_rQ�	__bases__�getrrrrM)
r<raZpverZhighestVersionZhighestBaserbZcurrentVersZpverNameZpersistVersrr
r
rrNvsD






�(
zVersioned.versionUpgrade)N)	r	r
rrr[rZrDrArNr
r
r
rrQKs
rQ)0rZ
__future__rrr�pickleZcopy_reg�ImportError�copyregr]rRZtwisted.python.compatrrZtwisted.pythonrrr*ZcPickleZ
PicklingErrorrrrrrr$r!�FunctionTyper(r&�
ModuleTyper0r-r7r6�	cStringIOr8r9r:r1�ior;rGrJrKrIrXrQr
r
r
r�<module>sh
�
$	�