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

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