%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f����|�dZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
mZmZmZmZmZddlmZddlmZdd	lmZmZmZdd
lmZmZefZdZ dZ!d
Z"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,eedddd�ddd�dZ-ia.ia/d�Z0d�Z1d �Z2d!�Z3d"�Z4d8d#�Z5d$�Z6d%�Z7Gd&�d'�Z8e	e�Gd(�d)��Z9e	e�Gd*�d+��Z:Gd,�d-�Z;Gd.�d/�Z<Gd0�d1e=�Z>Gd2�d3�Z?Gd4�d5�Z@e@�ZAeAj��e?�ddfd6�ZCe?�ddfd7�ZDy)9aM
S-expression-based persistence of python objects.

It does something very much like L{Pickle<pickle>}; however, pickle's main goal
seems to be efficiency (both in space and time); jelly's main goals are
security, human readability, and portability to other environments.

This is how Jelly converts various objects to s-expressions.

Boolean::
    True --> ['boolean', 'true']

Integer::
    1 --> 1

List::
    [1, 2] --> ['list', 1, 2]

String::
    "hello" --> "hello"

Float::
    2.3 --> 2.3

Dictionary::
    {'a': 1, 'b': 'c'} --> ['dictionary', ['b', 'c'], ['a', 1]]

Module::
    UserString --> ['module', 'UserString']

Class::
    UserString.UserString --> ['class', ['module', 'UserString'], 'UserString']

Function::
    string.join --> ['function', 'join', ['module', 'string']]

Instance: s is an instance of UserString.UserString, with a __dict__
{'data': 'hello'}::
    ["UserString.UserString", ['dictionary', ['data', 'hello']]]

Class Method: UserString.UserString.center::
    ['method', 'center', ['None'], ['class', ['module', 'UserString'],
     'UserString']]

Instance Method: s.center, where s is an instance of UserString.UserString::
    ['method', 'center', ['instance', ['reference', 1, ['class',
    ['module', 'UserString'], 'UserString']], ['dictionary', ['data', 'd']]],
    ['dereference', 1]]

The Python 2.x C{sets.Set} and C{sets.ImmutableSet} classes are
serialized to the same thing as the builtin C{set} and C{frozenset}
classes.  (This is only relevant if you are communicating with a
version of jelly running on an older version of Python.)

@author: Glyph Lefkowitz

�N)�reduce)�implementer)�Version)�NotKnown�
_Container�_Dereference�_DictKeyAndValue�_InstanceMethod�_Tuple)�nativeString)�deprecatedModuleAttribute)�namedAny�namedObject�qual)�
IJellyable�IUnjellyable�None�class�module�functionsdereferences
persistents	references
dictionaryslist�setstuplesinstance�	frozenset�Twisted�z'instance_atom is unused within Twisted.ztwisted.spread.jelly�
instance_atoms
unpersistablec�F�t|t�r|j|�Sy)a�
    Given an object, if that object is a type, return a new, blank instance
    of that type which has not had C{__init__} called on it.  If the object
    is not a type, return L{None}.

    @param cls: The type (or class) to create an instance of.
    @type cls: L{type} or something else that cannot be
        instantiated.

    @return: a new blank instance or L{None} if C{cls} is not a class or type.
    N)�
isinstance�type�__new__)�clss �6/usr/lib/python3/dist-packages/twisted/spread/jelly.py�_createBlankr"�s"���#�t���{�{�3����c�R��t|���fd�}t�d|�}||��S)z�
    Make a new instance of a class without calling its __init__ method.

    @param state: A C{dict} used to update C{inst.__dict__} either directly or
        via C{__setstate__}, if available.

    @return: A new instance of C{cls}.
    c�>��t|t�r|xsi�_yy�N)r�dict�__dict__)�state�instances �r!�
defaultSetterz#_newInstance.<locals>.defaultSetter�s����e�T�"� %���H��#r#�__setstate__)r"�getattr)r r)r+�setterr*s    @r!�_newInstancer/�s0����C� �H�,��X�~�}�
=�F�
�5�M��Or#c��t|t�}|rt|�}t|t�s|j	d�}|S)N�utf-8)rrr�bytes�encode)�
classnamep�isObjects  r!�_maybeClassr6�s;���*�d�+�H���*�%�
��j�%�(��&�&�w�/�
��r#c�V�t|�}|t|<tj|�y)at
    Set which local class will represent a remote type.

    If you have written a Copyable class that you expect your client to be
    receiving, write a local "copy" class to represent it, then call::

        jellier.setUnjellyableForClass('module.package.Class', MyCopier).

    Call this at the module level immediately after its class
    definition. MyCopier should be a subclass of RemoteCopy.

    The classname may be a special tag returned by
    'Copyable.getTypeToCopyFor' rather than an actual classname.

    This call is also for cached classes, since there will be no
    overlap.  The rules are the same.
    N)r6�unjellyableRegistry�globalSecurity�
