def _populate(self, json):
if not json:<EOL><INDENT>return<EOL><DEDENT>self._set('<STR_LIT>', json)<EOL>for key in json:<EOL><INDENT>if key in (k for k in type(self).properties.keys()<EOL>if not type(self).properties[k].identifier):<EOL><INDENT>if type(self).properties[key].relationshipand not json[key] is None:<EOL><INDENT>if isinstance(json[key], list):<EOL><INDENT>objs = []<EOL>for d in json[key]:<EOL><INDENT>if not '<STR_LIT:id>' in d:<EOL><INDENT>continue<EOL><DEDENT>new_class = type(self).properties[key].relationship<EOL>obj = new_class.make_instance(d['<STR_LIT:id>'],<EOL>getattr(self,'<STR_LIT>'))<EOL>if obj:<EOL><INDENT>obj._populate(d)<EOL><DEDENT>objs.append(obj)<EOL><DEDENT>self._set(key, objs)<EOL><DEDENT>else:<EOL><INDENT>if isinstance(json[key], dict):<EOL><INDENT>related_id = json[key]['<STR_LIT:id>']<EOL><DEDENT>else:<EOL><INDENT>related_id = json[key]<EOL><DEDENT>new_class = type(self).properties[key].relationship<EOL>obj = new_class.make_instance(related_id, getattr(self,'<STR_LIT>'))<EOL>if obj and isinstance(json[key], dict):<EOL><INDENT>obj._populate(json[key])<EOL><DEDENT>self._set(key, obj)<EOL><DEDENT><DEDENT>elif  type(self).properties[key].slug_relationshipand not json[key] is None:<EOL><INDENT>self._set(key, type(self).properties[key].slug_relationship(self._client, json[key]))<EOL><DEDENT>elif type(json[key]) is dict:<EOL><INDENT>self._set(key, MappedObject(**json[key]))<EOL><DEDENT>elif type(json[key]) is list:<EOL><INDENT>mapping = MappedObject(_list=json[key])<EOL>self._set(key, mapping._list) <EOL><DEDENT>elif type(self).properties[key].is_datetime:<EOL><INDENT>try:<EOL><INDENT>t = time.strptime(json[key], DATE_FORMAT)<EOL>self._set(key, datetime.fromtimestamp(time.mktime(t)))<EOL><DEDENT>except:<EOL><INDENT>self._set(key, json[key])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self._set(key, json[key])<EOL><DEDENT><DEDENT><DEDENT>self._set('<STR_LIT>', True)<EOL>self._set('<STR_LIT>', datetime.now())<EOL>
A helper method that, given a JSON object representing this object,
assigns values based on the properties dict and the attributes of
its Properties.