def findmatch(caps, MIMEtype, key='view', filename='/dev/null', plist=[]):
 entries = lookup(caps, MIMEtype, key)
 for e in entries:
  if ('test' in e):
   test = subst(e['test'], filename, plist)
   if (test and (os.system(test) != 0)):
    continue
  command = subst(e[key], MIMEtype, filename, plist)
  return (command, e)
 return (None, None)

def findmatch ( caps , MIMEtype , key = 'view' , filename = '/dev/null' , plist = [ ] ) : entries = lookup ( caps , MIMEtype , key ) for e in entries : if ( 'test' in e ) : test = subst ( e [ 'test' ] , filename , plist ) if ( test and ( os . system ( test ) != 0 ) ) : continue command = subst ( e [ key ] , MIMEtype , filename , plist ) return ( command , e ) return ( None , None )
find a match for a mailcap entry .