From: Brian Warner Date: Sat, 27 Aug 2011 18:33:57 +0000 (-0700) Subject: MDMF: s/Writable/Writeable/g, for consistency with existing SDMF code X-Git-Url: https://git.rkrishnan.org/frontends/vdrive/global?a=commitdiff_plain;h=48544a251dd5c552d6f5a19035176bc9ae64efbf;p=tahoe-lafs%2Ftahoe-lafs.git MDMF: s/Writable/Writeable/g, for consistency with existing SDMF code --- diff --git a/src/allmydata/interfaces.py b/src/allmydata/interfaces.py index 69ca6239..3081e94e 100644 --- a/src/allmydata/interfaces.py +++ b/src/allmydata/interfaces.py @@ -641,7 +641,7 @@ class IReadable(Interface): """ -class IWritable(Interface): +class IWriteable(Interface): """ I define methods that callers can use to update SDMF and MDMF mutable files on a Tahoe-LAFS grid. diff --git a/src/allmydata/mutable/filenode.py b/src/allmydata/mutable/filenode.py index e798a589..9f70e210 100644 --- a/src/allmydata/mutable/filenode.py +++ b/src/allmydata/mutable/filenode.py @@ -6,11 +6,11 @@ from twisted.internet import defer, reactor from foolscap.api import eventually from allmydata.interfaces import IMutableFileNode, ICheckable, ICheckResults, \ NotEnoughSharesError, MDMF_VERSION, SDMF_VERSION, IMutableUploadable, \ - IMutableFileVersion, IWritable + IMutableFileVersion, IWriteable from allmydata.util import hashutil, log, consumer, deferredutil, mathutil from allmydata.util.assertutil import precondition from allmydata.uri import WriteableSSKFileURI, ReadonlySSKFileURI, \ - WritableMDMFFileURI, ReadonlyMDMFFileURI + WriteableMDMFFileURI, ReadonlyMDMFFileURI from allmydata.monitor import Monitor from pycryptopp.cipher.aes import AES @@ -96,7 +96,7 @@ class MutableFileNode: # verification key, nor things like 'k' or 'N'. If and when someone # wants to get our contents, we'll pull from shares and fill those # in. - if isinstance(filecap, (WritableMDMFFileURI, ReadonlyMDMFFileURI)): + if isinstance(filecap, (WriteableMDMFFileURI, ReadonlyMDMFFileURI)): self._protocol_version = MDMF_VERSION elif isinstance(filecap, (ReadonlySSKFileURI, WriteableSSKFileURI)): self._protocol_version = SDMF_VERSION @@ -146,7 +146,7 @@ class MutableFileNode: self._encprivkey = self._encrypt_privkey(self._writekey, privkey_s) self._fingerprint = hashutil.ssk_pubkey_fingerprint_hash(pubkey_s) if version == MDMF_VERSION: - self._uri = WritableMDMFFileURI(self._writekey, self._fingerprint) + self._uri = WriteableMDMFFileURI(self._writekey, self._fingerprint) self._protocol_version = version elif version == SDMF_VERSION: self._uri = WriteableSSKFileURI(self._writekey, self._fingerprint) @@ -723,7 +723,7 @@ class MutableFileVersion: overwrite or modify the contents of the mutable file that I reference. """ - implements(IMutableFileVersion, IWritable) + implements(IMutableFileVersion, IWriteable) def __init__(self, node, diff --git a/src/allmydata/nodemaker.py b/src/allmydata/nodemaker.py index fbf527c2..b70ed601 100644 --- a/src/allmydata/nodemaker.py +++ b/src/allmydata/nodemaker.py @@ -97,7 +97,7 @@ class NodeMaker: if isinstance(cap, uri.CHKFileVerifierURI): return self._create_immutable_verifier(cap) if isinstance(cap, (uri.ReadonlySSKFileURI, uri.WriteableSSKFileURI, - uri.WritableMDMFFileURI, uri.ReadonlyMDMFFileURI)): + uri.WriteableMDMFFileURI, uri.ReadonlyMDMFFileURI)): return self._create_mutable(cap) if isinstance(cap, (uri.DirectoryURI, uri.ReadonlyDirectoryURI, diff --git a/src/allmydata/test/common.py b/src/allmydata/test/common.py index 61cb1dc3..1e29f0d5 100644 --- a/src/allmydata/test/common.py +++ b/src/allmydata/test/common.py @@ -223,11 +223,11 @@ class FakeMutableFileNode: def init_from_cap(self, filecap): assert isinstance(filecap, (uri.WriteableSSKFileURI, uri.ReadonlySSKFileURI, - uri.WritableMDMFFileURI, + uri.WriteableMDMFFileURI, uri.ReadonlyMDMFFileURI)) self.my_uri = filecap self.storage_index = self.my_uri.get_storage_index() - if isinstance(filecap, (uri.WritableMDMFFileURI, + if isinstance(filecap, (uri.WriteableMDMFFileURI, uri.ReadonlyMDMFFileURI)): self.file_types[self.storage_index] = MDMF_VERSION @@ -384,7 +384,7 @@ class FakeMutableFileNode: def get_best_mutable_version(self): return defer.succeed(self) - # Ditto for this, which is an implementation of IWritable. + # Ditto for this, which is an implementation of IWriteable. # XXX: Declare that the same is implemented. def update(self, data, offset): assert not self.is_readonly() @@ -408,7 +408,7 @@ def make_mutable_file_cap(): fingerprint=os.urandom(32)) def make_mdmf_mutable_file_cap(): - return uri.WritableMDMFFileURI(writekey=os.urandom(16), + return uri.WriteableMDMFFileURI(writekey=os.urandom(16), fingerprint=os.urandom(32)) def make_mutable_file_uri(mdmf=False): diff --git a/src/allmydata/test/test_mutable.py b/src/allmydata/test/test_mutable.py index deb4a58c..e6eea1ee 100644 --- a/src/allmydata/test/test_mutable.py +++ b/src/allmydata/test/test_mutable.py @@ -344,7 +344,7 @@ class Filenode(unittest.TestCase, testutil.ShouldFailMixin): def _created(n): self.failUnless(isinstance(n, MutableFileNode)) cap = n.get_cap() - self.failUnless(isinstance(cap, uri.WritableMDMFFileURI)) + self.failUnless(isinstance(cap, uri.WriteableMDMFFileURI)) rcap = n.get_readcap() self.failUnless(isinstance(rcap, uri.ReadonlyMDMFFileURI)) vcap = n.get_verify_cap() @@ -3039,7 +3039,7 @@ class Version(GridTestMixin, unittest.TestCase, testutil.ShouldFailMixin, \ # That's essentially what MDMF node is, so just check that. mdmf_uri = self.mdmf_node.get_uri() cap = uri.from_string(mdmf_uri) - self.failUnless(isinstance(cap, uri.WritableMDMFFileURI)) + self.failUnless(isinstance(cap, uri.WriteableMDMFFileURI)) readonly_mdmf_uri = self.mdmf_node.get_readonly_uri() cap = uri.from_string(readonly_mdmf_uri) self.failUnless(isinstance(cap, uri.ReadonlyMDMFFileURI)) diff --git a/src/allmydata/test/test_uri.py b/src/allmydata/test/test_uri.py index 27b98534..e1bb7d71 100644 --- a/src/allmydata/test/test_uri.py +++ b/src/allmydata/test/test_uri.py @@ -348,9 +348,9 @@ class Mutable(testutil.ReallyEqualMixin, unittest.TestCase): def test_writable_mdmf_cap(self): - u1 = uri.WritableMDMFFileURI(self.writekey, self.fingerprint) + u1 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint) cap = u1.to_string() - u = uri.WritableMDMFFileURI.init_from_string(cap) + u = uri.WriteableMDMFFileURI.init_from_string(cap) self.failUnless(IMutableFileURI.providedBy(u)) self.failUnlessReallyEqual(u.fingerprint, self.fingerprint) @@ -393,14 +393,14 @@ class Mutable(testutil.ReallyEqualMixin, unittest.TestCase): u1 = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint) cap = u1.to_string() self.failUnlessRaises(uri.BadURIError, - uri.WritableMDMFFileURI.init_from_string, + uri.WriteableMDMFFileURI.init_from_string, cap) def test_create_writable_mdmf_cap_from_verifycap(self): u1 = uri.MDMFVerifierURI(self.storage_index, self.fingerprint) cap = u1.to_string() self.failUnlessRaises(uri.BadURIError, - uri.WritableMDMFFileURI.init_from_string, + uri.WriteableMDMFFileURI.init_from_string, cap) def test_create_readonly_mdmf_cap_from_verifycap(self): @@ -433,7 +433,7 @@ class Mutable(testutil.ReallyEqualMixin, unittest.TestCase): def test_mdmf_cap_extra_information(self): # MDMF caps can be arbitrarily extended after the fingerprint # and key/storage index fields. - u1 = uri.WritableMDMFFileURI(self.writekey, self.fingerprint) + u1 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint) self.failUnlessEqual([], u1.get_extension_params()) cap = u1.to_string() @@ -444,14 +444,14 @@ class Mutable(testutil.ReallyEqualMixin, unittest.TestCase): cap += (":%s" % e) expected_extensions.append(e) - u2 = uri.WritableMDMFFileURI.init_from_string(cap) + u2 = uri.WriteableMDMFFileURI.init_from_string(cap) self.failUnlessReallyEqual(self.writekey, u2.writekey) self.failUnlessReallyEqual(self.fingerprint, u2.fingerprint) self.failIf(u2.is_readonly()) self.failUnless(u2.is_mutable()) c2 = u2.to_string() - u2n = uri.WritableMDMFFileURI.init_from_string(c2) + u2n = uri.WriteableMDMFFileURI.init_from_string(c2) self.failUnlessReallyEqual(u2, u2n) # We should get the extra back when we ask for it. @@ -496,11 +496,11 @@ class Mutable(testutil.ReallyEqualMixin, unittest.TestCase): def test_extension_character_range(self): # As written now, we shouldn't put things other than numbers in # the extension fields. - writecap = uri.WritableMDMFFileURI(self.writekey, self.fingerprint).to_string() + writecap = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint).to_string() readcap = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint).to_string() vcap = uri.MDMFVerifierURI(self.storage_index, self.fingerprint).to_string() self.failUnlessRaises(uri.BadURIError, - uri.WritableMDMFFileURI.init_from_string, + uri.WriteableMDMFFileURI.init_from_string, ("%s:invalid" % writecap)) self.failUnlessRaises(uri.BadURIError, uri.ReadonlyMDMFFileURI.init_from_string, @@ -516,8 +516,8 @@ class Mutable(testutil.ReallyEqualMixin, unittest.TestCase): # With a cap on the end. For each of the cap types, we need to # test that a valid cap (with and without the traditional # separators) is recognized and accepted by the classes. - w1 = uri.WritableMDMFFileURI(self.writekey, self.fingerprint) - w2 = uri.WritableMDMFFileURI(self.writekey, self.fingerprint, + w1 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint) + w2 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint, ['131073', '3']) r1 = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint) r2 = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint, @@ -549,8 +549,8 @@ class Mutable(testutil.ReallyEqualMixin, unittest.TestCase): # With a cap on the end. For each of the cap types, we need to # test that a valid cap (with and without the traditional # separators) is recognized and accepted by the classes. - w1 = uri.WritableMDMFFileURI(self.writekey, self.fingerprint) - w2 = uri.WritableMDMFFileURI(self.writekey, self.fingerprint, + w1 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint) + w2 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint, ['131073', '3']) r1 = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint) r2 = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint, @@ -571,8 +571,8 @@ class Mutable(testutil.ReallyEqualMixin, unittest.TestCase): # With a cap on the end. For each of the cap types, we need to # test that a valid cap (with and without the traditional # separators) is recognized and accepted by the classes. - w1 = uri.WritableMDMFFileURI(self.writekey, self.fingerprint) - w2 = uri.WritableMDMFFileURI(self.writekey, self.fingerprint, + w1 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint) + w2 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint, ['131073', '3']) r1 = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint) r2 = uri.ReadonlyMDMFFileURI(self.readkey, self.fingerprint, @@ -595,7 +595,7 @@ class Mutable(testutil.ReallyEqualMixin, unittest.TestCase): def test_mdmf_from_string(self): # Make sure that the from_string utility function works with # MDMF caps. - u1 = uri.WritableMDMFFileURI(self.writekey, self.fingerprint) + u1 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint) cap = u1.to_string() self.failUnless(uri.is_uri(cap)) u2 = uri.from_string(cap) @@ -604,7 +604,7 @@ class Mutable(testutil.ReallyEqualMixin, unittest.TestCase): self.failUnlessEqual(u3, u1) # XXX: We should refactor the extension field into setUp - u1 = uri.WritableMDMFFileURI(self.writekey, self.fingerprint, + u1 = uri.WriteableMDMFFileURI(self.writekey, self.fingerprint, ['131073', '3']) cap = u1.to_string() self.failUnless(uri.is_uri(cap)) @@ -795,7 +795,7 @@ class Dirnode(testutil.ReallyEqualMixin, unittest.TestCase): def test_mdmf(self): writekey = "\x01" * 16 fingerprint = "\x02" * 32 - uri1 = uri.WritableMDMFFileURI(writekey, fingerprint) + uri1 = uri.WriteableMDMFFileURI(writekey, fingerprint) d1 = uri.MDMFDirectoryURI(uri1) self.failIf(d1.is_readonly()) self.failUnless(d1.is_mutable()) @@ -819,7 +819,7 @@ class Dirnode(testutil.ReallyEqualMixin, unittest.TestCase): def test_mdmf_with_extensions(self): writekey = "\x01" * 16 fingerprint = "\x02" * 32 - uri1 = uri.WritableMDMFFileURI(writekey, fingerprint) + uri1 = uri.WriteableMDMFFileURI(writekey, fingerprint) d1 = uri.MDMFDirectoryURI(uri1) d1_uri = d1.to_string() # Add some extensions, verify that the URI is interpreted @@ -849,7 +849,7 @@ class Dirnode(testutil.ReallyEqualMixin, unittest.TestCase): writekey = "\x01" * 16 fingerprint = "\x02" * 32 - uri1 = uri.WritableMDMFFileURI(writekey, fingerprint) + uri1 = uri.WriteableMDMFFileURI(writekey, fingerprint) d1 = uri.MDMFDirectoryURI(uri1) self.failUnless(d1.is_mutable()) self.failIf(d1.is_readonly()) @@ -889,7 +889,7 @@ class Dirnode(testutil.ReallyEqualMixin, unittest.TestCase): # I'm not sure what I want to write here yet. writekey = "\x01" * 16 fingerprint = "\x02" * 32 - uri1 = uri.WritableMDMFFileURI(writekey, fingerprint) + uri1 = uri.WriteableMDMFFileURI(writekey, fingerprint) d1 = uri.MDMFDirectoryURI(uri1) v1 = d1.get_verify_cap() self.failUnlessIsInstance(v1, uri.MDMFDirectoryURIVerifier) diff --git a/src/allmydata/uri.py b/src/allmydata/uri.py index cd3e7dc3..d9d87354 100644 --- a/src/allmydata/uri.py +++ b/src/allmydata/uri.py @@ -410,7 +410,7 @@ class SSKVerifierURI(_BaseURI): def set_extension_params(self, params): pass -class WritableMDMFFileURI(_BaseURI): +class WriteableMDMFFileURI(_BaseURI): implements(IURI, IMutableFileURI) BASE_STRING='URI:MDMF:' @@ -753,7 +753,7 @@ class MDMFDirectoryURI(_DirectoryBaseURI): BASE_STRING='URI:DIR2-MDMF:' BASE_STRING_RE=re.compile('^'+BASE_STRING) BASE_HUMAN_RE=re.compile('^'+OPTIONALHTTPLEAD+'URI'+SEP+'DIR2-MDMF'+SEP) - INNER_URI_CLASS=WritableMDMFFileURI + INNER_URI_CLASS=WriteableMDMFFileURI def __init__(self, filenode_uri=None): if filenode_uri: @@ -801,7 +801,7 @@ def wrap_dirnode_cap(filecap): return ImmutableDirectoryURI(filecap) if isinstance(filecap, LiteralFileURI): return LiteralDirectoryURI(filecap) - if isinstance(filecap, WritableMDMFFileURI): + if isinstance(filecap, WriteableMDMFFileURI): return MDMFDirectoryURI(filecap) if isinstance(filecap, ReadonlyMDMFFileURI): return ReadonlyMDMFDirectoryURI(filecap) @@ -913,7 +913,7 @@ def from_string(u, deep_immutable=False, name=u""): elif s.startswith('URI:SSK-Verifier:'): return SSKVerifierURI.init_from_string(s) elif s.startswith('URI:MDMF:'): - return WritableMDMFFileURI.init_from_string(s) + return WriteableMDMFFileURI.init_from_string(s) elif s.startswith('URI:MDMF-RO:'): return ReadonlyMDMFFileURI.init_from_string(s) elif s.startswith('URI:MDMF-Verifier:'):