MCPcopy
hub / github.com/google/clusterfuzz / default

Method default

src/appengine/handlers/base_handler.py:59–76  ·  view source on GitHub ↗
(self, o)

Source from the content-addressed store, hash-verified

57 _EPOCH = datetime.datetime.utcfromtimestamp(0)
58
59 def default(self, o): # pylint: disable=arguments-differ,method-hidden
60 if isinstance(o, ndb.Model):
61 dict_obj = o.to_dict()
62 dict_obj['id'] = o.key.id()
63 return dict_obj
64 if isinstance(o, datetime.datetime):
65 return int((o - self._EPOCH).total_seconds())
66 if hasattr(o, 'to_dict'):
67 return o.to_dict()
68 if isinstance(o, cgi.FieldStorage):
69 return str(o)
70 if isinstance(o, bytes):
71 return o.decode('utf-8')
72 if isinstance(o, jira.resources.Resource):
73 if o.raw:
74 return o.raw
75
76 return json.JSONEncoder.default(self, o)
77
78
79def format_time(dt):

Callers

nothing calls this directly

Calls 2

to_dictMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected