← Back
Editing: jelly.cpython-38.pyc
U W[t� � @ s� d Z ddlZddlZddlZddlmZ ddlZddlZzddlmZ m Z W n ek rh dZ dZY nX e gZegZe�� �R ejded� zddlZW n ek r� dZY nX e�ej� e�ej� W 5 Q R X ddlmZ dd lmZmZmZ dd lm Z m!Z!m"Z" ddl#m$Z$m%Z%m&Z& ddl#m'Z'm(Z( dd l#m)Z) ddl*m+Z+m,Z, ddlm-Z- ddl.m/Z/ ddl0m1Z1 e2fZ3dZ4dZ5dZ6dZ7dZ8dZ9dZ:dZ;dZ<dZ=dZ>dZ?dZ@e/e1dd dd�d!d"d#� d$ZAi aBi aCd%d&� ZDd'd(� ZEd)d*� ZFd+d,� ZGd-d.� ZHdId/d0�ZId1d2� ZJd3d4� ZKG d5d6� d6�ZLee+�G d7d8� d8��ZMee,�G d9d:� d:��ZNG d;d<� d<�ZOG d=d>� d>�ZPG d?d@� d@eQ�ZRG dAdB� dB�ZSG dCdD� dD�ZTeT� ZUeU�V� eS� ddfdEdF�ZWeS� ddfdGdH�ZXdS )Ja� 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 C{set} builtin and the C{sets.Set} class are serialized to the same thing, and unserialized to C{set} if available, else to C{sets.Set}. It means that there's a possibility of type switching in the serialization process. The solution is to always use C{set}. The same rule applies for C{frozenset} and C{sets.ImmutableSet}. @author: Glyph Lefkowitz � N)�reduce)� ClassType�InstanceType� �ignore)�category)�implementer)�unicode�long�nativeString)�namedObject�qual�namedAny)�NotKnown�_Tuple�_InstanceMethod)�_DictKeyAndValue�_Dereference)� _Container)� IJellyable�IUnjellyable)�_PY3)�deprecatedModuleAttribute)�Version� None� class� module� functions dereferences persistents references dictionarys list� sets tuples instance� frozensetZTwisted� z'instance_atom is unused within Twisted.ztwisted.spread.jelly� instance_atoms unpersistablec C s. t | t�r| �| �S ts*t | t�r*t| �S dS )a� Given an object, if that object is a type (or a legacy old-style class), 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 C{None}. @param cls: The type (or class) to create an instance of. @type cls: L{_OldStyleClass}, 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__r �_OldStyleClass�_OldStyleInstance)�clsr r �6/usr/lib/python3/dist-packages/twisted/spread/jelly.py�_createBlank� s r) c s, t | �� � fdd�}t� d|�}||� � S )a Make a new instance of a class without calling its __init__ method. Supports both new- and old-style classes. @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 s | � _ d S �N��__dict__)�state��instancer r( � defaultSetter� s z#_newInstance.<locals>.defaultSetter�__setstate__)r) �getattr)r'