def MimeReplaceFilename(header, filename):
 start = header.find('filename=')
 start = header.find('"', start)
 end = (header.find('"', (start + 1)) + 1)
 if ((start > 0) and (end > start)):
  headernew = ((header[:(start + 1)] + filename) + header[(end - 1):])
 else:
  headernew = header[:]
 return headernew

def MimeReplaceFilename ( header , filename ) : start = header . find ( 'filename=' ) start = header . find ( '"' , start ) end = ( header . find ( '"' , ( start + 1 ) ) + 1 ) if ( ( start > 0 ) and ( end > start ) ) : headernew = ( ( header [ : ( start + 1 ) ] + filename ) + header [ ( end - 1 ) : ] ) else : headernew = header [ : ] return headernew
accepts a mime header containing filename=" .