dugu.py 文件源码

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

项目:dugu 作者: DeaDSouL 项目源码 文件源码
def __countFiles(self, which=None):
        # this will count links AND sockets
        #self.total_files = sum((len(f) for _, _, f in os.walk(self.cwd)))

        total_files = 0
        i = 0
        for path, _, filenames in os.walk(self.cwd):
            for filename in filenames:
                if i >= len(self.wait_symbols): i = 0
                print 'Counting Files.... %s \r' % self.wait_symbols[i],
                i += 1
                filename_path = os.path.join(path, filename)
                if os.path.islink(filename_path):
                    # TODO: may be we should use 'and' instead of 'or' ??
                    if self.cwd not in os.path.realpath(filename_path) or not self.args.symlinks:
                        continue
                if os.path.exists(filename_path) and os.access(filename_path, os.R_OK) and not S_ISSOCK(os.stat(filename_path).st_mode):
                    total_files += 1

        if which == 'dst': print 'Counting DST Files.....Done \r'
        elif which == 'src': print 'Counting SRC Files.....Done \r'
        else: print 'Counting Files.........Done \r'

        return total_files

    # ------------------------------------------------------------------
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号