#NEWLINE# def remove_target( self , target ) : #NEWLINE# #INDENT# '\n        Remove the specified target from the current criterion.\n        We assume that the criterion has a AND [] construction, and\n        furthermore that the target lies within the top-level AND.\n\n        @param criterion: TargetingCriterion\n        @param target: TargetingCriterion\n\n        @return: TargetingCriterion|None\n        ' #NEWLINE# assert isinstance ( target , TargetingCriterion ) #NEWLINE# if ( self == target ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# ( op1 , targets1 ) = self . get_data ( ) #NEWLINE# ( op2 , targets2 ) = target . get_data ( ) #NEWLINE# if ( not ( op1 == self . OPERATOR . AND ) ) : #NEWLINE# #INDENT# raise ParselmouthException ( 'TargetingCriterion has wrong structure. Top-level operator not an AND.' ) #NEWLINE# #UNINDENT# if ( ( not ( len ( targets2 ) == 1 ) ) or isinstance ( targets2 [ 0 ] , TargetingCriterion ) ) : #NEWLINE# #INDENT# raise ParselmouthException ( 'Target should be a simple TargetingCriterion with a single ObjectModel.' ) #NEWLINE# #UNINDENT# target_object_model = targets2 [ 0 ] #NEWLINE# target_index = None #NEWLINE# if ( target_object_model in targets1 ) : #NEWLINE# #INDENT# target_index = targets1 . index ( target_object_model ) #NEWLINE# #UNINDENT# if ( target in targets1 ) : #NEWLINE# #INDENT# target_index = targets1 . index ( target ) #NEWLINE# #UNINDENT# if ( target_index is None ) : #NEWLINE# #INDENT# raise ParselmouthException ( 'Target not found in top-level structure.' ) #NEWLINE# #UNINDENT# targets1 = deepcopy ( targets1 ) #NEWLINE# targets1 . pop ( target_index ) #NEWLINE# if ( ( len ( targets1 ) == 1 ) and isinstance ( targets1 [ 0 ] , TargetingCriterion ) ) : #NEWLINE# #INDENT# return targets1 [ 0 ] #NEWLINE# #UNINDENT# if ( len ( targets1 ) == 1 ) : #NEWLINE# #INDENT# op1 = self . OPERATOR . OR #NEWLINE# #UNINDENT# return TargetingCriterion ( targets1 , op1 )