Searches up from a directory looking for a file
325043
def find_file(name, directory):
    """"""
    path_bits = directory.split(os.sep)
    for i in range(0, len(path_bits) - 1):
        check_path = path_bits[0:len(path_bits) - i]
        check_file = "%s%s%s" % (os.sep.join(check_path), os.sep, name)
        if os.path.exists(check_file):
            return abspath(check_file)

    return None
175236
def _find_path(self, search_dirs, file_name):
        
        for dir_path in search_dirs:
            file_path = os.path.join(dir_path, file_name)
            if os.path.exists(file_path):
                return file_path

        return None
216546
def find(pattern, path='.', exclude=None, recursive=True):
    """"""
    import fnmatch
    import os

    if recursive:
        for root, dirnames, filenames in os.walk(path):
            for pat in _to_list(pattern):
                for filename in fnmatch.filter(filenames, pat):
                    filepath = join(abspath(root), filename)
                    for excl in _to_list(exclude):
                        if excl and fnmatch.fnmatch(filepath, excl):
                            break
                    else:
                        yield filepath
    else:
        for pat in _to_list(pattern):
            for filename in fnmatch.filter(list(path), pat):
                filepath = join(abspath(path), filename)
                for excl in _to_list(exclude):
                    if excl and fnmatch.fnmatch(filepath, excl):
                        break
                    else:
                        yield filepath
1294870
def select_directory(self):
        """"""
        self.__redirect_stdio_emit(False)
        directory = getexistingdirectory(
                self, _(""), self.path)
        if directory:
            directory = to_unicode_from_fs(osp.abspath(directory))
        self.__redirect_stdio_emit(True)
        return directory
729666
def get_files (dirname):
    """"""
    for entry in os.listdir(dirname):
        fullentry = os.path.join(dirname, entry)
        if os.path.islink(fullentry):
            continue
        if os.path.isfile(fullentry):
            yield entry
        elif os.path.isdir(fullentry):
            yield entry+"/"
999830
def finddirs(pattern, path='.', exclude=None, recursive=True):
    """"""
    import fnmatch
    import os
    if recursive:
        for root, dirnames, filenames in os.walk(path):
            for pat in _to_list(pattern):
                for dirname in fnmatch.filter(dirnames, pat):
                    dirpath = join(abspath(root), dirname)
                    for excl in _to_list(exclude):
                        if excl and fnmatch.fnmatch(dirpath, excl):
                            break
                    else:
                        yield dirpath
    else:
        for pat in _to_list(pattern):
            for dirname in fnmatch.filter(listdirs(path), pat):
                dirpath = join(abspath(path), dirname)
                for excl in _to_list(exclude):
                    if excl and fnmatch.fnmatch(dirpath, excl):
                        break
                else:
                    yield dirpath
1083566
def find(name):
    """"""

    if op.exists(name):
        return name

    path = op.dirname(__file__) or '.'

    paths = [path] + config['include_path']

    for path in paths:
        filename = op.abspath(op.join(path, name))
        if op.exists(filename):
            return filename

        for d in os.listdir(path):
            fullpath = op.abspath(op.join(path, d))
            if op.isdir(fullpath):
                filename = op.abspath(op.join(fullpath, name))
                if op.exists(filename):
                    return filename

    return None
314813
function tryFile(directories, filename) {
	return firstResult(directories, dir => {
		const filepath = path.resolve(dir, filename);
		return fs.existsSync(filepath) ? filepath : undefined;
	});
}
798442
def grep(rootdir, searched):
    ""
    to_inspect = []
    for root, dirs, files in os.walk(rootdir):
        for _file in files:
            if _file.endswith('.rst'):
                to_inspect.append(join(root, _file))

    to_check = ((_file, open(_file, 'r').read()) for _file in to_inspect)
    to_check = filter(lambda item: searched in item[1], to_check)
    to_check = map(lambda item: item[0], to_check)
    return to_check
