load folder path, return all files endswith yml/yaml/json in list.

    Args:
        folder_path (str): specified folder path to load
        recursive (bool): load files recursively if True

    Returns:
        list: files endswith yml/yaml/json
509529
def load_folder_files(folder_path, recursive=True):
    
    if isinstance(folder_path, (list, set)):
        files = []
        for path in set(folder_path):
            files.extend(load_folder_files(path, recursive))

        return files

    if not os.path.exists(folder_path):
        return []

    file_list = []

    for dirpath, dirnames, filenames in os.walk(folder_path):
        filenames_list = []

        for filename in filenames:
            if not filename.endswith(('.yml', '.yaml', '.json')):
                continue

            filenames_list.append(filename)

        for filename in filenames_list:
            file_path = os.path.join(dirpath, filename)
            file_list.append(file_path)

        if not recursive:
            break

    return file_list
947253
def full_file_list(scan_path):
    
    file_list = []
    path = os.path.abspath(scan_path)
    for root, dirs, files in os.walk(path):
        if len(files) != 0 and not '.svn' in root and not '.git' in root:
            for f in files:
                file_list.append(os.path.join(root, f))
    return file_list
557047
def _load_paths(self, paths, depth=0):
        '''
        
        '''

        if depth > self.MAX_DEPTH:
            return

        for path in paths:
            try:
                # avoid empty string
                if not path:
                    continue

                # cleanUp path
                if depth == 0:
                    path = os.path.expanduser(path)  # replace ~
                    path = os.path.expandvars(path)  # replace vars
                    path = os.path.normpath(path)  # replace /../ , "" will be converted to "."

                if not os.path.exists(path):
                    raise PresetException("does not exists or is a broken link or not enough permissions to read")
                elif os.path.isdir(path):
                    try:
                        for child in os.listdir(path):
                            self._load_paths([os.path.join(path, child)], depth + 1)
                    except OSError as e:
                        raise PresetException("IOError: " + e.strerror)
                elif os.path.isfile(path):
                    if path.endswith(".json"):
                        self._load_preset(path)
                else:
                    raise PresetException("not regular file")
            except PresetException as e:
                e.message = "Failed to load preset: \"{}\" [ {} ]".format(path, e.message)
                if self.strict:
                    raise
                logger.error(str(e))
893730
def parent_folder(path, base=None):
    
    return path and os.path.dirname(resolved_path(path, base=base))
599257
def loader(path):
    
    finder = ModuleFinder if _isdir(path) else FileFinder
    return Loader(finder(path))
1277104
def rm_files(path, extension):
    
    files = list_files(extension, path)
    for file in files:
        if file.endswith(extension):
            os.remove(os.path.join(path, file))
    return
1302815
def load_directory(self, dir_path):
        
        self._log.info('Loading all AgentML files contained in: ' + dir_path)

        # Get a list of file paths
        aml_files = []
        for root, dirs, files in os.walk(dir_path):
            aml_files += ['{root}/{file}'.format(root=root, file=file)
                          for file in sorted(files) if file.endswith('.aml')]

        # Loop through the files and load each one individually
        for file in aml_files:
            self.load_file(file)
1140452
def list(self, list_folders=False, list_files=False):
        

        a_files = os.listdir(self.folder.path)
        for a_file in a_files:
            path = self.folder.child(a_file)
            if os.path.isdir(path):
                if list_folders:
                    yield Folder(path)
            elif list_files:
                if not self.pattern or fnmatch.fnmatch(a_file, self.pattern):
                    yield File(path)
473997
def from_folder(cls, path:PathOrStr, extensions:Collection[str]=None, recurse:bool=True,
                    include:Optional[Collection[str]]=None, processor:PreProcessors=None, **kwargs)->'ItemList':
        """"""
        path = Path(path)
        return cls(get_files(path, extensions, recurse=recurse, include=include), path=path, processor=processor, **kwargs)
894374
function recursiveReaddirSync(path) {
  var list = []
    , files = fs.readdirSync(path)
    , stats
    ;

  files.forEach(function (file) {
    stats = fs.lstatSync(p.join(path, file));
    if(stats.isDirectory()) {
      list = list.concat(recursiveReaddirSync(p.join(path, file)));
    } else {
      list.push(p.join(path, file));
    }
  });

  return list;
}
939893
def listdir(self, path='.'):
        
        self._connect()

        if self.sftp:
            contents = self._sftp_listdir(path)
        else:
            contents = self._ftp_listdir(path)

        self._close()

        return contents
1032513
def load_parameter_file(file_path, name = ''):
    
    if not os.path.exists(file_path):
        raise ValueError("{} doest not exist".format(file_path))
    if os.path.isdir(file_path):
        return ParameterNode(name, directory_path = file_path)
    data = _load_yaml_file(file_path)
    return _parse_child(name, data, file_path)
1062866
def _recurse(self, path):
        '''
        
        '''
        files = {}
        empty_dirs = []
        try:
            sub_paths = os.listdir(path)
        except OSError as exc:
            if exc.errno == errno.ENOENT:
                # Path does not exist
                sys.stderr.write('{0} does not exist\n'.format(path))
                sys.exit(42)
            elif exc.errno in (errno.EINVAL, errno.ENOTDIR):
                # Path is a file (EINVAL on Windows, ENOTDIR otherwise)
                files[path] = self._mode(path)
        else:
            if not sub_paths:
                empty_dirs.append(path)
            for fn_ in sub_paths:
                files_, empty_dirs_ = self._recurse(os.path.join(path, fn_))
                files.update(files_)
                empty_dirs.extend(empty_dirs_)

        return files, empty_dirs
190095
def ls_recurse(path, include_hidden=False):
    
    lst = []
    for file in os.listdir(path):
        hidden_file = FileSystem(file).is_hidden()
        if (hidden_file and include_hidden) or (not hidden_file):
            lst.append(os.path.join(path, file))
            if is_folder(os.path.join(path, file)):
                lst += ls_recurse(
                    os.path.join(path, file),
                    include_hidden=include_hidden
                )  # get list of files in directory
    return list(set(lst))
832286
def _complete_path(path=None):
    
    if not path:
        return _listdir('.')
    dirname, rest = os.path.split(path)
    tmp = dirname if dirname else '.'
    res = [p for p in _listdir(tmp) if p.startswith(rest)]
    # more than one match, or single match which does not exist (typo)
    if len(res) > 1 or not os.path.exists(path):
        return res
    # resolved to a single directory, so return list of files below it
    if os.path.isdir(path):
        return [p for p in _listdir(path)]
    # exact file match terminates this completion
    return [path + ' ']
399756
def __load_paths(self, base_path=None):
        
        if base_path is None:
            base_path = dirname(dirname(dirname(__file__)))
        if not base_path.endswith(sep):
            base_path += sep
        self.__paths = {
            'base': base_path,
            'cert': base_path + 'certs' + sep,
            'lib': base_path + 'lib' + sep,
            'extlib': base_path + 'extlib' + sep,
        }
13359
def list_files_in_directory(full_directory_path):
    
    files = list()
    for file_name in __os.listdir(full_directory_path):
        if __os.path.isfile(__os.path.join(full_directory_path, file_name)):
            files.append(file_name)
    return files