2020-01-20 15:19:53 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2020-02-03 17:25:54 +00:00
|
|
|
from benedict.serializers.abstract import AbstractSerializer
|
2020-01-20 15:19:53 +00:00
|
|
|
from benedict.serializers.base64 import Base64Serializer
|
|
|
|
from benedict.serializers.csv import CSVSerializer
|
|
|
|
from benedict.serializers.json import JSONSerializer
|
|
|
|
from benedict.serializers.query_string import QueryStringSerializer
|
|
|
|
from benedict.serializers.toml import TOMLSerializer
|
|
|
|
from benedict.serializers.xml import XMLSerializer
|
|
|
|
from benedict.serializers.yaml import YAMLSerializer
|
|
|
|
|
|
|
|
|
|
|
|
_SERIALIZERS = {
|
2020-02-19 14:16:23 +00:00
|
|
|
'b64': Base64Serializer,
|
|
|
|
'base64': Base64Serializer,
|
|
|
|
'csv': CSVSerializer,
|
|
|
|
'json': JSONSerializer,
|
|
|
|
'qs': QueryStringSerializer,
|
|
|
|
'querystring': QueryStringSerializer,
|
|
|
|
'query-string': QueryStringSerializer,
|
|
|
|
'query_string': QueryStringSerializer,
|
|
|
|
'toml': TOMLSerializer,
|
|
|
|
'yaml': YAMLSerializer,
|
|
|
|
'yml': YAMLSerializer,
|
|
|
|
'xml': XMLSerializer,
|
2020-01-20 15:19:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_SERIALIZERS_EXTENSIONS = [
|
|
|
|
'.{}'.format(extension) for extension in _SERIALIZERS.keys()]
|
|
|
|
|
|
|
|
|
|
|
|
def get_serializer_by_format(format):
|
2020-02-19 14:17:28 +00:00
|
|
|
return _SERIALIZERS.get(format.lower().replace(' ', '_'))
|
2020-01-20 15:19:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
def get_serializers_extensions():
|
|
|
|
return list(_SERIALIZERS_EXTENSIONS)
|