1220882
def _search_for_files(parts):
    
    file_parts = []
    for part in parts:
        if isinstance(part, list):
            file_parts.extend(_search_for_files(part))
        elif isinstance(part, FileToken):
            file_parts.append(part)
    return file_parts
1156379
def find_files(self, root):
        

        def is_ignored(path, ignore_patterns):
            """
            Check if the given path should be ignored or not.
            """
            filename = os.path.basename(path)
            ignore = lambda pattern: fnmatch.fnmatchcase(filename, pattern)
            return any(ignore(pattern) for pattern in ignore_patterns)

        dir_suffix = '%s*' % os.sep
        normalized_patterns = [
            p[:-len(dir_suffix)] if p.endswith(dir_suffix) else p
            for p in self.ignore_patterns
        ]

        all_files = []
        walker = os.walk(root, topdown=True, followlinks=self.follow_symlinks)
        for dir_path, dir_names, file_names in walker:
            for dir_name in dir_names[:]:
                path = os.path.normpath(os.path.join(dir_path, dir_name))
                if is_ignored(path, normalized_patterns):
                    dir_names.remove(dir_name)
                    if self.verbose:
                        print_out("Ignoring directory '{:}'".format(dir_name))
            for file_name in file_names:
                path = os.path.normpath(os.path.join(dir_path, file_name))
                if is_ignored(path, self.ignore_patterns):
                    if self.verbose:
                        print_out("Ignoring file '{:}' in '{:}'".format(
                                  file_name, dir_path))
                else:
                    all_files.append((dir_path, file_name))
        return sorted(all_files)
35582
def find_files(root, pattern):
    
    results = []
    for base, dirs, files in os.walk(root):
        matched = fnmatch.filter(files, pattern)
        results.extend(os.path.join(base, f) for f in matched)
    return results
1226015
function findDirRec(dir, callback) {
      var result = path.resolve(dir, dirmod);
      fs.stat(result, function stat(err, stat) {
        if (err || !stat.isDirectory()) {
          if (lastResult == result) {
            callback(new Error('No configuration directory found.'));
            return;
          }
          lastResult = result;
          findDirRec(path.resolve(dir, '..'), callback);
        } else {
          callback(null, result);
        }
      });
    }
973464
def _find_files(directory):
    
    pattern = "{directory}/*.xml".format(
        directory=directory,
    )
    files = glob(pattern)
    return files
1116124
function find(test, cwd, callback, one) {
  var results = []
  var current

  test = augment(test)

  if (!callback) {
    callback = cwd
    cwd = null
  }

  current = cwd ? resolve(cwd) : process.cwd()

  once()

  // Test a file and check what should be done with the resulting file.
  function handle(filePath) {
    var file = toVFile(filePath)
    var result = test(file)

    if (mask(result, INCLUDE)) {
      if (one) {
        callback(null, file)
        return true
      }

      results.push(file)
    }

    if (mask(result, BREAK)) {
      callback(null, one ? null : results)
      return true
    }
  }

  // Check one directory.
  function once(child) {
    if (handle(current) === true) {
      return
    }

    readdir(current, onread)

    function onread(error, entries) {
      var length = entries ? entries.length : 0
      var index = -1
      var entry

      if (error) {
        entries = []
      }

      while (++index < length) {
        entry = entries[index]

        if (entry !== child && handle(resolve(current, entry)) === true) {
          return
        }
      }

      child = current
      current = dirname(current)

      if (current === child) {
        callback(null, one ? null : results)
        return
      }

      once(basename(child))
    }
  }
}
1145395
function (search) {
            var result = false;

            files.forEach(function (elem) {
                if (elem.path === search) {
                    result = true;
                }
            });
            
            return result;
        }
740971
def _find_file(filename):
    
    import os
    if os.path.exists(filename):
        path = filename
    else:
        path = os.path.dirname(__file__)
        path = os.path.join(path, 'data', filename)

    if not os.path.exists(path):
        raise ValueError("cannot locate file '%s'" %filename)

    return path