Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/twisted/spread/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/twisted/spread/__pycache__/jelly.cpython-310.pyc
o

�bY��@sdZddlZddlZddlZddlZddlZddlmZddlm	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/dd�Z0d d!�Z1d"d#�Z2d$d%�Z3d&d'�Z4dBd(d)�Z5d*d+�Z6d,d-�Z7Gd.d/�d/�Z8e	e�Gd0d1�d1��Z9e	e�Gd2d3�d3��Z:Gd4d5�d5�Z;Gd6d7�d7�Z<Gd8d9�d9e=�Z>Gd:d;�d;�Z?Gd<d=�d=�Z@e@�ZAeA�B�e?�ddfd>d?�ZCe?�ddfd@dA�ZDdS)CaM
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
unpersistablecCst|t�r
|�|�SdS)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__)�cls�r�6/usr/lib/python3/dist-packages/twisted/spread/jelly.py�_createBlank�s

�r!cs,t|���fdd�}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}.
    cs
|�_dS�N��__dict__)�state��instancerr �
defaultSetter��
z#_newInstance.<locals>.defaultSetter�__setstate__)r!�getattr)rr%r(�setterrr&r �_newInstance�s
	r-cCs.t|t�}|rt|�}t|t�s|�d�}|S)N�utf-8)rrr�bytes�encode)�
classnamep�isObjectrrr �_maybeClass�s


r3cC�t|�}|t|<t�|�dS)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)r3�unjellyableRegistry�globalSecurity�
allowTypes)�	classname�unjellyablerrr �setUnjellyableForClass�sr:cCr4)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)r3�unjellyableFactoryRegistryr6r7)r8�copyFactoryrrr �setUnjellyableFactoryForClass�sr=c	Csn|dur|j}|r
d|}t|�D]#}t||�}zt||�}Wn	ty(Yqw|r4t|�|��|�qdS)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+�
issubclass�	TypeErrorr:)�module�	baseClass�prefix�name�loaded�yesrrr �setUnjellyableForClassTree�s
���rHcCsPt|d�r
|��}n|j}|�|�}|�t|j��d�|�|�g�|�	||�S)zM
    Utility method to default to 'normal' state rules in serialization.
    �__getstate__r.)
�hasattrrIr$�prepare�extendr�	__class__r0�jelly�preserve)�inst�jellierr%�sxprrr �getInstanceStates


 rScCs0|�|d�}t|d�r|�|�|S||_|S)zO
    Utility method to default to 'normal' state rules in unserialization.
    �r*)�unjellyrJr*r$)rP�	unjellier�	jellyListr%rrr �setInstanceStates

�rXc@s&eZdZdZdd�Zdefdd�ZdS)�
Unpersistablezd
    This is an instance of a class that comes back when something couldn't be
    unpersisted.
    cCs
||_dS)zY
        Initialize an unpersistable object with a descriptive C{reason} string.
        N)�reason)�selfrZrrr �__init__%s
zUnpersistable.__init__�returncCsdt|j�S)NzUnpersistable(%s))�reprrZ�r[rrr �__repr__+�zUnpersistable.__repr__N)r>�
__module__�__qualname__�__doc__r\�strr`rrrr rYsrYc@� eZdZdZdd�Zdd�ZdS)�	Jellyablezc
    Inherit from me to Jelly yourself directly with the `getStateFor'
    convenience method.
    cCs|jSr"r#)r[rQrrr �getStateFor6szJellyable.getStateForcCs<|�|�}|�t|j��d�|�|�|��g�|�||�S)zH
        @see: L{twisted.spread.interfaces.IJellyable.jellyFor}
        r.)rKrLrrMr0rNrhrO)r[rQrRrrr �jellyFor9s
��zJellyable.jellyForN)r>rbrcrdrhrirrrr rg/�rgc@rf)�Unjellyablezf
    Inherit from me to Unjelly yourself directly with the
    C{setStateFor} convenience method.
    cCs
