#NEWLINE# def group_targets_by_color( targets , compat_cls ) : #NEWLINE# #INDENT# targets_by_color = defaultdict ( list ) #NEWLINE# for target in targets : #NEWLINE# #INDENT# color_def = target . get_colordef ( ) #NEWLINE# if ( ( color_def == UNCOLORED_MARKER ) or isinstance ( targets , compat_cls ) ) : #NEWLINE# #INDENT# targets_by_color [ color_def . color_id ] . append ( target ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise InvalidColorError ( ( 'Incompatible color definition %s' % color_def ) ) #NEWLINE# #UNINDENT# #UNINDENT# return targets_by_color