From 3e7dd858969165a9fd1482fc53a4950a8374f9e9 Mon Sep 17 00:00:00 2001
From: zooko <zooko@zooko.com>
Date: Fri, 9 Nov 2007 03:58:06 +0530
Subject: [PATCH] TEMP TFIX EASYFGEC

darcs-hash:51a43555f1cf5d12bd8602254a17b0596d590e7d
---
 zfec/zfec/easyfec.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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
         
-- 
2.45.2