||_dSr"r#)r[rVr%rrr �setStateForNr)zUnjellyable.setStateForcCs|�|d�}|�||�|S)z�
        Perform the inverse operation of L{Jellyable.jellyFor}.

        @see: L{twisted.spread.interfaces.IUnjellyable.unjellyFor}
        rT)rUrl)r[rVrWr%rrr �
unjellyForQszUnjellyable.unjellyForN)r>rbrcrdrlrmrrrr rkGrjrkc@sZeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zddd�ZdS)�_JellierzC
    (Internal) This class manages state for a call to jelly()
    cCs.||_i|_i|_i|_d|_||_||_dS)z
        Initialize.
        rTN)�taster�	preserved�cooked�cooker�_ref_id�persistentStore�invoker)r[rortrurrr r\as
z_Jellier.__init__cCsR|jt|�}t�|�}|j}|jd|_t||g|dd�<t|g|jt|�<|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
        rTN)rp�id�copyrs�reference_atom�dereference_atomrq)r[�object�aList�newList�refidrrr �_cookps
z_Jellier._cookcCs 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]].
        )rprvrr)r[rzrrr rK�sz_Jellier.preparecCsDt|�|jvr||jt|�d<|jt|�}|S||jt|�<|S)zQ
        (internal) Mark an object's persistent list for later referral.
        �)rvrqrp)r[rz�sexprrr rO�s�z_Jellier.preservecCs>t|�}||jvr|j|S||jvr|�|�|j|SdSr")rvrqrpr~)r[�obj�objIdrrr �
_checkMutable�s




�z_Jellier._checkMutablec
Cs�t|t�r|�|�}|r|S|�|�St|�}|j�t|��d���r�|t	t
tfvr,|St|tj
�rH|j}|j}|j}d|j|�|�|�|�gS|turSd|�d�gSt|td��r]dgSt|tj�rmd|jd|jgSt|tj�rxd|jgS|tur�d	|r�d
p�dgS|tjur�|jr�td��d
d�dd�|j|j|j|j |j!|j"|j#fD���d�gS|tj$ur�|jr�td��dd�dd�|j |j!|j"|j#fD���d�gS|tj%ur�dd�dd�|j|j|jfD���d�gS|tj&u�rdd�dd�|j'|j(|j)fD���d�gSt*|t��rdt|��d�gS|t+j,u�r|�-|�S|�|�}|�r)|S|�.|�}|t/u�r=|�0|�1t2|��n�|t3u�rL|�0|�1t4|��n�|t5v�rn|�6t7�|�8�D]\}}	|�6|�|�|�|	�g��qZnq|t9u�r}|�0|�1t:|��nb|t;u�r�|�0|�1t<|��nSt|j��d�}
d}|j=�r�|�=||�}|du�r�|�6t>�|�6|�n/|j�?|j��r�|�6|
�t@|d��r�|�A�}n|jB}|�6|�|��n|�Cdt|j�|�|�D||�StEd|�d|����)Nr.smethod�unicode�UTF-8rr�.r�boolean�true�falsez2Currently can't jelly datetime objects with tzinfo�datetime� cS�g|]}t|��qSr�re��.0�xrrr �
<listcomp>����z"_Jellier.jelly.<locals>.<listcomp>�timecSr�rr�r�rrr r��r��datecSr�rr�r�rrr r���	timedeltacSr�rr�r�rrr r�
r�rrIz$instance of class %s deemed insecurezType not allowed for object: )Frrgr�rirro�
isTypeAllowedrr0r/�int�float�types�
MethodType�__self__�__func__rMr>rNre�FunctionTyperbrc�
ModuleType�bool�datetime�tzinfo�NotImplementedError�join�year�month�day�hour�minute�second�microsecond�time�date�	timedelta�days�seconds�microsecondsr@�decimal�Decimal�
jelly_decimalrK�listrL�_jellyIterable�	list_atom�tuple�
tuple_atom�	DictTypes�append�dictionary_atom�items�set�set_atom�	frozenset�frozenset_atomrt�persistent_atom�isClassAllowedrJrIr$�
unpersistablerO�
InsecureJelly)
r[r��preRef�objType�aSelf�aFunc�aClassrR�key�val�	className�
persistentr%rrr rN�s�


�

����
�
����
	 ����






�





��z_Jellier.jellyccs"�|V|D]}|�|�VqdS)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)rN)r[�atomr��itemrrr r�<s
�
�z_Jellier._jellyIterablecCs0|��\}}}tdd�|�}|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}
        cSs|d|S)N�
