#NEWLINE# def _get_metadata_model( name = None ) : #NEWLINE# #INDENT# if ( k is not None ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return registry [ name ] #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# if ( len ( registry ) == 1 ) : #NEWLINE# #INDENT# valid_names = ( 'Try using the name "%s" or simply leaving it out altogether.' % registry . keys ( ) [ 0 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# valid_names = ( 'Valid names are ' + ', ' . join ( ( ( '"%s"' % k ) for k in registry . keys ( ) ) ) ) #NEWLINE# #UNINDENT# raise Exception ( ( 'Metadata definition with name "%s" does not exist.\n%s' % ( name , valid_names ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# assert ( len ( registry ) == 1 ) , "You must have exactly one Metadata class, if using get_metadata() without a 'name' parameter." #NEWLINE# return registry . values ( ) [ 0 ]