allowTypes)�	classname�unjellyables  r!�setUnjellyableForClassr=�s'��(�I�&�I�%0��	�"����i�(r#c�V�t|�}|t|<tj|�y)a�
    Set the factory to construct a remote instance of a type::

      jellier.setUnjellyableFactoryForClass('module.package.Class', MyFactory)

    Call this at the module level immediately after its class definition.
    C{copyFactory} should return an instance or subclass of
    L{RemoteCopy<pb.RemoteCopy>}.

    Similar to L{setUnjellyableForClass} except it uses a factory instead
    of creating an instance.
    N)r6�unjellyableFactoryRegistryr9r:)r;�copyFactorys  r!�setUnjellyableFactoryForClassrA�s'���I�&�I�,7��y�)����i�(r#c���|�|j}|rd|z}t|�D].}t||�}	t||�}|s�t	|�|��|��0y#t
$rY�=wxYw)a�
    Set all classes in a module derived from C{baseClass} as copiers for
    a corresponding remote class.

    When you have a hierarchy of Copyable (or Cacheable) classes on one
    side, and a mirror structure of Copied (or RemoteCache) classes on the
    other, use this to setUnjellyableForClass all your Copieds for the
    Copyables.

    Each copyTag (the "classname" argument to getTypeToCopyFor, and
    what the Copyable's getTypeToCopyFor returns) is formed from
    adding a prefix to the Copied's class name.  The prefix defaults
    to module.__name__.  If you wish the copy tag to consist of solely
    the classname, pass the empty string ''.

    @param module: a module object from which to pull the Copied classes.
        (passing sys.modules[__name__] might be useful)

    @param baseClass: the base class from which all your Copied classes derive.

    @param prefix: the string prefixed to classnames to form the
        unjellyableRegistry.
    Nz%s.)�__name__�dirr-�
issubclassr=�	TypeError)�module�	baseClass�prefix�name�loaded�yess      r!�setUnjellyableForClassTreerM�s}��0�~�����
������F��B�����&��	B��V�Y�/�C��&�&��$��'8�&�A�B���	 ��	 �s�A�	A�Ac�"�t|d�r|j�}n|j}|j|�}|j	t|j�jd�|j|�g�|j||�S)zM
    Utility method to default to 'normal' state rules in serialization.
    �__getstate__r1)
�hasattrrOr(�prepare�extendr�	__class__r3�jelly�preserve)�inst�jellierr)�sxps    r!�getInstanceStaterYst���t�^�$��!�!�#���
�
��
�/�/�$�
�C��J�J��T�^�^�$�+�+�G�4�g�m�m�E�6J�K�L����D�#�&�&r#c�z�|j|d�}t|d�r|j|�|S||_|S)zO
    Utility method to default to 'normal' state rules in unserialization.
    �r,)�unjellyrPr,r()rV�	unjellier�	jellyListr)s    r!�setInstanceStater_sE��
���i��l�+�E��t�^�$����%� ��K���
��Kr#c�"�eZdZdZd�Zdefd�Zy)�
Unpersistablezd
    This is an instance of a class that comes back when something couldn't be
    unpersisted.
    c��||_y)zY
        Initialize an unpersistable object with a descriptive C{reason} string.
        N)�reason)�selfrcs  r!�__init__zUnpersistable.__init__&s����r#�returnc�2�dt|j�zS)NzUnpersistable(%s))�reprrc�rds r!�__repr__zUnpersistable.__repr__,s��"�T�$�+�+�%6�6�6r#N)rC�
