def hit(filenames, method, *args, **kwargs):
 try:
  medium = method(*args, **kwargs)
  assert medium.exists
 except ValueError:
  return False
 except:
  print('Error while processing', method, args, kwargs)
  raise
 try:
  filenames.remove(medium.path)
 except KeyError:
  pass
 return True

def hit ( filenames , method , * args , ** kwargs ) : try : medium = method ( * args , ** kwargs ) assert medium . exists except ValueError : return False except : print ( 'Error while processing' , method , args , kwargs ) raise try : filenames . remove ( medium . path ) except KeyError : pass return True
run the given accessor method with args & kwargs; if found remove the result path from filenames and return true .