def from_dict(d): """Transform the dict to a person object and return the person.""" query_params_match = d.get('@query_params_match') sources = [Source.from_dict(source) for source in d.get('sources', [])] fields = Person.fields_from_dict(d) return Person(fields=fields, sources=sources, query_params_match=query_params_match)
def __init__(self, fields=None, source=None, query_params_match=None, query_person_match=None, valid_since=None): """Extend FieldsContainer.__init__ and set the record's source and attributes. Args: fields -- An iterable of fields (from osrframework.thirdparties.pipl_com.lib.fields). source -- A Source object (osrframework.thirdparties.pipl_com.lib.source.Source). query_params_match -- A bool value that indicates whether the record contains all the params from the query or not. query_person_match -- A float between 0.0 and 1.0 that indicates how likely it is that this record holds data about the person from the query. Higher value means higher likelihood, value of 1.0 means "this is definitely him". This value is based on Pipl's statistical algorithm that takes into account many parameters like the popularity of the name/address (if there was a name/address in the query) etc. valid_since -- A datetime.datetime object, this is the first time Pipl's crawlers saw this record. """ FieldsContainer.__init__(self, fields) self.source = source or Source() self.query_params_match = query_params_match self.query_person_match = query_person_match self.valid_since = valid_since
def from_dict(d): """Transform the dict to a record object and return the record.""" query_params_match = d.get('@query_params_match') query_person_match = d.get('@query_person_match') valid_since = d.get('@valid_since') if valid_since: valid_since = str_to_datetime(valid_since) source = Source.from_dict(d.get('source', {})) fields = Record.fields_from_dict(d) return Record(source=source, fields=fields, query_params_match=query_params_match, query_person_match=query_person_match, valid_since=valid_since)