#NEWLINE# @ receiver ( post_delete , sender = models . EntityOccurrence ) #NEWLINE# def on_eo_delete( sender , instance , **kwargs ) : #NEWLINE# #INDENT# segments_to_check = sender . _segments_to_check . get ( instance . id ) #NEWLINE# if segment : #NEWLINE# #INDENT# for segment in segments_to_check : #NEWLINE# #INDENT# eos = list ( segment . get_entity_occurrences ( ) ) #NEWLINE# if ( len ( eos ) < 2 ) : #NEWLINE# #INDENT# segment . delete ( )