本文整理汇总了Python中Tardis.Util.asString方法的典型用法代码示例。如果您正苦于以下问题:Python Util.asString方法的具体用法?Python Util.asString怎么用?Python Util.asString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tardis.Util
的用法示例。
在下文中一共展示了Util.asString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: collectDirContents2
# 需要导入模块: from Tardis import Util [as 别名]
# 或者: from Tardis.Util import asString [as 别名]
def collectDirContents2(tardis, dirList, crypt):
"""
Do the same thing as collectDirContents, just a lot faster, relying on the structure of the DB.
Create a set of directory "ranges", a range being a set of entries in the dirlist that a: all have
the same inode, and b: span a contiguous range of backupsets in the backupsets list (ie, if there are 3
backupsets in the range in backupsets, there also must be the same three entries in the dirlist). Then
query any directory entries that exist in here, and span each one over the approriate portions of the
range. Repeat for each range.
"""
contents = {}
for (x, y) in dirList:
contents[x['backupset']] = {}
names = set()
ranges = []
dirRange = []
prev = {}
dirHash = dict([(x['backupset'], y) for (x,y) in dirList])
# Detect the ranges
for bset in backupSets:
d = dirHash.setdefault(bset['backupset'])
# If we don't have an entry here, the range ends.
# OR if the inode is different from the previous
if prev and ((not d) or (prev['inode'] != d['inode']) or (prev['device'] != d['device'])):
if len(dirRange):
ranges.append(dirRange)
dirRange = []
if d:
dirRange.append(bset)
prev = d
if len(dirRange):
ranges.append(dirRange)
# Now, for each range, populate
for r in ranges:
first = r[0]['backupset']
last = r[-1]['backupset']
dinfo = dirHash[first]
#print "Reading for (%d, %d) : %d => %d" %(dinfo['inode'], dinfo['device'], first, last)
x = tardis.readDirectoryForRange((dinfo['inode'], dinfo['device']), first, last)
for y in x:
logger.debug("Processing %s", y['name'])
name = Util.asString(crypt.decryptFilename(y['name'])) if crypt else Util.asString(y['name'])
names.add(name)
for bset in r:
if y['firstset'] <= bset['backupset'] <= y['lastset']:
contents[bset['backupset']][name] = y
# and return what we've discovered
return (contents, names)