python-benedict/benedict/serializers/yaml.py

21 lines
461 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
2020-01-20 16:03:59 +00:00
from __future__ import absolute_import
from benedict.serializers.abstract import AbstractSerializer
import yaml
class YAMLSerializer(AbstractSerializer):
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