#NEWLINE# def get_field_definition( field_definition ) : #NEWLINE# #INDENT# ' Normalizes a field definition into its component parts, even if some are missing. ' #NEWLINE# if ( not isinstance ( field_definition , ( tuple , list ) ) ) : #NEWLINE# #INDENT# field_definition = [ field_definition ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# field_definition = list ( field_definition ) #NEWLINE# #UNINDENT# if ( len ( field_definition ) == 1 ) : #NEWLINE# #INDENT# field = [ None , field_definition , None ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( field_definition ) == 2 ) : #NEWLINE# #INDENT# field = ( field_definition + [ None ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( field_definition ) == 3 ) : #NEWLINE# #INDENT# field = field_definition #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'Invalid field definition format.' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( not isinstance ( field [ 1 ] , ( tuple , list ) ) ) : #NEWLINE# #INDENT# field [ 1 ] = ( field [ 1 ] , ) #NEWLINE# #UNINDENT# field [ 1 ] = tuple ( ( name for name in field [ 1 ] if ( name is not None ) ) ) #NEWLINE# return FieldDefinitionTuple ( * field )