If notebook_or_folder is a folder, returns a list containing all notebooks
    in the folder. Otherwise, returns a list containing the notebook name.

    If recursive is True, recurses into subdirectories.
548954
def expand_folder(notebook_or_folder, recursive=False):
    
    is_file = os.path.isfile(notebook_or_folder)
    is_dir = os.path.isdir(notebook_or_folder)
    if not (is_file or is_dir):
        raise ValueError(
            '{} is neither an existing file nor a folder.'
            .format(notebook_or_folder)
        )

    if is_file:
        return [notebook_or_folder]

    # Now we know the input is a directory
    if not recursive:
        return glob('{}/*.ipynb'.format(notebook_or_folder))

    # Recursive case
    return [
        os.path.join(folder, filename)
        for folder, _, filenames in os.walk(notebook_or_folder)
        # Skip folders that start with .
        if not os.path.basename(folder).startswith('.')
        for filename in fnmatch.filter(filenames, '*.ipynb')
    ]
117917
private boolean folderContainsFiles(File folder) {
        if (folder != null) {
            File[] files = folder.listFiles();
            for (File file : files)
                if (file.isFile())
                    return true;
            for (File file : files)
                if (file.isDirectory())
                    if (folderContainsFiles(file))
                        return true;
        }
        return false;
    }
1296375
def is_inside_any(dir_list, fname):
    """"""
    for dirname in dir_list:
        if is_inside(dirname, fname):
            return True
    return False
1300305
def read_dirs(path, folder):
    '''
     
    '''
    lbls, fnames, all_lbls = [], [], []
    full_path = os.path.join(path, folder)
    for lbl in sorted(os.listdir(full_path)):
        if lbl not in ('.ipynb_checkpoints','.DS_Store'):
            all_lbls.append(lbl)
            for fname in os.listdir(os.path.join(full_path, lbl)):
                if fname not in ('.DS_Store'):
                    fnames.append(os.path.join(folder, lbl, fname))
                    lbls.append(lbl)
    return fnames, lbls, all_lbls
422268
def add_folder(self, folder):
        
        if folder in self.folders:
            return

        self.folders.add(folder)
        
        for subfolder, junk, filenames in os.walk(folder):
            for filename in filenames:
                name, ext = os.path.splitext(filename)
                if ext in self.exts:
                    self.images.append(
                        os.path.join(subfolder, filename))
1035646
def check_notebooks_for_errors(notebooks_directory):
    '''  '''
    print("Checking notebooks in directory {} for errors".format(notebooks_directory))

    failed_notebooks_count = 0
    for file in os.listdir(notebooks_directory):
        if file.endswith(".ipynb"):
            print("Checking notebook " + file)
            full_file_path = os.path.join(notebooks_directory, file)
            output, errors = run_notebook(full_file_path)
            if errors is not None and len(errors) > 0:
                failed_notebooks_count += 1
                print("Errors in notebook " + file)
                print(errors)

    if failed_notebooks_count == 0:
        print("No errors found in notebooks under " + notebooks_directory)
824697
def get_file_list(path, max_depth=1, cur_depth=0):
    
    if os.path.exists(path):
        for name in os.listdir(path):
            if name.startswith('.'):
                continue
            
            full_path = os.path.join(path, name)
            if os.path.isdir(full_path):
                if cur_depth == max_depth:
                    continue
                
                file_list = get_file_list(full_path, max_depth, cur_depth + 1)
                for result in file_list:
                    yield result
            else:
                yield full_path
390095
def _iter_full_paths(path_list):
    
    for path in path_list:
        if not os.path.isdir(path):
            full_path = os.path.realpath(path)
            yield path
        else:
            for root, dirs, filenames in os.walk(path):
                for filename in filenames:
                    full_path = os.path.realpath(os.path.join(root, filename))
                    yield full_path
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)
782644
def listFiles(self):
        
        def fn(dirName, level, files):
            if level == self.levelNo-1:
                for fileName in os.listdir(dirName):
                    if fileName != "lock":
                        absFileName = os.path.join(dirName, fileName)
                        files.append(absFileName)
            else:
                for subDir in os.listdir(dirName):
                    if subDir != "lock":
                        absDirName = os.path.join(dirName, subDir)
                        assert os.path.isdir(absDirName)
                        fn(absDirName, level+1, files)
        files = []
        fn(self.rootDir, 0, files)
        return files
730212
def get_page_names(self):
        ''''''
        fis = [p  for p in glob.glob(os.path.join(self._dirs['source'], \
                                     "*")) if os.path.isdir(p)]
        fis = [os.path.split(p)[1] for p in fis ]
        return fis
284003
def _file_list(self, folder):
        ''''''
        rtn = []
        walk = self._walk_report(folder)
        for key,val in walk.items():
            for v in val:
                x=os.path.join(key,v)
                rtn.append(x)

        self.file_count = len(rtn)  #a count of the files we'll have in the final cleaned sosreport, for reporting
        return rtn
721278
def all(self, paths, access=None, recursion=False):
        
        self.__init__()
        self.access = access
        self.filetype = 'all'
        self.paths = paths
        self.recursion = recursion

        return _sorter(self._generator_other())
1370477
def get_importable_files(folder):
    
    for fname in os.listdir(folder):
        if fname.endswith('.py') and not fname.startswith('_'):
            fullname = os.path.join(folder, fname)
            if check_writable_by_others(fullname):
                print("ERROR: refuse to load module from world writable file %r" % fullname)
            else:
                yield fname
658372
def get_drive_files_list(folder)
      ls = Hash.new
      page_token = nil
      begin
        (files, page_token) = folder.files("pageToken" => page_token)
        files.each do |f|
          ls[f.original_filename] = f
        end
      end while page_token
      return ls
    end
865626
public static function ListAllFiles( string $folder, bool $recursive = false ) : array
   {

      // Init the array that should contain the resulting file paths
      $files = [];

      if ( ! @\is_dir( $folder ) )
      {
         // No folder = we are done here
         return $files;
      }

      if ( ! $recursive )
      {
         // List only files directly contained inside $folder (none from sub folders)

         // Open the directory pointer
         $d = \dir( $folder );
         // Ignore . and ..
         $d->read(); $d->read();
         // loop the rest
         while ( false !== ( $entry = $d->read() ) )
         {
            $tmp = Path::Combine( $folder, $entry );
            if ( ! \is_file( $tmp ) )
            {
               // Ignore sub folders
               continue;
            }
            $files[] = $tmp;
         }
         $d->close();
         return $files;
      }

      // List all files, also from sub folders
      static::_listRecursive( $files, $folder );

      return $files;

   }
126952
function getAllFolders(dir, folderlist) {
    const files = fs.readdirSync(dir);
    folderlist = folderlist || [];
    files.forEach((file) => {
        if (fs.statSync(path.join(dir, file)).isDirectory()) {
            folderlist = getAllFolders(path.join(dir, file), folderlist);
            folderlist.push(path.join(dir, file));
        }
    });
    return folderlist;
}