Yield directory file names.
173055
def directory_files(path):
    """"""

    for entry in os.scandir(path):
        if not entry.name.startswith('.') and entry.is_file():
            yield entry.name
702469
def _os_walk(directory, recurse=True, **kwargs):
    
    if recurse:
        for root, dirs, files in os.walk(directory, **kwargs):
            yield root, dirs, files
    else:
        files = []
        for filename in os.listdir(directory):
            if os.path.isfile(os.path.join(directory, filename)):
                files.append(filename)
        yield directory, [], files
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+"/"
36684
def _generate_filenames(sources):
    
    for source in sources:
        if os.path.isdir(source):
            for path, dirlist, filelist in os.walk(source):
                for fname in filelist:
                    if GenericFilePath.is_compressed(fname):
                        if VERBOSE:
                            print("Skipping compressed file: {}".format(os.path.abspath(fname)))
                        continue
                    else:
                        yield os.path.join(path, fname)

        elif os.path.isfile(source):
            yield source

        elif source.isdigit():
            analysis_id = "AN{}".format(source.zfill(6))
            url = MWREST.format(analysis_id)
            yield url

        elif GenericFilePath.is_url(source):
            yield source

        else:
            raise TypeError("Unknown file source.")
324682
def yield_all_file_path(dir_abspath):
        
        if os.path.isdir(dir_abspath):
            dir_abspath = os.path.abspath(dir_abspath)
            for current_folder, _, fnamelist in os.walk(dir_abspath):
                for fname in fnamelist:
                    yield os.path.join(current_folder, fname)
        else:
            raise FileNotFoundError(
                "'%s' may not exists or is not a directory!" % dir_abspath)
1118215
def output_files(self):
        
        for item in self.source_files:
            yield os.path.join(self.address.repo, self.address.path, item)
749302
def iter_directory(directory):
    """"""
    for path, dir, files in os.walk(directory):
        for f in files:
            filepath = os.path.join(path, f)
            key = os.path.relpath(filepath, directory)
            yield (filepath, key)
66160
def _generator_file(self):
        """'"""
        for path in self.paths:
            if os.path.isfile(path):
                if isvalid(path, self.access, self.extensions,
                           minsize=self.minsize):
                    yield os.path.abspath(path)
            elif os.path.isdir(path):
                for root, _, fnames in self._walker(path):
                    yield from self._generator_rebase(fnames, root)
710117
def mkdirs(filename, mode=0o777):
    """"""
    dirname = os.path.dirname(filename)
    if not dirname:
        return
    _compat.makedirs(dirname, mode=mode, exist_ok=True)
538575
def iterpaths(self):
        
        try:
            for path in self.order:
                yield path
        except:
            for path in self.files:
                yield path
1317818
def get_files_from_storage(paths):
        """"""
        for path in paths:
            f = default_storage.open(path)
            f.name = os.path.basename(path)
            try:
                yield f
            except ClientError:
                logger.exception("File not found: %s", path)
1373271
def filename_items_for_filetype(filenames, filetype_info):
        """"""
        matched_files = []
        for pattern in filetype_info['file_patterns']:
            for filename in match_filenames(filenames, pattern):
                if filename in matched_files:
                    continue
                try:
                    filename_info = parse(
                        pattern, get_filebase(filename, pattern))
                except ValueError:
                    logger.debug("Can't parse %s with %s.", filename, pattern)
                    continue
                matched_files.append(filename)
                yield filename, filename_info
196925
def file_names(self) -> Iterable[str]:
        
        if self.is_sharded():
            yield from ShardedFile(self.filename_spec).get_filenames()
        elif self.filename_spec:
            yield self.filename_spec
695962
def _to_dir(self, file_generator):
        
        for f in file_generator:
            outpath = self._output_path(f.source, file_generator.to_format)

            if not os.path.exists(os.path.dirname(outpath)):
                os.makedirs(os.path.dirname(outpath))

            with open(outpath, mode="w") as outfile:
                f.write(outfile, file_generator.to_format)
461866
private function directories(): \Generator
    {
        foreach ($this->directories as $root) {
            if (is_dir($root)) {
                yield $root => new \RecursiveIteratorIterator(
                    new \RecursiveDirectoryIterator($root)
                );
            }
        }
    }
471825
def iterfiles(self, pattern=None, abspath=False):
        
        if pattern is not None:
            globster = Globster([pattern])
        for root, dirs, files in self.walk():
            for f in files:
                if pattern is None or (pattern is not None and globster.match(f)):
                    if abspath:
                        yield os.path.join(root, f)
                    else:
                        yield self.relpath(os.path.join(root, f))
75785
def get_filenodes_generator(self):
        
        for topnode, dirs, files in self.walk():
            for node in files:
                yield node