#NEWLINE# def header_elements( fieldname , fieldvalue ) : #NEWLINE# #INDENT# 'Return a sorted HeaderElement list from a comma-separated header string.' #NEWLINE# if ( not fieldvalue ) : #NEWLINE# #INDENT# return [ ] #NEWLINE# #UNINDENT# result = [ ] #NEWLINE# for element in fieldvalue . split ( ',' ) : #NEWLINE# #INDENT# if ( fieldname . startswith ( 'Accept' ) or ( fieldname == 'TE' ) ) : #NEWLINE# #INDENT# hv = AcceptElement . from_str ( element ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# hv = HeaderElement . from_str ( element ) #NEWLINE# #UNINDENT# result . append ( hv ) #NEWLINE# #UNINDENT# return list ( reversed ( sorted ( result ) ) )