def datetime_parser(dct): for k, v in dct.iteritems(): if isinstance(v, basestring): m = date_regex.findall(v) if len(m) > 0: dct[k] = parse(m[0], yearfirst=True) if '$humanTime' in dct: return parse_human_time(dct['$humanTime']) return bson_object_hook(dct)
def datetime_parser(dct): for k, v in dct.items(): if isinstance(v, str): m = date_regex.findall(v) if len(m) > 0: dct[k] = parse(m[0], yearfirst=True) if "$humanTime" in dct: return parse_human_time(dct["$humanTime"]) if "$oids" in dct: return parse_oids(dct["$oids"]) return bson_object_hook(dct)
def parse_oids(oids): if not isinstance(oids, list): raise Exception("$oids takes an array as input.") return [bson_object_hook({"$oid": oid}) for oid in oids]
def parse_oids(oids): if not isinstance(oids, list): raise Exception("$oids takes an array as input.") return [bson_object_hook({'$oid': oid}) for oid in oids]