#NEWLINE# def _return_class( self , ent_dict , child = None , child_id = None , entity_id = None , collection = None ) : #NEWLINE# #INDENT# 'Generate item for new class instantiation' #NEWLINE# ent_type = ent_dict . get ( '_type' , ent_dict . get ( 'type' ) ) #NEWLINE# relations = ent_dict . get ( 'relations' ) #NEWLINE# if ( child is not None ) : #NEWLINE# #INDENT# if ( child_id is not None ) : #NEWLINE# #INDENT# ent_dict [ 'id' ] = child_id #NEWLINE# #UNINDENT# ent_dict [ 'parent_id' ] = entity_id #NEWLINE# ent_dict [ 'parent' ] = collection #NEWLINE# #UNINDENT# if ( relations is not None ) : #NEWLINE# #INDENT# for ( rel_name , data ) in six . iteritems ( relations ) : #NEWLINE# #INDENT# if isinstance ( data , list ) : #NEWLINE# #INDENT# ent_dict [ rel_name ] = [ ] #NEWLINE# for cls in data : #NEWLINE# #INDENT# ent_dict [ rel_name ] . append ( self . _return_class ( cls ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# ent_dict [ rel_name ] = self . _return_class ( data ) #NEWLINE# #UNINDENT# #UNINDENT# ent_dict . pop ( 'relations' , None ) #NEWLINE# #UNINDENT# return self . new ( ent_type , properties = ent_dict )