python-benedict/benedict/serializers/yaml.py

23 lines
483 B
Python
Raw Normal View History

# -*- 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.
"""
def __init__(self):
super(YAMLSerializer, self).__init__()
def decode(self, s, **kwargs):
data = yaml.safe_load(s, **kwargs)
return data
def encode(self, d, **kwargs):
2020-12-22 11:49:23 +00:00
data = yaml.dump(dict(d.items()), **kwargs)
return data