r)�left�rightrrr �<lambda>Xsz(_Jellier.jelly_decimal.<locals>.<lambda>�decimal)�as_tupler)r[�d�sign�guts�exponent�valuerrr r�Ms


z_Jellier.jelly_decimalNcCs8|durg}|�t�t|t�r|�d�}|�|�|S)z�
        (internal) Returns an sexp: (unpersistable "reason").  Utility method
        for making note that a particular object could not be serialized.
        Nr.)r��unpersistable_atomrrer0)r[rZrRrrr r�]s



z_Jellier.unpersistabler")
r>rbrcrdr\r~rKrOr�rNr�r�r�rrrr rn\srnc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;S)<�
_UnjelliercCs"||_||_i|_g|_||_dSr")ro�persistentLoad�
references�
postCallbacksru)r[ror�rurrr r\ls

z_Unjellier.__init__cCs |�|�}|jD]}|�q|Sr")rUr�)r[r��o�mrrr �unjellyFullss

z_Unjellier.unjellyFullcCst|d�r|j�|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)rJr�r�r�)r[�	unjelliedrrr �_maybePostUnjellyys
	z_Unjellier._maybePostUnjellycCs&t|�tur|S|d}|j�|�st|��t�|�}|dur/tt|�d|�}|�	|||��St
�|�}|durD|�	||�|d���St|�}t|d|d�}|dur\||dd��S|�
d�}d�|dd��}	|j�|	�s{td|	�d|�d	���t|�}
|j�|
�s�td
|��|�|
|d�S)NrrmrTz_unjelly_%sr����zModule z not allowed (in type z).zClass %s not allowed.)rr�ror�r�r5�getr+r!r�r;rUr�splitr��isModuleAllowedrr��_genericUnjelly)r[r��jelTypeBytes�regClass�method�
regFactory�jelTypeText�thunk�	nameSplit�modName�clzrrr rU�s4


�z_Unjellier.unjellycCs|�t||�|���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-rU)r[rr%rrr r��sz_Unjellier._genericUnjellycCsdSr"r�r[�exprrr �
_unjelly_None�sz_Unjellier._unjelly_NonecCst|dd�S)Nrr�r�r�rrr �_unjelly_unicode�raz_Unjellier._unjelly_unicodecCsD|d}|d}|dkrd}nd}t�|���d}t�|||f�S)z*
        Unjelly decimal objects.
        rrT)r�r�r�)r[r�r�r�r�r�rrr �_unjelly_decimal�sz_Unjellier._unjelly_decimalcCs|ddvsJ�|ddkS)Nr)r�r�r�rr�rrr �_unjelly_boolean�sz_Unjellier._unjelly_booleancCstjtt|d����S�Nr)r��mapr�r�r�rrr �_unjelly_datetime��z_Unjellier._unjelly_datetimecC�tjtt|d����Sr�)r�r�r�r�r�r�rrr �
_unjelly_date�r�z_Unjellier._unjelly_datecCr�r�)r�r�r�r�r�r�rrr �
_unjelly_time�r�z_Unjellier._unjelly_timecCs(tt|d���\}}}tj|||d�S)Nr)r�r�r�)r�r�r�r�r�)r[r�r�r�r�rrr �_unjelly_timedelta�sz_Unjellier._unjelly_timedeltacCs,|�|�}t|t�r|�||�|||<|Sr")rUrr�addDependant)r[r��loc�jelr�rrr �unjellyInto�s


z_Unjellier.unjellyIntocCs6|d}|j�|�}|dur|St|�}||j|<|Sr�)r�r�r)r[�lstr}r��derrrr �_unjelly_dereference�s
z_Unjellier._unjelly_dereferencecCsf|d}|d}|�|�}|j�|�}|dur||j|<|St|t�r/|�|�||j|<|SJd��)NrrTz!Multiple references with same ID!)rUr�r�rr�resolveDependants)r[rr}r�r��refrrr �_unjelly_reference�s


