#NEWLINE# def _fold( header ) : #NEWLINE# #INDENT# 'Fold a header line into multiple crlf-separated lines at column 72.' #NEWLINE# i = header . rfind ( '\r\n ' ) #NEWLINE# if ( i == ( - 1 ) ) : #NEWLINE# #INDENT# pre = '' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# i += 3 #NEWLINE# pre = header [ : i ] #NEWLINE# header = header [ i : ] #NEWLINE# #UNINDENT# while ( len ( header ) > 72 ) : #NEWLINE# #INDENT# i = header [ : 72 ] . rfind ( ' ' ) #NEWLINE# if ( i == ( - 1 ) ) : #NEWLINE# #INDENT# i = j = 72 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# j = ( i + 1 ) #NEWLINE# #UNINDENT# pre += ( header [ : i ] + '\r\n ' ) #NEWLINE# header = header [ j : ] #NEWLINE# #UNINDENT# return ( pre + header )