Fix an error with photos hashes in the fetch command

This commit is contained in:
Lucas Verney 2018-10-15 08:48:36 +02:00
parent 35c902d3d3
commit dc9392e6f0

View File

@ -15,6 +15,7 @@ import math
import re import re
import time import time
import imagehash
import mapbox import mapbox
import requests import requests
import unidecode import unidecode
@ -128,7 +129,13 @@ class DateAwareJSONEncoder(json.JSONEncoder):
def default(self, o): # pylint: disable=locally-disabled,E0202 def default(self, o): # pylint: disable=locally-disabled,E0202
if isinstance(o, (datetime.date, datetime.datetime)): if isinstance(o, (datetime.date, datetime.datetime)):
return o.isoformat() return o.isoformat()
try:
return json.JSONEncoder.default(self, o) return json.JSONEncoder.default(self, o)
except TypeError:
# Discard image hashes
if isinstance(o, imagehash.ImageHash):
return None
raise
def pretty_json(data): def pretty_json(data):