def MapObject(object_map, obj): oid = obj['object_id'] obj['id'] = oid del obj['object_id'] if oid in object_map: object_ = object_map[oid] else: if 'attributes' in obj: attrs = obj['attributes'] del obj['attributes'] else: attrs = [] if 'w' in obj: obj['width'] = obj['w'] obj['height'] = obj['h'] del obj['w'], obj['h'] object_ = Object(**obj) object_.attributes = attrs object_map[oid] = object_ return object_map, object_
def MapObject(object_map, obj): """ Use object ids as hashes to `src.models.Object` instances. If item not in table, create new `Object`. Used when building scene graphs from json. """ oid = obj['object_id'] obj['id'] = oid del obj['object_id'] if oid in object_map: object_ = object_map[oid] else: if 'attributes' in obj: attrs = obj['attributes'] del obj['attributes'] else: attrs = [] if 'w' in obj: obj['width'] = obj['w'] obj['height'] = obj['h'] del obj['w'], obj['h'] object_ = Object(**obj) object_.attributes = attrs object_map[oid] = object_ return object_map, object_