2020-01-20 15:19:53 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
from benedict.serializers.abstract import AbstractSerializer
|
|
|
|
|
|
|
|
import yaml
|
|
|
|
|
|
|
|
|
|
|
|
class YAMLSerializer(AbstractSerializer):
|
2022-02-13 10:56:44 +00:00
|
|
|
"""
|
|
|
|
This class describes an yaml serializer.
|
|
|
|
"""
|
|
|
|
|
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
|