def rehash_release(_filelist, fdesc, rmstr):
"""
Calculates checksums of a given filelist and writes them to the given
file descriptor. Takes rmstr as the third argument, which is a string to
remove from the path of the hashed file when writing it to a file.
"""
info('Hashing checksums')
for csum in checksums:
fdesc.write('%s:\n' % csum['name'])
for i in _filelist:
if isfile(i):
cont = open(i, 'rb').read()
fdesc.write(' %s %8s %s\n' % (csum['f'](cont).hexdigest(),
getsize(i),
i.replace(rmstr+'/', '')))
elif i.endswith('.xz') and isfile(i.replace('.xz', '.gz')):
xzstr = lzma_comp(open(i.replace('.xz', '.gz'), 'rb').read())
fdesc.write(' %s %8s %s\n' % (csum['f'](xzstr).hexdigest(),
len(xzstr),
i.replace(rmstr+'/', '')))
elif not i.endswith('.gz') and isfile(i+'.gz'):
uncomp = gzip_decomp(open(i+'.gz', 'rb').read())
fdesc.write(' %s %8s %s\n' % (csum['f'](uncomp).hexdigest(),
len(uncomp),
i.replace(rmstr+'/', '')))
return
评论列表
文章目录