本文整理匯總了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)