From: zooko Date: Wed, 28 Mar 2007 03:14:06 +0000 (+0530) Subject: pyfec: add documentation, assertion, licence information X-Git-Url: https://git.rkrishnan.org/listings/frontends/htmlfontify-example.html?a=commitdiff_plain;h=602f821a78d2405e50a03a8c1434e43295835917;p=tahoe-lafs%2Fzfec.git pyfec: add documentation, assertion, licence information darcs-hash:3f117bc64875732e7cc80b5788147a6c23bb161f --- diff --git a/pyfec/fec/_fecmodule.c b/pyfec/fec/_fecmodule.c index 97a935e..a3497c8 100644 --- a/pyfec/fec/_fecmodule.c +++ b/pyfec/fec/_fecmodule.c @@ -125,8 +125,9 @@ Encoder_init(Encoder *self, PyObject *args, PyObject *kwdict) { } static char Encoder_encode__doc__[] = "\ -Encode data into m packets.\ -@param inshares: a sequence of k buffers of data to encode -- these are the k primary shares, i.e. the input data split into k pieces (for best performance, make it a tuple instead of a list)\n\ +Encode data into m packets.\n\ +\n\ +@param inshares: a sequence of k buffers of data to encode -- these are the k primary shares, i.e. the input data split into k pieces (for best performance, make it a tuple instead of a list); All shares are required to be the same length.\n\ @param desired_shares_ids optional sequence of shareids indicating which shares to produce and return; If None, all m shares will be returned (in order). (For best performance, make it a tuple instead of a list.)\n\ @returns: a list of buffers containing the requested shares; Note that if any of the input shares were 'primary shares', i.e. their shareid was < k, then the result sequence will contain a Python reference to the same Python object as was passed in. As long as the Python object in question is immutable (i.e. a string) then you don't have to think about this detail, but if it is mutable (i.e. an array), then you have to be aware that if you subsequently mutate the contents of that object then that will also change the contents of the sequence that was returned from this call to encode().\n\ "; diff --git a/pyfec/fec/filefec.py b/pyfec/fec/filefec.py index 4899ede..a4736f5 100644 --- a/pyfec/fec/filefec.py +++ b/pyfec/fec/filefec.py @@ -6,10 +6,13 @@ # # This file is part of pyfec. # -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2 of the License, or (at your option) +# any later version. This program also comes with the added permission that, +# in the case that you are obligated to release a derived work under this +# licence (as per section 2.b of the GPL), you may delay the fulfillment of +# this obligation for up to 12 months. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -59,9 +62,12 @@ def decode_from_files(outf, filesize, prefix, k, m): x = [ inf.read(CHUNKSIZE) for inf in infs ] decshares = dec.decode(x, shareids) for decshare in decshares: + if len(decshare) == 0: + raise "error -- probably share was too short -- was it stored in a file which got truncated? chunksizes: %s" % ([len(chunk) for chunk in x],) if filesize >= len(decshare): outf.write(decshare) filesize -= len(decshare) + # print "filesize is now %s after subtracting %s" % (filesize, len(decshare),) else: outf.write(decshare[:filesize]) return