Iterator for api.folder_get_content
172630
def _folder_get_content_iter(self, folder_key=None):
        """"""

        lookup_params = [
            {'content_type': 'folders', 'node': 'folders'},
            {'content_type': 'files', 'node': 'files'}
        ]

        for param in lookup_params:
            more_chunks = True
            chunk = 0
            while more_chunks:
                chunk += 1
                content = self.api.folder_get_content(
                    content_type=param['content_type'], chunk=chunk,
                    folder_key=folder_key)['folder_content']

                # empty folder/file list
                if not content[param['node']]:
                    break

                # no next page
                if content['more_chunks'] == 'no':
                    more_chunks = False

                for resource_info in content[param['node']]:
                    yield resource_info
1046329
def get_contents(self):
        """"""
        childsigs = [n.get_csig() for n in self.children()]
        return ''.join(childsigs)
546148
def items(self):
        """"""
        contents = self.paths
        contents = (
            BinFile(path.path) if path.is_file else BinDir(path.path)
            for path in contents
        )
        return contents
637933
def read_content (self):
        """"""
        if self.is_directory():
            data = get_index_html(get_files(self.get_os_filename()))
            if isinstance(data, unicode):
                data = data.encode("iso8859-1", "ignore")
        else:
            data = super(FileUrl, self).read_content()
        return data
739618
def read_folder(directory):
    
    res = []
    for filename in os.listdir(directory):
        with io.open(os.path.join(directory, filename), encoding="utf-8") as f:
            content = f.read()
            res.append(content)
    return res
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)
1197019
private function getContent(): void
    {
        foreach ($this->files as $item) {

            if (is_file($item)) {
                $this->readFileContent($item);
            }

            if (is_dir($item)) {
                $this->readDirectoryContent($item);
            }
        }
    }
33395
function getFoldersRecursive (folder) {
    var fileContents = fs.readdirSync(folder),
        stats,
        folders = [];

    fileContents.forEach(function (fileName) {
        stats = fs.lstatSync(folder + '/' + fileName);

        if (stats.isDirectory()) {
          folders.push(folder + '/' + fileName);
          folders = folders.concat(getFoldersRecursive(folder + '/' + fileName));
        }
    });

    return folders;
}
717384
@Override
    public Iterator<Path> iterator() {
        if (closed) {
            throw new IllegalStateException("Directory Stream is closed");
        } else if (iteratorReturned) {
            throw new IllegalStateException("Iterator was already returned");
        }

        boolean finishedSuccessfully = true;
        try {
            // Translate ShrinkWrap API to NIO.2 API Path
            final Map<ArchivePath, Node> content = this.fs.getArchive().getContent();
            final Collection<Path> newPaths = new ArrayList<>(content.size());
            final Collection<ArchivePath> archivePaths = content.keySet();
            for (final ArchivePath path : archivePaths) {
                final Path newPath = new ShrinkWrapPath(path, fs);

                if (!newPath.getParent().equals(startingPath)) {
                    continue;
                }

                // If we have a filter, and it rejects this path
                try {
                    if (filter != null && !(filter.accept(newPath))) {
                        // Move along
                        continue;
                    }
                } catch (IOException ioe) {
                    throw new RuntimeException("Error encountered during filtering", ioe);
                }

                // Add the new Path; the filter either wasn't specified or didn't reject this Path
                newPaths.add(newPath);
            }

            // Return
            return newPaths.iterator();
        } catch (Throwable t) {
            finishedSuccessfully = false;
            throw t;
        } finally {
            if (finishedSuccessfully) {
                iteratorReturned = true;
            }
        }
    }
155878
def files(self):
        """"""
        contents = self.paths
        contents = (BinFile(path.path) for path in contents if path.is_file)
        return contents
395873
def get_files(directory, recursive=False):
    """"""
    files_out = []
    if recursive:
        for root, dirs, files in os.walk(os.path.abspath(directory)):
            files = [os.path.join(root, f) for f in files]
            files_out.append(files)
        files_out = list(itertools.chain(*files_out))
    else:
        files_out = [os.path.join(directory, f) for f in os.listdir(directory)]
        files_out = list(filter(lambda f: os.path.isfile(f), files_out))

    # order alphabetically on file name
    return sorted(files_out)
505960
def listdir(self, folder_id='0', offset=None, limit=None, fields=None):
		''
		if fields is not None\
			and not isinstance(fields, types.StringTypes): fields = ','.join(fields)
		return self(
			join('folders', folder_id, 'items'),
			dict(offset=offset, limit=limit, fields=fields) )
392772
def list_folder(self, path):
        """"""
        # Inspired by https://github.com/rspivak/sftpserver/blob/0.3/src/sftpserver/stub_sftp.py#L70
        try:
            folder_contents = []
            for f in os.listdir(path):
                attr = paramiko.SFTPAttributes.from_stat(os.stat(os.path.join(path, f)))
                attr.filename = f
                folder_contents.append(attr)
            return folder_contents
        except OSError as e:
            return SFTPServer.convert_errno(e.errno)
615437
function getFoldersAndFiles(fpath, folders, files){
	fs.readdirSync(fpath).forEach(function(name){
		var stat = fs.statSync(fpath + name);
		if(stat.isDirectory()){
			folders.push({
				path : fpath,
				name : name
			});
			
			getFoldersAndFiles(fpath + name + '/', folders, files);
		}else{
			files.push({
				path : fpath,
				name : name
			});
		}
	});
}
615970
function getFiles(base, dir = '', results = []) {
            const files = fs.readdirSync(path.join(base, dir));
            for (const file of files) {
                const relativeToBase = path.join(dir, file);
                if (fs.statSync(path.join(base, relativeToBase)).isDirectory()) {
                    getFiles(base, relativeToBase, results);
                } else {
                    results.push(relativeToBase);
                }
            }
            return results;
        }
453861
function (dir, done) {
  var results = [];
  fs.readdir(dir, function (err, list) {
    if (err) return done(err);
    var i = 0;
    (function next() {
      var file = list[i++];
      if (!file) return done(null, results);
      file = dir + '/' + file;
      fs.stat(file, function (err2, stat) {
        if (stat && stat.isDirectory()) {
          walk(file, function (err3, res) {
            results = results.concat(res);
            next();
          });
        } else {
          results.push(file);
          next();
        }
      });
    })();
  });
}
425048
function gallery (content, contentType) {
  let output = {}
  const allFiles = content.filter(each => each.dir.includes(`/${contentType}`))
  const index = allFiles.filter(each => each.base === 'index.md')[0]
  index.attr.forEach(each => {
    Object.keys(each).forEach(key => {
      output[key] = Object.assign({ title: each[key] }, allFiles.filter(file => file.name === key)[0])
    })
  })
  return output
}