python-benedict/benedict/serializers/toml.py

27 lines
544 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
import toml
from benedict.serializers.abstract import AbstractSerializer
class TOMLSerializer(AbstractSerializer):
2022-02-13 10:56:44 +00:00
"""
This class describes a toml serializer.
"""
def __init__(self):
super(TOMLSerializer, self).__init__(
extensions=[
"toml",
],
)
def decode(self, s, **kwargs):
data = toml.loads(s, **kwargs)
return data
def encode(self, d, **kwargs):
data = toml.dumps(dict(d), **kwargs)
return data