__module__�__qualname__�__doc__re�strrj�r#r!rara s���
�7�#�7r#rac��eZdZdZd�Zd�Zy)�	Jellyablezc
    Inherit from me to Jelly yourself directly with the `getStateFor'
    convenience method.
    c��|jSr&�r()rdrWs  r!�getStateForzJellyable.getStateFor7s���}�}�r#c���|j|�}|jt|j�j	d�|j|j
|��g�|j||�S)zH
        @see: L{twisted.spread.interfaces.IJellyable.jellyFor}
        r1)rQrRrrSr3rTrtrU)rdrWrXs   r!�jellyForzJellyable.jellyFor:sf���o�o�d�#���
�
��T�^�^�$�+�+�G�4��
�
�d�.�.�w�7�8�
�	
�����c�*�*r#N)rCrkrlrmrtrvror#r!rqrq0s���
�+r#rqc��eZdZdZd�Zd�Zy)�Unjellyablezf
    Inherit from me to Unjelly yourself directly with the
    C{setStateFor} convenience method.
    c��||_yr&rs)rdr]r)s   r!�setStateForzUnjellyable.setStateForOs	����
r#c�R�|j|d�}|j||�|S)z�
        Perform the inverse operation of L{Jellyable.jellyFor}.

        @see: L{twisted.spread.interfaces.IUnjellyable.unjellyFor}
        r[)r\rz)rdr]r^r)s    r!�
unjellyForzUnjellyable.unjellyForRs-���!�!�)�A�,�/������E�*��r#N)rCrkrlrmrzr|ror#r!rxrxHs���
�r#rxc�H�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zdd�Zy
)
�_JellierzC
    (Internal) This class manages state for a call to jelly()
    c�f�||_i|_i|_i|_d|_||_||_y)z
        Initialize.
        r[N)�taster�	preserved�cooked�cooker�_ref_id�persistentStore�invoker)rdr�r�r�s    r!rez_Jellier.__init__bs8�����������������.�����r#c���|jt|�}tj|�}|j}|jdz|_t||g|ddt
|g|jt|�<|S)a�
        (internal) Backreference an object.

        Notes on this method for the hapless future maintainer: If I've already
        gone through the prepare/preserve cycle on the specified object (it is
        being referenced after the serializer is "done with" it, e.g. this
        reference is NOT circular), the copy-in-place of aList is relevant,
        since the list being modified is the actual, pre-existing jelly
        expression that was returned for that object. If not, it's technically
        superfluous, since the value in self.preserved didn't need to be set,
        but the invariant that self.preserved[id(object)] is a list is
        convenient because that means we don't have to test and create it or
        not create it here, creating fewer code-paths.  that's why
        self.preserved is always set to a list.

        Sorry that this code is so hard to follow, but Python objects are
        tricky to persist correctly. -glyph
        r[N)r��id�copyr��reference_atom�dereference_atomr�)rd�object�aList�newList�refids     r!�_cookz_Jellier._cookqsk��&���r�&�z�*���)�)�E�"�������|�|�a�'���#�E�7�3��a��#3�U�";����B�v�J���r#c�f�g|jt|�<||jt|�<gS)a]
        (internal) Create a list for persisting an object to.  This will allow
        backreferences to be made internal to the object. (circular
        references).

        The reason this needs to happen is that we don't generate an ID for
        every object, so we won't necessarily know which ID the object will
        have in the future.  When it is 'cooked' ( see _cook ), it will be
        assigned an ID, and the temporary placeholder list created here will be
        modified in-place to create an expression that gives this object an ID:
        [reference id# [object-jelly]].
        )r�r�r�)rdr�s  r!rQz_Jellier.prepare�s/��&(����r�&�z�"�#)����B�v�J���	r#c���t|�|jvr5||jt|�d<|jt|�}|S||jt|�<|S)zQ
        (internal) Mark an object's persistent list for later referral.
        �)r�r�r�)rdr��sexps   r!rUz_Jellier.preserve�s]��
�f�:����$�,0�D�N�N�2�f�:�&�q�)��>�>�"�V�*�-�D���*.�D�N�N�2�f�:�&��r#c��t|�}||jvr|j|S||jvr |j|�|j|Syr&)r�r�r�r�)rd�obj�objIds   r!�
_checkMutablez_Jellier._checkMutable�sQ���3����D�K�K���;�;�u�%�%��D�N�N�"��J�J�s�O��;�;�u�%�%�#r#c
�0
�t|t�r&|j|�}|r|S|j|�St	|�}|j
j
t|�jd���r�|tttfvr|St|tj�rR|j}|j}|j }d|j"|j%|�|j%|�gS|t&urd|jd�gSt|t	d��rdgSt|tj(�rd|j*dz|j,zgSt|tj.�rd|j"gS|t0urd	|xrd
xsdgS|t2j2ur�|j4rt7d��d
dj9|j:|j<|j>|j@|jB|jD|jFfD�cgc]
}t'|���c}�jd�gS|t2jHur||j4rt7d��ddj9|j@|jB|jD|jFfD�cgc]
}t'|���c}�jd�gS|t2jJurZddj9|j:|j<|j>fD�cgc]
}t'|���c}�jd�gS|t2jLurZddj9|jN|jP|jRfD�cgc]
}t'|���c}�jd�gStU|t�rdt|�jd�gS|tVjXur|j[|�S|j|�}|r|S|j]|�}|t^ur'|ja|jctd|���n
|tfur'|ja|jcth|���n�|tjvr`|jmtn�|jq�D]6\}	}
|jm|j%|	�|j%|
�g��8�ns|trur'|ja|jctt|���nD|tvur'|ja|jctx|���nt|j �jd�}d}|jzr|j{||�}|�'|jmt|�|jm|�n�|j
j|j �r[|jm|�t�|d�r|j��}
n|j�}
|jm|j%|
��n(|j�dt|j �z|�|j�||�St�d|�d|����cc}wcc}wcc}wcc}w)Nr1smethod�unicode�UTF-8rr�.r�boolean�true�falsez2Currently can't jelly datetime objects with tzinfo�datetime� �time�date�	timedeltarrOz$instance of class %s deemed insecurezType not allowed for object: )Frrqr�rvrr��
isTypeAllowedrr3r2�int�float�types�
MethodType�__self__�__func__rSrCrTrn�FunctionTyperkrl�
ModuleType�bool�datetime�tzinfo�NotImplementedError�join�year�month�day�hour�minute�second�microsecond�time�date�	timedelta�days�seconds�microsecondsrE�decimal�Decimal�
jelly_decimalrQ�listrR�_jellyIterable�	list_atom�tuple�
tuple_atom�	DictTypes�append�dictionary_atom�items�set�set_atom�	frozenset�frozenset_atomr��persistent_atom�isClassAllowedrPrOr(�
unpersistablerU�
InsecureJelly)rdr��preRef�objType�aSelf�aFunc�aClass�xrX�key�val�	className�
persistentr)s              r!rTz_Jellier.jelly�s����c�9�%��'�'��,�F���
��<�<��%�%��s�)���;�;�$�$�T�'�]�%9�%9�'�%B�C��5�#�u�-�-��
��C��!1�!1�2���������������N�N��J�J�u�%��J�J�v�&�	���C��"�C�J�J�w�$7�8�8��C��d��,��y� ��C��!3�!3�4�#�S�^�^�c�%9�C�<L�<L�%L�M�M��C��!1�!1�2�!�3�<�<�0�0��D��"�C�O�G�$?�x�@�@��H�-�-�-��:�:�-�L��� ��H�H�!$��� #�	�	� #��� #��� #�
�
� #�
�
� #���&�� !� ��F��
��f�W�o���"�H�M�M�)��:�:�-�L�����H�H�'*�h�h��
�
�C�J�J����%X�� !� ��F���
�f�W�o����H�M�M�)���H�H�s�x�x����C�G�G�.L�M��c�!�f�M�N�U�U������H�.�.�.� ��H�H�*-�(�(�C�K�K��AQ�AQ�)R�S�A��Q��S���f�W�o�	���G�T�*� �$�s�)�"2�"2�7�";�<�<��G�O�O�+��)�)�#�.�.��+�+�C�0���!�M��l�l�3�'���d�?��J�J�t�2�2�9�c�B�C���%��J�J�t�2�2�:�s�C�D��	�)��J�J��/�$'�I�I�K�G���S��
�
�D�J�J�s�O�T�Z�Z��_�#E�F�G���^��J�J�t�2�2�8�S�A�B��	�)��J�J�t�2�2�>�3�G�H� $�S�]�]� 3� :� :�7� C�I�!%�J��+�+�%)�%9�%9�#�t�%D�
�!�-��
�
�?�3��
�
�:�.����3�3�C�M�M�B��
�
�9�-�"�3��7�$'�$4�$4�$6�E�$'�L�L�E��
�
�4�:�:�e�#4�5��*�*�B�"�3�=�=�1�2���
�}�}�S�#�.�.��"?��y��#�� O�P�P��o��,��N��Ts�$Z
�2Z	
�Z
�
Z
c#�HK�|��|D]}|j|����y�w)a
        Jelly an iterable object.

        @param atom: the identifier atom of the object.
        @type atom: C{str}

        @param obj: any iterable object.
        @type obj: C{iterable}

        @return: a generator of jellied data.
        @rtype: C{generator}
        N)rT)rd�atomr��items    r!r�z_Jellier._jellyIterable=s+�����
