search for hwpack dir under root.
333987
def find_hwpack_dir(root):
    """"""
    root = path(root)
    log.debug('files in dir: %s', root)
    for x in root.walkfiles():
        log.debug('  %s', x)

    hwpack_dir = None
    for h in (root.walkfiles('boards.txt')):
        assert not hwpack_dir
        hwpack_dir = h.parent
        log.debug('found hwpack: %s', hwpack_dir)

    assert hwpack_dir
    return hwpack_dir
773758
def find_vcs_root(path, dirs=(".git",)):
    """"""
    prev, path = None, os.path.abspath(path)
    while prev != path:
        if any(os.path.exists(os.path.join(path, d)) for d in dirs):
            return path
        prev, path = path, os.path.abspath(os.path.join(path, os.pardir))
    return None
576879
def _get_dir_list(load):
    '''
    
    '''
    if 'env' in load:
        # "env" is not supported; Use "saltenv".
        load.pop('env')

    if 'saltenv' not in load or load['saltenv'] not in envs():
        return []
    ret = set()
    for repo in init():
        repo['repo'].open()
        ref = _get_ref(repo, load['saltenv'])
        if ref:
            manifest = repo['repo'].manifest(rev=ref[1])
            for tup in manifest:
                filepath = tup[4]
                split = filepath.rsplit('/', 1)
                while len(split) > 1:
                    relpath = os.path.relpath(split[0], repo['root'])
                    # Don't add '.'
                    if relpath != '.':
                        # Don't add files outside the hgfs_root
                        if not relpath.startswith('../'):
                            ret.add(os.path.join(repo['mountpoint'], relpath))
                    split = split[0].rsplit('/', 1)
        repo['repo'].close()
    if repo['mountpoint']:
        ret.add(repo['mountpoint'])
    return sorted(ret)
23084
def find_packages(path: str) -> List[str]:
    
    for root, _dir, files in os.walk(path):
        if '__init__.py' in files:
            yield root.replace("/", ".")
709640
def groot(path=''):
    ""

    def check_filelist(l):
        if ('README.md' in l) or ('README' in l):
            return True
        else:
            return False

    import os, copy
    cwd = os.getcwd()  # initial dir
    cwd0 = copy.copy(cwd)
    cwd_init = copy.copy(cwd)

    found = False
    sysroot = False

    while not found and not sysroot:
        found = check_filelist(os.listdir())
        if not found:
            os.chdir(os.path.join(cwd, os.pardir))
            cwd = os.getcwd()
            if cwd == cwd0:
                sysroot = True
            else:
                cwd0 = cwd
        else:
            os.chdir(os.path.join(cwd0, path))

    if sysroot:
        os.chdir(cwd_init)
        raise Exception("Root directory not found.")
429356
def get_subpackages(name):
    """"""
    splist = []
    for dirpath, _dirnames, _filenames in os.walk(name):
        if osp.isfile(osp.join(dirpath, '__init__.py')):
            splist.append(".".join(dirpath.split(os.sep)))
    return splist
464609
def dir_path(dir):
    """"""
    old_dir = os.getcwd()
    os.chdir(dir)
    yield
    os.chdir(old_dir)
1143192
def find_root
      Pathname.pwd.ascend do |root|
        config_dir = root.join(Project::CONFIG_DIR)

        if config_dir.directory?
          config_file = config_dir.join(Project::CONFIG_FILE)
          return root if config_file.file?

          environments_dir = config_dir.join(Project::ENVIRONMENTS_DIR)
          return root if environments_dir.directory?
        end
      end

      shell.say "Could not find '#{Project::CONFIG_FILE}' in any parent directories", :red
      exit -1
    end
1110712
def get_root_path():
    """"""
    root_path = __file__
    return os.path.dirname(os.path.realpath(root_path))
1091772
function findAllNodeModules(startDir) {
	let dir = path.resolve(startDir);
	let dirs = [];
	const { root } = path.parse(startDir);

	// eslint-disable-next-line no-constant-condition
	while (true) {
		const joined = path.join(dir, 'node_modules');
		if (existsSync(joined)) {
			dirs.push(joined);
		}
		if (dir === root) {
			return dirs;
		}
		dir = path.dirname(dir);
	}
}
1257738
def find_clean_dirs(self):
        """"""

        for folder in glob.glob(self.glob_pattern):
            if re.match(self.re_pattern, folder):
                yield folder
        for folder in glob.glob(self.orig_glob_pattern):
            if re.match(self.orig_re_pattern, folder):
                yield folder
1308851
function findProjectRoot(startPath) {
    log.trace("findProjectRoot startPath = %s", startPath);
    if(isDiskRoot()) {
      if(hasPackageJson()) {
        return startPath;
      } else {
        throw new Error("Cannot find project root");
      }
    } else if(hasPackageJson()) {
      return startPath;
    } else {
      return findProjectRoot(PATH.resolve(startPath+PATH.sep+".."));
    }

    function hasPackageJson() {
      return fs.existsSync(startPath+PATH.sep+"package.json");
    }

    function isDiskRoot() {
      return startPath.match(/^([A-Z]:\\\\|\/)$/);
    }
  }
1093398
def find_repo_root_by_path(path):
    """"""
    repo = git.Repo(path, search_parent_directories=True)
    repo_path = repo.git.rev_parse('--show-toplevel')
    logging.info('Repository: {}'.format(repo_path))
    return repo_path
960705
def base_dir(self):
        """"""
        if self.root_dir:
            return op.join(self.root_dir, self.id)
        else:
            return None
329712
def _find_packages_iter(cls, where, exclude, include):
        
        for root, dirs, files in os.walk(where, followlinks=True):
            # Copy dirs to iterate over it, then empty dirs.
            all_dirs = dirs[:]
            dirs[:] = []

            for dir in all_dirs:
                full_path = os.path.join(root, dir)
                rel_path = os.path.relpath(full_path, where)
                package = rel_path.replace(os.path.sep, '.')

                # Skip directory trees that are not valid packages
                if ('.' in dir or not cls._looks_like_package(full_path)):
                    continue

                # Should this package be included?
                if include(package) and not exclude(package):
                    yield package

                # Keep searching subdirectories, as there may be more packages
                # down there, even if the parent was excluded.
                dirs.append(dir)
305928
def _find_package(parts):
    """"""
    for i in range(len(parts), 0, -1):
        prefix = '.'.join(parts[0:i])
        if prefix in sys.modules:
            return i, sys.modules[prefix]
    return 0, None
213419
def search_project_root():
        

        while True:

            current = os.getcwd()

            if pathlib.Path("Miragefile.py").is_file() or pathlib.Path("Miragefile").is_file():
                return current
            elif os.getcwd() == "/":
                raise FileNotFoundError
            else:
                os.chdir("../")