From: zooko Date: Thu, 8 Nov 2007 22:28:06 +0000 (+0530) Subject: TEMP TFIX EASYFGEC X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/css/cyclelanguage?a=commitdiff_plain;h=3e7dd858969165a9fd1482fc53a4950a8374f9e9;p=tahoe-lafs%2Fzfec.git TEMP TFIX EASYFGEC darcs-hash:51a43555f1cf5d12bd8602254a17b0596d590e7d --- diff --git a/zfec/zfec/easyfec.py b/zfec/zfec/easyfec.py index 1843a69..8b5e896 100644 --- a/zfec/zfec/easyfec.py +++ b/zfec/zfec/easyfec.py @@ -19,11 +19,11 @@ class Encoder(object): @param data: string """ chunksize = div_ceil(len(data), self.fec.k) - numchunks = div_ceil(len(data), chunksize) - l = [ data[i:i+chunksize] for i in range(0, len(data), chunksize) ] + l = [ data[i*chunksize:(i+1)*chunksize] for i in range(self.fec.k) ] # padding - if len(l[-1]) != len(l[0]): - l[-1] = l[-1] + ('\x00'*(len(l[0])-len(l[-1]))) + if l and (len(l[-1]) != chunksize): + l[-1] = l[-1] + ('\x00'*(chunksize-len(l[-1]))) + assert len(l) == self.fec.k, (len(l), self.fec.k,) res = self.fec.encode(l) return res