��	#�D��*�*�T�"�"�	#�s� "c�X�|j�\}}}td�|�}|r|}d||gS)z�
        Jelly a decimal object.

        @param d: a decimal object to serialize.
        @type d: C{decimal.Decimal}

        @return: jelly for the decimal object.
        @rtype: C{list}
        c��|dz|zS)N�
ro)�left�rights  r!�<lambda>z(_Jellier.jelly_decimal.<locals>.<lambda>Ys��4�"�9�u�+<�r#�decimal)�as_tupler)rd�d�sign�guts�exponent�values      r!r�z_Jellier.jelly_decimalNs:�� !�z�z�|���d�H��<�d�C����F�E��E�8�,�,r#Nc��|�g}|jt�t|t�r|j	d�}|j|�|S)z�
        (internal) Returns an sexp: (unpersistable "reason").  Utility method
        for making note that a particular object could not be serialized.
        r1)r��unpersistable_atomrrnr3)rdrcrXs   r!r�z_Jellier.unpersistable^sD��
�;��C��
�
�%�&��f�c�"��]�]�7�+�F��
�
�6���
r#r&)
rCrkrlrmrer�rQrUr�rTr�r�r�ror#r!r~r~]s7���
��<�0�&�~Q�@#�"-� r#r~c��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�
_Unjellierc�J�||_||_i|_g|_||_yr&)r��persistentLoad�
references�
postCallbacksr�)rdr�r�r�s    r!rez_Unjellier.__init__ms'�����,�����������r#c�X�|j|�}|jD]	}|��|Sr&)r\r�)rdr��o�ms    r!�unjellyFullz_Unjellier.unjellyFullts/���L�L�����#�#�	�A�
�C�	��r#c�h�t|d�r%|jj|j�|S)z�
        If the given object has support for the C{postUnjelly} hook, set it up
        to be called at the end of deserialization.

        @param unjellied: an object that has already been unjellied.

        @return: C{unjellied}
        �postUnjelly)rPr�r�r�)rd�	unjellieds  r!�_maybePostUnjellyz_Unjellier._maybePostUnjellyzs.���9�m�,����%�%�i�&;�&;�<��r#c��t|�tur|S|d}|jj|�st	|��t
