add per list export_json

This commit is contained in:
j 2016-01-15 13:29:35 +05:30
commit b961086475
4 changed files with 31 additions and 12 deletions

View file

@ -383,3 +383,11 @@ def can_connect_dns(host="8.8.8.8", port=53):
except:
pass
return False
def _to_json(python_object):
if isinstance(python_object, datetime):
if python_object.year < 1900:
tt = python_object.timetuple()
return '%d-%02d-%02dT%02d:%02d%02dZ' % tuple(list(tt)[:6])
return python_object.strftime('%Y-%m-%dT%H:%M:%SZ')
raise TypeError(u'%s %s is not JSON serializable' % (repr(python_object), type(python_object)))