#NEWLINE# def normalize_width( width , err ) : #NEWLINE# #INDENT# "\n    Split width into (width_type, width_amount).  Raise exception err\n    if width doesn't match a valid alignment.\n    " #NEWLINE# if ( width in ( CLIP , PACK ) ) : #NEWLINE# #INDENT# return ( width , None ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( type ( width ) == int ) : #NEWLINE# #INDENT# return ( GIVEN , width ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( type ( width ) == tuple ) and ( len ( width ) == 2 ) and ( width [ 0 ] == RELATIVE ) ) : #NEWLINE# #INDENT# return width #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# raise err ( ( "width value %r is not one of fixed number of columns, 'pack', ('relative', percentage of total width), 'clip'" % ( width , ) ) )