j
|�}|�.tt|�d|�}|j|||��Stj
|�}|�)|j||j|d���St|�}t|d|zd�}|�||dd�S|jd�}dj|dd�}	|jj|	�st	d|	�d|�d	���t!|�}
|jj#|
�st	d
|z��|j%|
|d�S)Nrr|r[z_unjelly_%sr����zModule z not allowed (in type z).zClass %s not allowed.)rr�r�r�r�r8�getr-r"r�r?r\r�splitr��isModuleAllowedrr��_genericUnjelly)rdr��jelTypeBytes�regClass�method�
regFactory�jelTypeText�thunk�	nameSplit�modName�clzs           r!r\z_Unjellier.unjelly�s�����9�D� ��J��1�v���{�{�(�(��6���-�-�&�*�*�<�8�����\�(�3�\�8�L�F��)�)�&��s�*;�<�<�/�3�3�L�A�
��!��)�)�*�T�\�\�#�a�&�5I�*J�K�K�"�<�0����m�k�9�4�@������Q�R��>�!�#�)�)�#�.�I��h�h�y��"�~�.�G��;�;�.�.�w�7�#��g�Y�&<�[�M��L����k�*�C��;�;�-�-�c�2�#�$;�k�$I�J�J��'�'��S��V�4�4r#c�V�|jt||j|���S)a�
        Unjelly a type for which no specific unjellier is registered, but which
        is nonetheless allowed.

        @param cls: the class of the instance we are unjellying.
        @type cls: L{type}

        @param state: The jellied representation of the object's state; its
            C{__dict__} unless it has a C{__setstate__} that takes something
            else.
        @type state: L{list}

        @return: the new, unjellied instance.
        )r�r/r\)rdr r)s   r!rz_Unjellier._genericUnjelly�s%���%�%�l�3����U�8K�&L�M�Mr#c��yr&ro�rd�exps  r!�
_unjelly_Nonez_Unjellier._unjelly_None�s��r#c� �t|dd�S)Nrr�)rnrs  r!�_unjelly_unicodez_Unjellier._unjelly_unicode�s���3�q�6�7�#�#r#c��|d}|d}|dkrd}nd}tj|�j�d}tj|||f�S)z*
        Unjelly decimal objects.
        rr[)r�r�r�)rdrr�r�r�r�s      r!�_unjelly_decimalz_Unjellier._unjelly_decimal�sY���A����q�6���1�9��D��D����u�%�.�.�0��3������d�H�5�6�6r#c�$�|ddvsJ�|ddk(S)Nr)r�r�r�rors  r!�_unjelly_booleanz_Unjellier._unjelly_boolean�s$���1�v�,�,�,�,��1�v�� � r#c�d�tjtt|dj���S�Nr)r��mapr�rrs  r!�_unjelly_datetimez_Unjellier._unjelly_datetime�s$��� � �#�c�3�q�6�<�<�>�":�;�;r#c�d�tjtt|dj	���Sr)r�r�rr�rrs  r!�
