def make_path_searcher(path_generator, target_predicate, target_normalizer, extra_paths, **kwargs):
 def path_searcher(target, extra_dirs=extra_paths):
  matches = itertools.ifilter(target_predicate, path_generator(target, extra_dirs, **kwargs))
  paths = itertools.imap(target_normalizer, matches)
  return next(paths, '')
 return path_searcher

def make_path_searcher ( path_generator , target_predicate , target_normalizer , extra_paths , ** kwargs ) : def path_searcher ( target , extra_dirs = extra_paths ) : matches = itertools . ifilter ( target_predicate , path_generator ( target , extra_dirs , ** kwargs ) ) paths = itertools . imap ( target_normalizer , matches ) return next ( paths , '' ) return path_searcher
universal search function generator using lazy evaluation .