From 344d245bbaa983d1319df1d6d3007873073e8014 Mon Sep 17 00:00:00 2001 From: warner Date: Thu, 19 Apr 2007 00:48:12 +0530 Subject: [PATCH] rename top-level package from 'fec' to 'zfec' darcs-hash:972d01d4a06da3354d3802b9a27c2948f0e36073 --- zfec/bin/fec | 10 ++++---- zfec/bin/unfec | 10 ++++---- zfec/setup.py | 4 ++-- zfec/{fec => zfec}/__init__.py | 0 zfec/{fec => zfec}/_fecmodule.c | 0 zfec/{fec => zfec}/easyfec.py | 6 ++--- zfec/{fec => zfec}/fec.c | 0 zfec/{fec => zfec}/fec.h | 0 zfec/{fec => zfec}/filefec.py | 14 +++++------ zfec/{fec => zfec}/test/__init__.py | 0 zfec/{fec => zfec}/test/bench_pyfec.py | 0 zfec/{fec => zfec}/test/test_pyfec.py | 32 +++++++++++++------------- zfec/{fec => zfec}/util/__init__.py | 0 zfec/{fec => zfec}/util/argparse.py | 0 zfec/{fec => zfec}/util/fileutil.py | 0 zfec/{fec => zfec}/util/mathutil.py | 0 zfec/{fec => zfec}/util/version.py | 0 17 files changed, 38 insertions(+), 38 deletions(-) rename zfec/{fec => zfec}/__init__.py (100%) rename zfec/{fec => zfec}/_fecmodule.c (100%) rename zfec/{fec => zfec}/easyfec.py (91%) rename zfec/{fec => zfec}/fec.c (100%) rename zfec/{fec => zfec}/fec.h (100%) rename zfec/{fec => zfec}/filefec.py (98%) rename zfec/{fec => zfec}/test/__init__.py (100%) rename zfec/{fec => zfec}/test/bench_pyfec.py (100%) rename zfec/{fec => zfec}/test/test_pyfec.py (88%) rename zfec/{fec => zfec}/util/__init__.py (100%) rename zfec/{fec => zfec}/util/argparse.py (100%) rename zfec/{fec => zfec}/util/fileutil.py (100%) rename zfec/{fec => zfec}/util/mathutil.py (100%) rename zfec/{fec => zfec}/util/version.py (100%) diff --git a/zfec/bin/fec b/zfec/bin/fec index 6ff1956..c4eb9fe 100755 --- a/zfec/bin/fec +++ b/zfec/bin/fec @@ -5,14 +5,14 @@ import sys -import fec -from fec.util import argparse -from fec import filefec -from fec.util.version import Version +import zfec +from zfec.util import argparse +from zfec import filefec +from zfec.util.version import Version __version__ = Version("1.0.0a1-0-STABLE") if '-V' in sys.argv or '--version' in sys.argv: - print "zfec library version: ", fec.__version__ + print "zfec library version: ", zfec.__version__ print "fec command-line tool version: ", __version__ sys.exit(0) diff --git a/zfec/bin/unfec b/zfec/bin/unfec index 0befb6b..ab354ee 100755 --- a/zfec/bin/unfec +++ b/zfec/bin/unfec @@ -5,15 +5,15 @@ import os, sys -from fec.util import argparse +from zfec.util import argparse -import fec -from fec import filefec -from fec.util.version import Version +import zfec +from zfec import filefec +from zfec.util.version import Version __version__ = Version("1.0.0a1-0-STABLE") if '-V' in sys.argv or '--version' in sys.argv: - print "zfec library version: ", fec.__version__ + print "zfec library version: ", zfec.__version__ print "fec command-line tool version: ", __version__ sys.exit(0) diff --git a/zfec/setup.py b/zfec/setup.py index 7a44bc1..1ca9108 100755 --- a/zfec/setup.py +++ b/zfec/setup.py @@ -63,7 +63,7 @@ setup(name='zfec', url='http://www.allmydata.com/source/zfec', license='GNU GPL', platform='Any', - packages=['fec', 'fec.util', 'fec.test'], + packages=['zfec', 'zfec.util', 'zfec.test'], classifiers=trove_classifiers, - ext_modules=[Extension('_fec', ['fec/fec.c', 'fec/_fecmodule.c',], extra_link_args=extra_link_args, extra_compile_args=extra_compile_args, undef_macros=undef_macros),], + ext_modules=[Extension('_fec', ['zfec/fec.c', 'zfec/_fecmodule.c',], extra_link_args=extra_link_args, extra_compile_args=extra_compile_args, undef_macros=undef_macros),], ) diff --git a/zfec/fec/__init__.py b/zfec/zfec/__init__.py similarity index 100% rename from zfec/fec/__init__.py rename to zfec/zfec/__init__.py diff --git a/zfec/fec/_fecmodule.c b/zfec/zfec/_fecmodule.c similarity index 100% rename from zfec/fec/_fecmodule.c rename to zfec/zfec/_fecmodule.c diff --git a/zfec/fec/easyfec.py b/zfec/zfec/easyfec.py similarity index 91% rename from zfec/fec/easyfec.py rename to zfec/zfec/easyfec.py index 8fc1506..e81a7dd 100644 --- a/zfec/fec/easyfec.py +++ b/zfec/zfec/easyfec.py @@ -1,4 +1,4 @@ -import fec +import zfec # div_ceil() was copied from the pyutil library. def div_ceil(n, d): @@ -9,7 +9,7 @@ def div_ceil(n, d): class Encoder(object): def __init__(self, k, m): - self.fec = fec.Encoder(k, m) + self.fec = zfec.Encoder(k, m) def encode(self, data): """ @@ -26,7 +26,7 @@ class Encoder(object): class Decoder(object): def __init__(self, k, m): - self.fec = fec.Decoder(k, m) + self.fec = zfec.Decoder(k, m) def decode(self, blocks, sharenums, padlen=0): blocks = self.fec.decode(blocks, sharenums) diff --git a/zfec/fec/fec.c b/zfec/zfec/fec.c similarity index 100% rename from zfec/fec/fec.c rename to zfec/zfec/fec.c diff --git a/zfec/fec/fec.h b/zfec/zfec/fec.h similarity index 100% rename from zfec/fec/fec.h rename to zfec/zfec/fec.h diff --git a/zfec/fec/filefec.py b/zfec/zfec/filefec.py similarity index 98% rename from zfec/fec/filefec.py rename to zfec/zfec/filefec.py index 7a08a19..775985c 100644 --- a/zfec/fec/filefec.py +++ b/zfec/zfec/filefec.py @@ -23,7 +23,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -import easyfec, fec +import easyfec, zfec from util import fileutil from util.mathutil import log_ceil @@ -31,9 +31,9 @@ import array, os, re, struct, traceback CHUNKSIZE = 4096 -class InsufficientShareFilesError(fec.Error): +class InsufficientShareFilesError(zfec.Error): def __init__(self, k, kb, *args, **kwargs): - fec.Error.__init__(self, *args, **kwargs) + zfec.Error.__init__(self, *args, **kwargs) self.k = k self.kb = kb @@ -43,7 +43,7 @@ class InsufficientShareFilesError(fec.Error): def __str__(self): return self.__repr__() -class CorruptedShareFilesError(fec.Error): +class CorruptedShareFilesError(zfec.Error): pass def _build_header(m, k, pad, sh): @@ -185,7 +185,7 @@ def encode_to_files(inf, fsize, dirname, prefix, k, m, suffix=".fec", overwrite= mlen = len(str(m)) format = FORMAT_FORMAT % (mlen, mlen,) - padbytes = fec.util.mathutil.pad_size(fsize, k) + padbytes = zfec.util.mathutil.pad_size(fsize, k) fns = [] fs = [] @@ -330,7 +330,7 @@ def encode_file(inf, cb, k, m, chunksize=4096): @param chunksize how much data to read from inf for each of the k input blocks """ - enc = fec.Encoder(k, m) + enc = zfec.Encoder(k, m) l = tuple([ array.array('c') for i in range(k) ]) indatasize = k*chunksize # will be reset to shorter upon EOF eof = False @@ -381,7 +381,7 @@ def encode_file_stringy(inf, cb, k, m, chunksize=4096): @param chunksize how much data to read from inf for each of the k input blocks """ - enc = fec.Encoder(k, m) + enc = zfec.Encoder(k, m) indatasize = k*chunksize # will be reset to shorter upon EOF while indatasize == k*chunksize: # This loop body executes once per segment. diff --git a/zfec/fec/test/__init__.py b/zfec/zfec/test/__init__.py similarity index 100% rename from zfec/fec/test/__init__.py rename to zfec/zfec/test/__init__.py diff --git a/zfec/fec/test/bench_pyfec.py b/zfec/zfec/test/bench_pyfec.py similarity index 100% rename from zfec/fec/test/bench_pyfec.py rename to zfec/zfec/test/bench_pyfec.py diff --git a/zfec/fec/test/test_pyfec.py b/zfec/zfec/test/test_pyfec.py similarity index 88% rename from zfec/fec/test/test_pyfec.py rename to zfec/zfec/test/test_pyfec.py index 081eecd..e080e83 100755 --- a/zfec/fec/test/test_pyfec.py +++ b/zfec/zfec/test/test_pyfec.py @@ -30,7 +30,7 @@ import cStringIO, os, random, re, sys -import fec +import zfec try: from twisted.trial import unittest @@ -56,14 +56,14 @@ def ab(x): # debuggery return "%s:%s" % (len(x), "--empty--",) def _h(k, m, ss): - encer = fec.Encoder(k, m) + encer = zfec.Encoder(k, m) nums_and_blocks = list(enumerate(encer.encode(ss))) assert isinstance(nums_and_blocks, list), nums_and_blocks assert len(nums_and_blocks) == m, (len(nums_and_blocks), m,) nums_and_blocks = random.sample(nums_and_blocks, k) blocks = [ x[1] for x in nums_and_blocks ] nums = [ x[0] for x in nums_and_blocks ] - decer = fec.Decoder(k, m) + decer = zfec.Decoder(k, m) decoded = decer.decode(blocks, nums) assert len(decoded) == len(ss), (len(decoded), len(ss),) assert tuple([str(s) for s in decoded]) == tuple([str(s) for s in ss]), (tuple([ab(str(s)) for s in decoded]), tuple([ab(str(s)) for s in ss]),) @@ -84,7 +84,7 @@ def _help_test_random_with_l(l): ss = [ randstr(l/k) for x in range(k) ] _h(k, m, ss) -class Fec(unittest.TestCase): +class ZFec(unittest.TestCase): def test_random(self): for i in range(3): _help_test_random() @@ -92,13 +92,13 @@ class Fec(unittest.TestCase): print "%d randomized tests pass." % (i+1) def test_bad_args_enc(self): - encer = fec.Encoder(2, 4) + encer = zfec.Encoder(2, 4) try: encer.encode(["a", "b", ], ["c", "I am not an integer blocknum",]) - except fec.Error, e: + except zfec.Error, e: assert "Precondition violation: second argument is required to contain int" in str(e), e else: - raise "Should have gotten fec.Error for wrong type of second argument." + raise "Should have gotten zfec.Error for wrong type of second argument." try: encer.encode(["a", "b", ], 98) # not a sequence at all @@ -108,7 +108,7 @@ class Fec(unittest.TestCase): raise "Should have gotten TypeError for wrong type of second argument." def test_bad_args_dec(self): - decer = fec.Decoder(2, 4) + decer = zfec.Decoder(2, 4) try: decer.decode(98, [0, 1]) # first argument is not a sequence @@ -119,10 +119,10 @@ class Fec(unittest.TestCase): try: decer.decode(["a", "b", ], ["c", "d",]) - except fec.Error, e: + except zfec.Error, e: assert "Precondition violation: second argument is required to contain int" in str(e), e else: - raise "Should have gotten fec.Error for wrong type of second argument." + raise "Should have gotten zfec.Error for wrong type of second argument." try: decer.decode(["a", "b", ], 98) # not a sequence at all @@ -143,9 +143,9 @@ class FileFec(unittest.TestCase): for sh in [0, 1, m-1,]: if sh >= m: continue - h = fec.filefec._build_header(m, k, pad, sh) + h = zfec.filefec._build_header(m, k, pad, sh) hio = cStringIO.StringIO(h) - (rm, rk, rpad, rsh,) = fec.filefec._parse_header(hio) + (rm, rk, rpad, rsh,) = zfec.filefec._parse_header(hio) assert (rm, rk, rpad, rsh,) == (m, k, pad, sh,), h def _help_test_filefec(self, teststr, k, m, numshs=None): @@ -156,7 +156,7 @@ class FileFec(unittest.TestCase): PREFIX = "test" SUFFIX = ".fec" - tempdir = fec.util.fileutil.NamedTemporaryDirectory(cleanup=False) + tempdir = zfec.util.fileutil.NamedTemporaryDirectory(cleanup=False) try: tempfn = os.path.join(tempdir.name, TESTFNAME) tempf = open(tempfn, 'wb') @@ -166,10 +166,10 @@ class FileFec(unittest.TestCase): assert fsize == len(teststr) # encode the file - fec.filefec.encode_to_files(open(tempfn, 'rb'), fsize, tempdir.name, PREFIX, k, m, SUFFIX, verbose=VERBOSE) + zfec.filefec.encode_to_files(open(tempfn, 'rb'), fsize, tempdir.name, PREFIX, k, m, SUFFIX, verbose=VERBOSE) # select some share files - RE=re.compile(fec.filefec.RE_FORMAT % (PREFIX, SUFFIX,)) + RE=re.compile(zfec.filefec.RE_FORMAT % (PREFIX, SUFFIX,)) fns = os.listdir(tempdir.name) sharefs = [ open(os.path.join(tempdir.name, fn), "rb") for fn in fns if RE.match(fn) ] random.shuffle(sharefs) @@ -177,7 +177,7 @@ class FileFec(unittest.TestCase): # decode from the share files outf = open(os.path.join(tempdir.name, 'recovered-testfile.txt'), 'wb') - fec.filefec.decode_from_files(outf, sharefs, verbose=VERBOSE) + zfec.filefec.decode_from_files(outf, sharefs, verbose=VERBOSE) outf.close() tempfn = open(os.path.join(tempdir.name, 'recovered-testfile.txt'), 'rb') diff --git a/zfec/fec/util/__init__.py b/zfec/zfec/util/__init__.py similarity index 100% rename from zfec/fec/util/__init__.py rename to zfec/zfec/util/__init__.py diff --git a/zfec/fec/util/argparse.py b/zfec/zfec/util/argparse.py similarity index 100% rename from zfec/fec/util/argparse.py rename to zfec/zfec/util/argparse.py diff --git a/zfec/fec/util/fileutil.py b/zfec/zfec/util/fileutil.py similarity index 100% rename from zfec/fec/util/fileutil.py rename to zfec/zfec/util/fileutil.py diff --git a/zfec/fec/util/mathutil.py b/zfec/zfec/util/mathutil.py similarity index 100% rename from zfec/fec/util/mathutil.py rename to zfec/zfec/util/mathutil.py diff --git a/zfec/fec/util/version.py b/zfec/zfec/util/version.py similarity index 100% rename from zfec/fec/util/version.py rename to zfec/zfec/util/version.py -- 2.45.2