if os.path.exists(name): inputfiles.append(io.open(file_name+"_%d"%i,'rb')) survived.append(i) outputfile = io.open(file_name+"_decoded", 'wb') for i,p in enumerate(survived): dec_points[i] = p+1 print dec_points decoder = HSRC(k, dec_points, w=w, packetsize=packetsize, mode=mode, decoder=True) readblock = k*buffsize to_read = file_size while to_read>0: for i,inputf in enumerate(inputfiles): inputf.readinto(encoded_data[i]) decoder.decode(encoded_data, raw_data) if to_read>=readblock: for rd in raw_data: outputfile.write(rd) to_read -= readblock else: data = to_read for rd in raw_data: outputfile.write(buffer(rd,0,to_read)) to_read = max(to_read-buffsize, 0) for inputf in inputfiles: inputf.close() outputfile.close()