�

�z_Unjellier._unjelly_referencecCsNttt|���}d}|D]}t|�||||�t�rd}q|r#t|�St|�S)NrTr)r��range�lenrrrr�r
)r[r�l�finished�elemrrr �_unjelly_tuple�s�z_Unjellier._unjelly_tuplecCs0ttt|���}|D]}|�||||�q
|Sr")r�r
rr)r[rrrrrr �
_unjelly_listsz_Unjellier._unjelly_listcCsTttt|���}d}|D]}|�||||�}t|t�rd}q|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�r
rrrrr)r[r�
containerTyperrr�datarrr �_unjellySetOrFrozensets	
�
z!_Unjellier._unjellySetOrFrozensetcC�|�|t�S)z7
        Unjelly set using the C{set} builtin.
        )rr��r[rrrr �_unjelly_set�z_Unjellier._unjelly_setcCr)zC
        Unjelly frozenset using the C{frozenset} builtin.
        )rr�rrrr �_unjelly_frozenset"rz_Unjellier._unjelly_frozensetcCs:i}|D]\}}t|�}|�|d|�|�|d|�q|S)NrrT)rr)r[rr��k�v�kvdrrr �_unjelly_dictionary(sz_Unjellier._unjelly_dictionarycCsLt|d�}t|�tkrtd��|j�|�std|����t|iid�}|S)Nrz5Attempted to unjelly a module with a non-string name.z"Attempted to unjelly module named r�)rrrer�ror��
__import__)r[�rest�
moduleName�modrrr �_unjelly_module0sz_Unjellier._unjelly_modulecCs�t|d�}|�td��}td��|dd��}|j�|�s$td|��t|�}t|�}|tur8td||f��|j�|�sFtdt	|���|S)Nrr�r�zmodule %s not allowedz6class %r unjellied to something that isn't a class: %rzclass not allowed: %s)
rr�r�ror�r�rrr�r)r[r!�cname�clistr��klausr�rrr �_unjelly_class9s ��z_Unjellier._unjelly_classcCsTt|d�}|�td��}td��|dd��}|j�|�s$td|��t|�}|S)Nrr�r�zModule not allowed: %s)rr�r�ror�r�r
)r[r!�fname�modSplitr��functionrrr �_unjelly_functionJsz_Unjellier._unjelly_functioncCs"|jr
|�|d|�}|Std�S)NrzPersistent callback not found)r�rY)r[r!�ploadrrr �_unjelly_persistentTsz_Unjellier._unjelly_persistentcCs0tjdtddd�|�|d�}|�||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�linenorT)�warnings�
warn_explicit�DeprecationWarningrUr�)r[r!r�rrr �_unjelly_instance[s
�z_Unjellier._unjelly_instancecCstd|d���S)NzUnpersistable data: r)rY)r[r!rrr �_unjelly_unpersistablepsz!_Unjellier._unjelly_unpersistablecCs�|d}|�|d�}|�|d�}t|t�std��||jvrJ|dur+t||�}|St|t�r8t|||�}|Stj	|j||g|gd�R�}|St
d��)z.
        (internal) Unjelly a method.
        rrTrz"Method found with non-class class.NFzinstance method changed)rUrrr�r$r+rr	r�r�rA)r[r!�im_name�im_self�im_class�imrrr �_unjelly_methodss&


	