_unjelly_datez_Unjellier._unjelly_date��"���}�}�c�#�s�1�v�|�|�~�6�7�7r#c�d�tjtt|dj	���Sr)r�r�rr�rrs  r!�
_unjelly_timez_Unjellier._unjelly_time�rr#c�|�tt|dj��\}}}tj|||��S)Nr)r�r�r�)rr�rr�r�)rdrr�r�r�s     r!�_unjelly_timedeltaz_Unjellier._unjelly_timedelta�s4��&)�#�s�1�v�|�|�~�&>�#��g�|��!�!�t�W�<�X�Xr#c�v�|j|�}t|t�r|j||�|||<|Sr&)r\rr�addDependant)rdr��loc�jelr�s     r!�unjellyIntoz_Unjellier.unjellyInto�s6���L�L�����a��"�
�N�N�3��$���C���r#c��|d}|jj|�}|�|St|�}||j|<|Sr)r�rr)rd�lstr�r��ders     r!�_unjelly_dereferencez_Unjellier._unjelly_dereference�sF���A����O�O����&���=��H��5�!��!$�������
r#c��|d}|d}|j|�}|jj|�}|�||j|<|St|t�r"|j|�||j|<|SJd��)Nrr[z!Multiple references with same ID!)r\r�rrr�resolveDependants)rdr)r�rr��refs      r!�_unjelly_referencez_Unjellier._unjelly_reference�s����A����!�f���L�L�����o�o�!�!�%�(���;�%&�D�O�O�E�"�����X�
&��!�!�!�$�%&�D�O�O�E�"���
:�9�9�1r#c	���ttt|���}d}|D])}t|j	||||�t
�s�(d}�+|rt
|�St|�S)Nr[r)r��range�lenrr'rr�r)rdr)�l�finished�elems     r!�_unjelly_tuplez_Unjellier._unjelly_tuple�sb����s�3�x��!�����	�D��$�*�*�1�d�C��I�>��I���	����8�O��!�9�r#c�z�ttt|���}|D]}|j||||��|Sr&)r�r1r2r')rdr)r3r5s    r!�
_unjelly_listz_Unjellier._unjelly_lists>����s�3�x��!���	1�D����Q��c�$�i�0�	1��r#c���ttt|���}d}|D]+}|j||||�}t	|t
�s�*d}�-|st
||�S||�S)z�
        Helper method to unjelly set or frozenset.

        @param lst: the content of the set.
        @type lst: C{list}

        @param containerType: the type of C{set} to use.
        TF)r�r1r2r'rrr)rdr)�
containerTyper3r4r5�datas       r!�_unjellySetOrFrozensetz!_Unjellier._unjellySetOrFrozenset	sn��
��s�3�x��!�����	!�D��#�#�A�t�S��Y�7�D��$��)� ��	!���a��/�/� ��#�#r#c�.�|j|t�S)z7
        Unjelly set using the C{set} builtin.
        )r<r��rdr)s  r!�_unjelly_setz_Unjellier._unjelly_sets���*�*�3��4�4r#c�.�|j|t�S)zC
        Unjelly frozenset using the C{frozenset} builtin.
        )r<r�r>s  r!�_unjelly_frozensetz_Unjellier._unjelly_frozenset#s���*�*�3�	�:�:r#c��i}|D]6\}}t|�}|j|d|�|j|d|��8|S)Nrr[)r	r')rdr)r��k�v�kvds      r!�_unjelly_dictionaryz_Unjellier._unjelly_dictionary)sO�����	(�D�A�q�"�1�%�C����S�!�Q�'����S�!�Q�'�	(��r#c���t|d�}t|�tk7rtd��|jj|�std|����t
|iid�}|S)Nrz5Attempted to unjelly a module with a non-string name.z"Attempted to unjelly module named r�)rrrnr�r�r�
__import__)rd�rest�
moduleName�mods    r!�_unjelly_modulez_Unjellier._unjelly_module1sc��!�$�q�'�*�
��
��s�"�� W�X�X��{�{�*�*�:�6��"D�Z�N� S�T�T���R��S�1���
r#c��t|d�}|jtd��}td�j|dd�}|jj	|�std|z��t
|�}t|�}|turtd|�d|����|jj|�stdt|�z��|S)Nrr�r�zmodule %s not allowedzclass z, unjellied to something that isn't a class: zclass not allowed: %s)
rrr�r�rr�rrr�r)rdrI�cname�clistr�klausr�s       r!�_unjelly_classz_Unjellier._unjelly_class:s����T�!�W�%�����L��-�.���s�#�(�(��s���4���{�{�*�*�7�3�� 7�'� A�B�B��E�"���u�+���$����%�!��
��{�{�)�)�%�0�� 7�$�u�+� E�F�F��r#c��t|d�}|jtd��}td�j|dd�}|jj	|�std|z��t
|�}|S)Nrr�r�zModule not allowed: %s)rrr�r�rr�r)rdrI�fname�modSplitr�functions      r!�_unjelly_functionz_Unjellier._unjelly_functionKso���T�!�W�%���;�;�|�C�0�1���s�#�(�(��#�2��7���{�{�*�*�7�3�� 8�7� B�C�C��E�?���r#c�^�|jr|j|d|�}|Std�S)NrzPersistent callback not found)r�ra)rdrI�ploads   r!�_unjelly_persistentz_Unjellier._unjelly_persistentUs2������'�'��Q���6�E��L� �!@�A�Ar#c��tjdtdd��|j|d�}|j	||d�S)z�
        (internal) Unjelly an instance.

        Called to handle the deprecated I{instance} token.

        @param rest: The s-expression representing the instance.

        @return: The unjellied instance.
        ztUnjelly support for the instance atom is deprecated since Twisted 15.0.0.  Upgrade peer for modern instance support.�r)�category�filename�linenor[)�warnings�
