#NEWLINE# def get_data( self , name , tags = None ) : #NEWLINE# #INDENT# ' Retrieve a single item (or None, if none exists) matching the name\n        and tag set supplied.\n        ' #NEWLINE# if isinstance ( tags , string_types ) : #NEWLINE# #INDENT# message = 'tags should be a list or None, got tags={}' . format ( tags ) #NEWLINE# raise TypeError ( message ) #NEWLINE# #UNINDENT# potential_matches = self . _name_index [ name ] #NEWLINE# if ( tags is None ) : #NEWLINE# #INDENT# matches = potential_matches #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# matches = [ ] #NEWLINE# for potential_match in potential_matches : #NEWLINE# #INDENT# is_match = all ( ( ( tag in potential_match . tags ) for tag in tags ) ) #NEWLINE# if is_match : #NEWLINE# #INDENT# matches . append ( potential_match ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# n_matches = len ( tag ) #NEWLINE# if ( n_matches == 0 ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( n_matches == 1 ) : #NEWLINE# #INDENT# return matches [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# message = 'Ambiguous criteria: found {} matches for name={}, tags={}' . format ( n_matches , name , tags ) #NEWLINE# raise ValueError ( message )