astutils.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:pynd 作者: d0ugal 项目源码 文件源码
def _walk_files(self, path):
        """Walk paths and yield Python paths

        Directories and files are yielded in alphabetical order. Directories
        starting with a "." are skipped. As are those that match any provided
        ignore patterns.
        """

        if os.path.isfile(path):
            yield path
        elif not os.path.isdir(path):
            LOG.error("The path '%s' can't be found.", path)
            raise StopIteration

        for root, dirs, filenames in os.walk(path):
            # Remove dot-directories from the dirs list.
            dirs[:] = sorted(d for d in dirs if not d.startswith('.') and
                             not self._is_ignored(d))
            for filename in sorted(filenames):
                if self._is_python(filename):
                    yield os.path.join(root, filename)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号