#NEWLINE# def _FindConstantMetadataKeys( self , samples ) : #NEWLINE# #INDENT# "Finds metadata keys which are constant across a collection of samples.\n\n    Args:\n      samples: List of dicts, as passed to SamplePublisher.PublishSamples.\n\n    Returns:\n      The set of metadata keys for which all samples in 'samples' have the same\n      value.\n    " #NEWLINE# unique_values = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for sample in samples : #NEWLINE# #INDENT# for ( k , v ) in sample [ 'metadata' ] . iteritems ( ) : #NEWLINE# #INDENT# if ( len ( unique_values . setdefault ( k , set ( ) ) ) < 2 ) : #NEWLINE# #INDENT# unique_values [ k ] . add ( v ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# for sample in samples : #NEWLINE# #INDENT# for k in ( frozenset ( unique_values ) - frozenset ( sample [ 'metadata' ] ) ) : #NEWLINE# #INDENT# unique_values [ k ] . add ( None ) #NEWLINE# #UNINDENT# #UNINDENT# return frozenset ( ( k for ( k , v ) in unique_values . iteritems ( ) if ( len ( v ) == 1 ) ) )