本文整理汇总了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
示例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