2020-01-20 15:19:53 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2020-01-20 16:03:59 +00:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2020-01-20 15:19:53 +00:00
|
|
|
from benedict.serializers.abstract import AbstractSerializer
|
|
|
|
|
|
|
|
import yaml
|
|
|
|
|
|
|
|
|
|
|
|
class YAMLSerializer(AbstractSerializer):
|
2020-02-20 16:14:48 +00:00
|
|
|
def __init__(self):
|
|
|
|
super(YAMLSerializer, self).__init__()
|
|
|
|
|
|
|
|
def decode(self, s, **kwargs):
|
2020-01-20 15:19:53 +00:00
|
|
|
data = yaml.safe_load(s, **kwargs)
|
|
|
|
return data
|
|
|
|
|
2020-02-20 16:14:48 +00:00
|
|
|
def encode(self, d, **kwargs):
|
2020-12-22 11:49:23 +00:00
|
|
|
data = yaml.dump(dict(d.items()), **kwargs)
|
2020-01-20 15:19:53 +00:00
|
|
|
return data
|