当前位置: 首页>>代码示例>>Python>>正文


Python FileUtilities.getsize方法代码示例

本文整理汇总了Python中bleachbit.FileUtilities.getsize方法的典型用法代码示例。如果您正苦于以下问题:Python FileUtilities.getsize方法的具体用法?Python FileUtilities.getsize怎么用?Python FileUtilities.getsize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bleachbit.FileUtilities的用法示例。


在下文中一共展示了FileUtilities.getsize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: execute

# 需要导入模块: from bleachbit import FileUtilities [as 别名]
# 或者: from bleachbit.FileUtilities import getsize [as 别名]
    def execute(self, really_delete):

        if self.path is not None and FileUtilities.whitelisted(self.path):
            yield whitelist(self.path)
            return

        ret = {
            'label': self.label,
            'n_deleted': 0,
            'n_special': 1,
            'path': self.path,
            'size': None}

        if really_delete:
            if self.path is None:
                # Function takes no path.  It returns the size.
                func_ret = self.func()
                if isinstance(func_ret, types.GeneratorType):
                    # function returned generator
                    for func_ret in self.func():
                        if True == func_ret or isinstance(func_ret, tuple):
                            # Return control to GTK idle loop.
                            # If tuple, then display progress.
                            yield func_ret
                # either way, func_ret should be an integer
                assert isinstance(func_ret, (int, long))
                ret['size'] = func_ret
            else:
                if os.path.isdir(self.path):
                    raise RuntimeError('Attempting to run file function %s on directory %s' %
                                       (self.func.func_name, self.path))
                # Function takes a path.  We check the size.
                oldsize = FileUtilities.getsize(self.path)
                try:
                    self.func(self.path)
                except DatabaseError as e:
                    if -1 == e.message.find('file is encrypted or is not a database') and \
                       -1 == e.message.find('or missing database'):
                        raise
                    logging.getLogger(__name__).exception(e.message)
                    return
                try:
                    newsize = FileUtilities.getsize(self.path)
                except OSError as e:
                    from errno import ENOENT
                    if e.errno == ENOENT:
                        # file does not exist
                        newsize = 0
                    else:
                        raise
                ret['size'] = oldsize - newsize
        yield ret
开发者ID:tstenner,项目名称:bleachbit,代码行数:54,代码来源:Command.py

示例2: get_globs_size

# 需要导入模块: from bleachbit import FileUtilities [as 别名]
# 或者: from bleachbit.FileUtilities import getsize [as 别名]
def get_globs_size(paths):
    """Get the cumulative size (in bytes) of a list of globs"""
    total_size = 0
    for path in paths:
        from glob import iglob
        for p in iglob(path):
            total_size += FileUtilities.getsize(p)
    return total_size
开发者ID:tstenner,项目名称:bleachbit,代码行数:10,代码来源:Unix.py


注:本文中的bleachbit.FileUtilities.getsize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。