warn_explicit�DeprecationWarningr\r)rdrIrs   r!�_unjelly_instancez_Unjellier._unjelly_instance\sL��	���
I�'���	
��l�l�4��7�#���#�#�C��a��1�1r#c�$�td|d���S)NzUnpersistable data: r)ra)rdrIs  r!�_unjelly_unpersistablez!_Unjellier._unjelly_unpersistableqs���3�D��G�9�=�>�>r#c�v�|d}|j|d�}|j|d�}t|t�std��||jvrY|�t||�}|St|t�rt|||�}|Stj|j||g|gdz���}|Std��)z.
        (internal) Unjelly a method.
        rr[r�z"Method found with non-class class.Fzinstance method changed)r\rrr�r(r-rr
r�r�rF)rdrI�im_name�im_self�im_class�ims      r!�_unjelly_methodz_Unjellier._unjelly_methodts����q�'���,�,�t�A�w�'���<�<��Q��(���(�D�)�� D�E�E��h�'�'�'����X�w�/���	��G�X�.�$�W�g�x�@���	��%�%��%�%�g�.���<D�:��;O���
�	��5�6�6r#N) rCrkrlrer�r�r\rrrrrrrr r"r'r+r/r6r8r<r?rArFrLrQrVrYrbrdrjror#r!r�r�ls������5�<N�"�$�7�!�<�8�8�Y����	��$�(5�;����"�B�2�*?�r#r�c��eZdZdZy)r�z�
    This exception will be raised when a jelly is deemed `insecure'; e.g. it
    contains a type, class, or module disallowed by the specified `taster'
    N)rCrkrlrmror#r!r�r��s��r#r�c�"�eZdZdZd�Zd�Zd�Zy)�DummySecurityOptionsz{
    DummySecurityOptions() -> insecure security options
    Dummy security options -- this class will allow anything.
    c��y)z�
        DummySecurityOptions.isModuleAllowed(moduleName) -> boolean
        returns 1 if a module by that name is allowed, 0 otherwise
        r[ro�rdrJs  r!rz$DummySecurityOptions.isModuleAllowed����
r#c��y)z�
        DummySecurityOptions.isClassAllowed(class) -> boolean
        Assumes the module has already been allowed.  Returns 1 if the given
        class is allowed, 0 otherwise.
        r[ro�rd�klasss  r!r�z#DummySecurityOptions.isClassAllowed�s��r#c��y)z�
        DummySecurityOptions.isTypeAllowed(typeName) -> boolean
        Returns 1 if the given type is allowed, 0 otherwise.
        r[ro�rd�typeNames  r!r�z"DummySecurityOptions.isTypeAllowed�rpr#N)rCrkrlrmrr�r�ror#r!rmrm�s���
��r#rmc�H�eZdZdZgd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zy)�SecurityOptionszF
    This will by default disallow everything, except for 'none'.
    )
�
dictionaryr�r��	reference�dereferencer�r��long_int�longr'c��idd�dd�dd�dd�dd�dd�dd�d	d�d
d�dd�dd�d
d�dd�dd�dd�dd�|_i|_i|_y)z/
        SecurityOptions() initialize.
        rr[sboolr�sstringsstrsintsfloatr�r�r�r�sNoneTyper�r�rrN)�allowedTypes�allowedModules�allowedClassesris r!rezSecurityOptions.__init__�s���
��Q�
��Q�
�
��
�
�q�	
�

�A�
�
�A�

�
�a�
�
��
�
�Q�
�
�Q�
�
�!�
�
��
�
��
�
��
�
�A�
� 
�!�!
���$!��� ��r#c�6�|j|j�y)zz
        Allow all `basic' types.  (Dictionary and list.  Int, string, and float
        are implicitly allowed.)
        N)r:�
basicTypesris r!�allowBasicTypeszSecurityOptions.allowBasicTypes�s��
	�������)r#c��|D]M}t|t�r|jd�}t|t�st	|�}d|j
|<�Oy)zg
        SecurityOptions.allowTypes(typeString): Allow a particular type, by its
        name.
        r1r[N)rrnr3r2rr)rdr��typs   r!r:zSecurityOptions.allowTypes�sN��
�	'�C��#�s�#��j�j��)���c�5�)��3�i��%&�D���c�"�	'r#c���|j�|jdddd�|D]F}|jt|��|j|j�d|j
|<�Hy)a
        SecurityOptions.allowInstances(klass, klass, ...): allow instances
        of the specified classes

        This will also allow the 'instance', 'class' (renamed 'classobj' in
        Python 2.3), and 'module' types, as well as basic types.
        r*�class�classobjrGr[N)r�r:r�allowModulesrkr�)rd�classesrss   r!�allowInstancesOfz SecurityOptions.allowInstancesOf�se��	
�������
�G�Z��B��	+�E��O�O�D��K�(����e�.�.�/�)*�D����&�	+r#c���|D]Z}t|�tjk(r|j}t	|t
�s|j
d�}d|j|<�\y)z�
        SecurityOptions.allowModules(module, module, ...): allow modules by
        name. This will also allow the 'module' type.
        r1r[N)rr�r�rCrr2r3r�)rd�modulesrGs   r!r�zSecurityOptions.allowModulessV��
�	,�F��F�|�u�/�/�/������f�e�,����w�/��*+�D����'�	,r#c�`�t|t�s|jd�}||jvS)z�
        SecurityOptions.isModuleAllowed(moduleName) -> boolean
        returns 1 if a module by that name is allowed, 0 otherwise
        r1)rr2r3r�ros  r!rzSecurityOptions.isModuleAlloweds/��
