empty_volume_cache.py 文件源码

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

项目:Email_My_PC 作者: Jackeriss 项目源码 文件源码
def _WalkCallback(self, arg, directory, files):
        # callback function for os.path.walk - no need to be member, but its
        # close to the callers :)
        callback, total_list = arg
        for file in files:
            fqn = os.path.join(directory, file).lower()
            if file.endswith(".pyc") or file.endswith(".pyo"):
                # See below - total_list == None means delete files,
                # otherwise it is a list where the result is stored. Its a
                # list simply due to the way os.walk works - only [0] is
                # referenced
                if total_list is None:
                    print "Deleting file", fqn
                    # Should do callback.PurgeProcess - left as an exercise :)
                    os.remove(fqn)
                else:
                    total_list[0] += os.stat(fqn)[stat.ST_SIZE]
                    # and callback to the tool
                    if callback:
                        # for the sake of seeing the progress bar do its thing,
                        # we take longer than we need to...
                        # ACK - for some bizarre reason this screws up the XP
                        # cleanup manager - clues welcome!! :)
                        ## print "Looking in", directory, ", but waiting a while..."
                        ## time.sleep(3)
                        # now do it
                        used = total_list[0]
                        callback.ScanProgress(used, 0, "Looking at " + fqn)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号