예제 #1
0
파일: unpickler.py 프로젝트: jakesyl/cing
 def _restore_set(self, obj):
     return set([self._restore(v) for v in obj[tags.SET]])
예제 #2
0
파일: tags.py 프로젝트: jakesyl/cing
STATE = 'py/state'
TUPLE = 'py/tuple'
TYPE = 'py/type'
# GWV
# INFO = 'py/info'  # key used for info to be part of unpickler context
# VERSION = 'py/version'  # key used to store version information; added to unpickler context
# REVISION = 'py/revision'  # key used to store version information; added to unpickler context
ITEMS = 'py/items'  # key to store items of AnyDictHandler
VALUES = 'py/values'  # key to store values of AnyListHandler

# All reserved tag names
RESERVED = set([
    FUNCTION,
    ID,
    INITARGS,
    ITERATOR,
    NEWARGS,
    NEWOBJ,
    OBJECT,
    REDUCE,
    REF,
    REPR,
    SEQ,
    SET,
    STATE,
    TUPLE,
    TYPE,
    ITEMS,
    VALUES
])
예제 #3
0
파일: util.py 프로젝트: jakesyl/cing
import io
import operator
import time
import types

from cing.Libs.jsonTools import tags
from cing.Libs.jsonTools.compat import set
from cing.Libs.jsonTools.compat import unicode
from cing.Libs.jsonTools.compat import long
from cing.Libs.jsonTools.compat import PY3

if not PY3:
    import __builtin__

SEQUENCES = (list, set, tuple)
SEQUENCES_SET = set(SEQUENCES)
PRIMITIVES = set((str, unicode, bool, float, int, long))


def is_type(obj):
    """Returns True is obj is a reference to a type.

    >>> is_type(1)
    False

    >>> is_type(object)
    True

    >>> class Klass: pass
    >>> is_type(Klass)
    True