#NEWLINE# def _translate_diff( self , new , changed , deleted ) : #NEWLINE# #INDENT# '\n        Translates a list of new changed and deleted into\n        Add and remove instructions\n\n        :param new: list of new items\n        :param changed: list of tuples (from, to)\n        :param deleted: list of things to delete\n        :returns: a tuple with a list of items to remove and to add\n\n        **Example**::\n\n            new = [AggregatedActivity]\n            deleted = [AggregatedActivity]\n            changed = [(AggregatedActivity, AggregatedActivity)]\n            to_remove, to_delete = feed._translate_diff(new, changed, deleted)\n        ' #NEWLINE# error_format = 'please only send aggregated activities not %s' #NEWLINE# flat_changed = sum ( map ( list , changed ) , [ ] ) #NEWLINE# for aggregated_activity in itertools . chain ( new , flat_changed , deleted ) : #NEWLINE# #INDENT# if ( not isinstance ( aggregated_activity , AggregatedActivity ) ) : #NEWLINE# #INDENT# raise ValueError ( ( c % aggregated_activity ) ) #NEWLINE# #UNINDENT# #UNINDENT# to_remove = deleted [ : ] #NEWLINE# to_add = new [ : ] #NEWLINE# if changed : #NEWLINE# #INDENT# to_remove += [ c [ 0 ] for c in changed ] #NEWLINE# to_add += [ c [ 1 ] for c in changed ] #NEWLINE# #UNINDENT# return ( to_remove , to_add )