Skip to content

Commit

Permalink
Simplify CMRESSerializer code (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin Schubert authored and cmanaha committed Oct 8, 2017
1 parent 0b8bbee commit 2514dda
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions cmreslogging/serializers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
""" JSON serializer for Elasticsearch use
"""
from datetime import date, datetime
from decimal import Decimal

from elasticsearch.serializer import JSONSerializer


Expand All @@ -19,11 +16,7 @@ def default(self, data):
:params data: The data to serialize before sending it to elastic search
"""
result = None
if isinstance(data, (date, datetime)):
result = data.isoformat()
elif isinstance(data, Decimal):
result = float(data)
else:
result = str(data)
return result
try:
return super(CMRESSerializer, self).default(data)
except TypeError:
return str(data)

0 comments on commit 2514dda

Please sign in to comment.