2020-02-19 17:14:23 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
from __future__ import absolute_import
|
|
|
|
|
|
|
|
from benedict.serializers.abstract import AbstractSerializer
|
|
|
|
|
|
|
|
import pickle
|
|
|
|
|
|
|
|
|
|
|
|
class PickleSerializer(AbstractSerializer):
|
|
|
|
|
2020-02-20 16:14:48 +00:00
|
|
|
def __init__(self):
|
|
|
|
super(PickleSerializer, self).__init__()
|
|
|
|
|
|
|
|
def decode(self, b, **kwargs):
|
2020-02-19 17:14:23 +00:00
|
|
|
data = pickle.loads(b, **kwargs)
|
|
|
|
return data
|
|
|
|
|
2020-02-20 16:14:48 +00:00
|
|
|
def encode(self, d, **kwargs):
|
2020-02-19 17:14:23 +00:00
|
|
|
data = pickle.dumps(d, **kwargs)
|
|
|
|
return data
|