#NEWLINE# def get_unique_tag_value( graph , target , tag ) : #NEWLINE# #INDENT# '\n    get a tag corresponding to a target, if it\'s clear the target "owns" the tag.\n    this makes sure, if you\'re looking at cpu graphs with group by server,\n    each cpu type (user, idle, etc) has a representative color\n    but if you group by type (and compare servers on one graph for e.g. \'idle\') you don\'t want\n    all targets to have the same color... except if due to filtering only 1 server shows up, we\n    can apply the color again.\n    note that if the graph has 6 targets: 3 different servers, each 2 different types, then this\n    will proceed and you\'ll see 3 targets of each color.\n    this could be extended to search for the value in the variables of all other targets, to guarantee\n    uniqueness (and avoid a color showing up multiple times)\n    TLDR: color a target based on tag value, but avoid all targets having the same color on 1 graph\n    ' #NEWLINE# if ( tag in target [ 'variables' ] ) : #NEWLINE# #INDENT# t = graph [ 'variables' ] [ tag ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( graph [ 'targets' ] ) == 1 ) : #NEWLINE# #INDENT# if ( tag in graph [ 'constants' ] ) : #NEWLINE# #INDENT# t = graph [ 'constants' ] [ tag ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( tag in graph [ 'promoted_constants' ] ) : #NEWLINE# #INDENT# t = graph [ 'promoted_constants' ] [ tag ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# #UNINDENT# if isinstance ( t , basestring ) : #NEWLINE# #INDENT# return t #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return t [ 0 ]