�*�e�,�#�*�*�7�3�J��T�0�0�0�0r#c��||jvS)z�
        SecurityOptions.isClassAllowed(class) -> boolean
        Assumes the module has already been allowed.  Returns 1 if the given
        class is allowed, 0 otherwise.
        )r�rrs  r!r�zSecurityOptions.isClassAlloweds����+�+�+�+r#c�l�t|t�s|jd�}||jvxsd|vS)z�
        SecurityOptions.isTypeAllowed(typeName) -> boolean
        Returns 1 if the given type is allowed, 0 otherwise.
        r1�.)rr2r3rrus  r!r�zSecurityOptions.isTypeAllowed!s7��
�(�E�*����w�/�H��4�,�,�,�@���0@�@r#N)
rCrkrlrmr�rer�r:r�r�rr�r�ror#r!rxrx�s7����J�!�6*�
'�
+�,�1�,�Ar#rxc�:�t|||�j|�S)z�
    Serialize to s-expression.

    Returns a list which is the serialized representation of an object.  An
    optional 'taster' argument takes a SecurityOptions and will mark any
    insecure objects as unpersistable rather than serializing them.
    )r~rT)r�r�r�r�s    r!rTrT0s���F�O�W�5�;�;�F�C�Cr#c�:�t|||�j|�S)aT
    Unserialize from s-expression.

    Takes a list that was the result from a call to jelly() and unserializes
    an arbitrary object from it.  The optional 'taster' argument, an instance
    of SecurityOptions, will cause an InsecureJelly exception to be raised if a
    disallowed type, module, or class attempted to unserialize.
    )r�r�)r�r�r�r�s    r!r\r\;s���f�n�g�6�B�B�4�H�Hr#r&)Ermr�r�r�r�r_�	functoolsr�zope.interfacer�incrementalr�twisted.persisted.crefutilrrrr	r
r�twisted.python.compatr�twisted.python.deprecater
�twisted.python.reflectrrr�twisted.spread.interfacesrrr'r��	None_atom�
class_atom�module_atom�
function_atomr�r�r�r�r�r�r�rr�r�r8r?r"r/r6r=rArMrYr_rarqrxr~r��	Exceptionr�rmrxr9r�rTr\ror#r!�<module>r�s���
8�t���
���&����/�>�>�>�>�
�G�	��	�
�
����
�"������ ���	����
��
�����I�r�1�a� �-���	�&������
 � �(	�)�2)�(&B�R
'�	�
7�
7� 
�Z��+�+��+�.
�\������(L�L�^\�\�D	�I����:wA�wA�t!�"����� �.�/��t�D�.�/��d�	Ir#

Zerion Mini Shell 1.0