��
���z_Unjellier._unjelly_methodN) r>rbrcr\r�r�rUr�r�r�r�r�r�rrrrr	rrrrrrrr$r(r,r.r6r7r<rrrr r�ks<

		
r�c@seZdZdZdS)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)r>rbrcrdrrrr r��sr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�DummySecurityOptionsz{
    DummySecurityOptions() -> insecure security options
    Dummy security options -- this class will allow anything.
    cC�dS)z�
        DummySecurityOptions.isModuleAllowed(moduleName) -> boolean
        returns 1 if a module by that name is allowed, 0 otherwise
        rTr�r[r"rrr r���z$DummySecurityOptions.isModuleAllowedcCr>)z�
        DummySecurityOptions.isClassAllowed(class) -> boolean
        Assumes the module has already been allowed.  Returns 1 if the given
        class is allowed, 0 otherwise.
        rTr�r[�klassrrr r��sz#DummySecurityOptions.isClassAllowedcCr>)z�
        DummySecurityOptions.isTypeAllowed(typeName) -> boolean
        Returns 1 if the given type is allowed, 0 otherwise.
        rTr�r[�typeNamerrr r��r@z"DummySecurityOptions.isTypeAllowedN)r>rbrcrdr�r�r�rrrr r=�s
r=c@sXeZdZdZgd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)�SecurityOptionszF
    This will by default disallow everything, except for 'none'.
    )
�
dictionaryr�r��	reference�dereferencer�r��long_int�long�dictcCsvidd�dd�dd�dd�dd�dd�dd�d	d�d
d�dd�dd�d
d�dd�dd�dd�dd�|_i|_i|_dS)z/
        SecurityOptions() initialize.
        rrTsboolr�sstringsstrsintsfloatr�r�r�r�sNoneTyper�r�rrN)�allowedTypes�allowedModules�allowedClassesr_rrr r\�sF��������	�
���
����
zSecurityOptions.__init__cCs|j|j�dS)zz
        Allow all `basic' types.  (Dictionary and list.  Int, string, and float
        are implicitly allowed.)
        N)r7�
basicTypesr_rrr �allowBasicTypes�szSecurityOptions.allowBasicTypescGs>|D]}t|t�r|�d�}t|t�st|�}d|j|<qdS)zg
        SecurityOptions.allowTypes(typeString): Allow a particular type, by its
        name.
        r.rTN)rrer0r/rrL)r[r��typrrr r7�s


�zSecurityOptions.allowTypescGsJ|��|�dddd�|D]}|�t|��|�|j�d|j|<qdS)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�classobjrBrTN)rPr7r�allowModulesrbrN)r[�classesrBrrr �allowInstancesOf�s�z SecurityOptions.allowInstancesOfcGs@|D]}t|�tjkr|j}t|t�s|�d�}d|j|<qdS)z�
        SecurityOptions.allowModules(module, module, ...): allow modules by
        name. This will also allow the 'module' type.
        r.rTN)rr�r�r>rr/r0rM)r[�modulesrBrrr rTs

�zSecurityOptions.allowModulescCst|t�s
|�d�}||jvS)z�
        SecurityOptions.isModuleAllowed(moduleName) -> boolean
        returns 1 if a module by that name is allowed, 0 otherwise
        r.)rr/r0rMr?rrr r�s


zSecurityOptions.isModuleAllowedcCs
||jvS)z�
        SecurityOptions.isClassAllowed(class) -> boolean
        Assumes the module has already been allowed.  Returns 1 if the given
        class is allowed, 0 otherwise.
        )rNrArrr r�s
zSecurityOptions.isClassAllowedcCs&t|t�s
|�d�}||jvpd|vS)z�
        SecurityOptions.isTypeAllowed(typeName) -> boolean
        Returns 1 if the given type is allowed, 0 otherwise.
        r.�.)rr/r0rLrCrrr r� s

zSecurityOptions.isTypeAllowedN)
r>rbrcrdrOr\rPr7rVrTr�r�r�rrrr rE�s

rEcC�t|||��|�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.
    )rnrN)rzrortrurrr rN/srNcCrY)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�ror�rurrr rU:s	rUr")Erdrwr�r�r�r3�	functoolsr�zope.interfacer�incrementalr�twisted.persisted.crefutilrrrrr	r
�twisted.python.compatr�twisted.python.deprecater�twisted.python.reflectr
rr�twisted.spread.interfacesrrrKr��	None_atom�
class_atom�module_atom�
function_atomryr�rxr�r�r�r�rr�r�r5r;r!r-r3r:r=rHrSrXrYrgrkrnr��	Exceptionr�r=rEr6rPrNrUrrrr �<module>s~: 
�
)
$z

Spamworldpro Mini