From: Brian Warner Date: Fri, 17 Jul 2009 01:01:03 +0000 (-0500) Subject: rename NewDirectoryNode to DirectoryNode, NewDirectoryURI to DirectoryURI X-Git-Tag: trac-4000 X-Git-Url: https://git.rkrishnan.org/zeppelin?a=commitdiff_plain;h=531cc7899f2942c2c1a600eb5affe4ce427f9c6e;p=tahoe-lafs%2Ftahoe-lafs.git rename NewDirectoryNode to DirectoryNode, NewDirectoryURI to DirectoryURI --- diff --git a/src/allmydata/client.py b/src/allmydata/client.py index 35f55c09..6d9b2280 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -21,13 +21,13 @@ from allmydata.util import hashutil, base32, pollmixin, cachedir, log from allmydata.util.abbreviate import parse_abbreviated_size from allmydata.util.time_format import parse_duration, parse_date from allmydata.uri import LiteralFileURI, UnknownURI -from allmydata.dirnode import NewDirectoryNode +from allmydata.dirnode import DirectoryNode from allmydata.mutable.filenode import MutableFileNode from allmydata.unknown import UnknownNode from allmydata.stats import StatsProvider from allmydata.history import History -from allmydata.interfaces import IURI, INewDirectoryURI, IStatsProducer, \ - IReadonlyNewDirectoryURI, IFileURI, IMutableFileURI, RIStubClient, \ +from allmydata.interfaces import IURI, IDirectoryURI, IStatsProducer, \ + IReadonlyDirectoryURI, IFileURI, IMutableFileURI, RIStubClient, \ UnhandledCapTypeError KiB=1024 @@ -419,12 +419,12 @@ class Client(node.Node, pollmixin.PollMixin): return UnknownNode(writecap, readcap) u_s = u.to_string() if u_s not in self._node_cache: - if IReadonlyNewDirectoryURI.providedBy(u): - # new-style read-only dirnodes - node = NewDirectoryNode(self).init_from_uri(u) - elif INewDirectoryURI.providedBy(u): - # new-style dirnodes - node = NewDirectoryNode(self).init_from_uri(u) + if IReadonlyDirectoryURI.providedBy(u): + # read-only dirnodes + node = DirectoryNode(self).init_from_uri(u) + elif IDirectoryURI.providedBy(u): + # dirnodes + node = DirectoryNode(self).init_from_uri(u) elif IFileURI.providedBy(u): if isinstance(u, LiteralFileURI): node = LiteralFileNode(u, self) # LIT @@ -439,7 +439,7 @@ class Client(node.Node, pollmixin.PollMixin): def create_empty_dirnode(self): d = self.create_mutable_file() - d.addCallback(NewDirectoryNode.create_with_mutablefile, self) + d.addCallback(DirectoryNode.create_with_mutablefile, self) return d def create_mutable_file(self, contents="", keysize=None): diff --git a/src/allmydata/dirnode.py b/src/allmydata/dirnode.py index 83a96ece..b06836f3 100644 --- a/src/allmydata/dirnode.py +++ b/src/allmydata/dirnode.py @@ -18,7 +18,7 @@ from allmydata.monitor import Monitor from allmydata.util import hashutil, mathutil, base32, log from allmydata.util.assertutil import _assert, precondition from allmydata.util.netstring import netstring, split_netstring -from allmydata.uri import NewDirectoryURI, LiteralFileURI, from_string +from allmydata.uri import DirectoryURI, LiteralFileURI, from_string from pycryptopp.cipher.aes import AES class CachingDict(dict): @@ -140,7 +140,7 @@ class Adder: new_contents = self.node._pack_contents(children) return new_contents -class NewDirectoryNode: +class DirectoryNode: implements(IDirectoryNode, ICheckable, IDeepCheckable) filenode_class = MutableFileNode @@ -175,7 +175,7 @@ class NewDirectoryNode: d.addCallback(self._filenode_created) return d def _filenode_created(self, res): - self._uri = NewDirectoryURI(IMutableFileURI(self._node.get_uri())) + self._uri = DirectoryURI(IMutableFileURI(self._node.get_uri())) return self def get_size(self): diff --git a/src/allmydata/interfaces.py b/src/allmydata/interfaces.py index e2df3305..67de6165 100644 --- a/src/allmydata/interfaces.py +++ b/src/allmydata/interfaces.py @@ -467,9 +467,9 @@ class IImmutableFileURI(IFileURI): class IMutableFileURI(Interface): """I am a URI which represents a mutable filenode.""" -class INewDirectoryURI(Interface): +class IDirectoryURI(Interface): pass -class IReadonlyNewDirectoryURI(Interface): +class IReadonlyDirectoryURI(Interface): pass class CannotPackUnknownNodeError(Exception): @@ -2023,7 +2023,7 @@ class IClient(Interface): IFileNode or IMutableFileNode -providing instances, like FileNode, LiteralFileNode, or MutableFileNode. Directory-specifying URIs will result in - IDirectoryNode-providing instances, like NewDirectoryNode. + IDirectoryNode-providing instances, like DirectoryNode. """ class IClientStatus(Interface): diff --git a/src/allmydata/scripts/debug.py b/src/allmydata/scripts/debug.py index 618a556f..c85bfca3 100644 --- a/src/allmydata/scripts/debug.py +++ b/src/allmydata/scripts/debug.py @@ -430,15 +430,15 @@ def dump_uri_instance(u, nodeid, secret, out, show_header=True): print >>out, " storage index:", si_b2a(u.storage_index) print >>out, " fingerprint:", base32.b2a(u.fingerprint) - elif isinstance(u, uri.NewDirectoryURI): + elif isinstance(u, uri.DirectoryURI): if show_header: print >>out, "Directory Writeable URI:" dump_uri_instance(u._filenode_uri, nodeid, secret, out, False) - elif isinstance(u, uri.ReadonlyNewDirectoryURI): + elif isinstance(u, uri.ReadonlyDirectoryURI): if show_header: print >>out, "Directory Read-only URI:" dump_uri_instance(u._filenode_uri, nodeid, secret, out, False) - elif isinstance(u, uri.NewDirectoryURIVerifier): + elif isinstance(u, uri.DirectoryURIVerifier): if show_header: print >>out, "Directory Verifier URI:" dump_uri_instance(u._filenode_uri, nodeid, secret, out, False) diff --git a/src/allmydata/test/bench_dirnode.py b/src/allmydata/test/bench_dirnode.py index e5f969a6..df534345 100644 --- a/src/allmydata/test/bench_dirnode.py +++ b/src/allmydata/test/bench_dirnode.py @@ -25,19 +25,19 @@ class FakeMutableFileNode(mut_filenode.MutableFileNode): mut_filenode.MutableFileNode.__init__(self, client) self._uri = uri.WriteableSSKFileURI(randutil.insecurerandstr(16), randutil.insecurerandstr(32)) -class FakeDirectoryNode(dirnode.NewDirectoryNode): +class FakeDirectoryNode(dirnode.DirectoryNode): def __init__(self, client): - dirnode.NewDirectoryNode.__init__(self, client) + dirnode.DirectoryNode.__init__(self, client) mutfileuri = uri.WriteableSSKFileURI(randutil.insecurerandstr(16), randutil.insecurerandstr(32)) - myuri = uri.NewDirectoryURI(mutfileuri) + myuri = uri.DirectoryURI(mutfileuri) self.init_from_uri(myuri) children = [] # tuples of (k, v) (suitable for passing to dict()) packstr = None fakeclient = FakeClient() -testdirnode = dirnode.NewDirectoryNode(fakeclient) -testdirnode.init_from_uri(uri.NewDirectoryURI(uri.WriteableSSKFileURI(randutil.insecurerandstr(16), randutil.insecurerandstr(32)))) +testdirnode = dirnode.DirectoryNode(fakeclient) +testdirnode.init_from_uri(uri.DirectoryURI(uri.WriteableSSKFileURI(randutil.insecurerandstr(16), randutil.insecurerandstr(32)))) def random_unicode(l): while True: diff --git a/src/allmydata/test/common.py b/src/allmydata/test/common.py index 97f4bc3f..dfd88388 100644 --- a/src/allmydata/test/common.py +++ b/src/allmydata/test/common.py @@ -290,7 +290,7 @@ def make_verifier_uri(): return uri.SSKVerifierURI(storage_index=os.urandom(16), fingerprint=os.urandom(32)) -class FakeDirectoryNode(dirnode.NewDirectoryNode): +class FakeDirectoryNode(dirnode.DirectoryNode): """This offers IDirectoryNode, but uses a FakeMutableFileNode for the backing store, so it doesn't go to the grid. The child data is still encrypted and serialized, so this isn't useful for tests that want to diff --git a/src/allmydata/test/test_cli.py b/src/allmydata/test/test_cli.py index 8efccb2b..a2179a48 100644 --- a/src/allmydata/test/test_cli.py +++ b/src/allmydata/test/test_cli.py @@ -37,7 +37,7 @@ class CLI(unittest.TestCase): open("cli/test_options/node.url","w").write("http://localhost:8080/\n") filenode_uri = uri.WriteableSSKFileURI(writekey="\x00"*16, fingerprint="\x00"*32) - private_uri = uri.NewDirectoryURI(filenode_uri).to_string() + private_uri = uri.DirectoryURI(filenode_uri).to_string() open("cli/test_options/private/root_dir.cap", "w").write(private_uri + "\n") o = cli.ListOptions() o.parseOptions(["--node-directory", "cli/test_options"]) @@ -62,7 +62,7 @@ class CLI(unittest.TestCase): o = cli.ListOptions() other_filenode_uri = uri.WriteableSSKFileURI(writekey="\x11"*16, fingerprint="\x11"*32) - other_uri = uri.NewDirectoryURI(other_filenode_uri).to_string() + other_uri = uri.DirectoryURI(other_filenode_uri).to_string() o.parseOptions(["--node-directory", "cli/test_options", "--dir-cap", other_uri]) self.failUnlessEqual(o['node-url'], "http://localhost:8080/") @@ -199,7 +199,7 @@ class CLI(unittest.TestCase): writekey = "\x01" * 16 fingerprint = "\xfe" * 32 u1 = uri.WriteableSSKFileURI(writekey, fingerprint) - u = uri.NewDirectoryURI(u1) + u = uri.DirectoryURI(u1) output = self._dump_cap(u.to_string()) self.failUnless("Directory Writeable URI:" in output, output) diff --git a/src/allmydata/test/test_dirnode.py b/src/allmydata/test/test_dirnode.py index 346a1853..7ed41b2e 100644 --- a/src/allmydata/test/test_dirnode.py +++ b/src/allmydata/test/test_dirnode.py @@ -7,7 +7,7 @@ from allmydata import uri, dirnode from allmydata.client import Client from allmydata.immutable import upload from allmydata.interfaces import IURI, IClient, IMutableFileNode, \ - INewDirectoryURI, IReadonlyNewDirectoryURI, IFileNode, \ + IDirectoryURI, IReadonlyDirectoryURI, IFileNode, \ ExistingChildError, NoSuchChildError, \ IDeepCheckResults, IDeepCheckAndRepairResults, CannotPackUnknownNodeError from allmydata.mutable.filenode import MutableFileNode @@ -83,8 +83,8 @@ class FakeClient: if not u: u = readcap u = IURI(u) - if (INewDirectoryURI.providedBy(u) - or IReadonlyNewDirectoryURI.providedBy(u)): + if (IDirectoryURI.providedBy(u) + or IReadonlyDirectoryURI.providedBy(u)): return FakeDirectoryNode(self).init_from_uri(u) return Marker(u.to_string()) @@ -929,7 +929,7 @@ class UCWEingMutableFileNode(MutableFileNode): return res d.addCallback(_ucwe) return d -class UCWEingNewDirectoryNode(dirnode.NewDirectoryNode): +class UCWEingDirectoryNode(dirnode.DirectoryNode): filenode_class = UCWEingMutableFileNode @@ -957,7 +957,7 @@ class Deleter(GridTestMixin, unittest.TestCase): return dn.add_file(u"file", small) d.addCallback(_created_dir) def _do_delete(ignored): - n = UCWEingNewDirectoryNode(c0).init_from_uri(self.root_uri) + n = UCWEingDirectoryNode(c0).init_from_uri(self.root_uri) assert n._node.please_ucwe_after_next_upload == False n._node.please_ucwe_after_next_upload = True # This should succeed, not raise an exception diff --git a/src/allmydata/test/test_uri.py b/src/allmydata/test/test_uri.py index 0898530d..6dd95a29 100644 --- a/src/allmydata/test/test_uri.py +++ b/src/allmydata/test/test_uri.py @@ -185,11 +185,11 @@ class Invalid(unittest.TestCase): class Constraint(unittest.TestCase): def test_constraint(self): good="http://127.0.0.1:3456/uri/URI%3ADIR2%3Agh3l5rbvnv2333mrfvalmjfr4i%3Alz6l7u3z3b7g37s4zkdmfpx5ly4ib4m6thrpbusi6ys62qtc6mma/" - uri.NewDirectoryURI.init_from_human_encoding(good) - self.failUnlessRaises(uri.BadURIError, uri.NewDirectoryURI.init_from_string, good) + uri.DirectoryURI.init_from_human_encoding(good) + self.failUnlessRaises(uri.BadURIError, uri.DirectoryURI.init_from_string, good) bad = good + '===' - self.failUnlessRaises(uri.BadURIError, uri.NewDirectoryURI.init_from_human_encoding, bad) - self.failUnlessRaises(uri.BadURIError, uri.NewDirectoryURI.init_from_string, bad) + self.failUnlessRaises(uri.BadURIError, uri.DirectoryURI.init_from_human_encoding, bad) + self.failUnlessRaises(uri.BadURIError, uri.DirectoryURI.init_from_string, bad) fileURI = 'URI:CHK:gh3l5rbvnv2333mrfvalmjfr4i:lz6l7u3z3b7g37s4zkdmfpx5ly4ib4m6thrpbusi6ys62qtc6mma:3:10:345834' uri.CHKFileURI.init_from_string(fileURI) @@ -272,13 +272,13 @@ class NewDirnode(unittest.TestCase): fingerprint = "\x02" * 32 n = uri.WriteableSSKFileURI(writekey, fingerprint) - u1 = uri.NewDirectoryURI(n) + u1 = uri.DirectoryURI(n) self.failIf(u1.is_readonly()) self.failUnless(u1.is_mutable()) self.failUnless(IURI.providedBy(u1)) self.failIf(IFileURI.providedBy(u1)) self.failUnless(IDirnodeURI.providedBy(u1)) - self.failUnless("NewDirectoryURI" in str(u1)) + self.failUnless("DirectoryURI" in str(u1)) u1_filenode = u1.get_filenode_uri() self.failUnless(u1_filenode.is_mutable()) self.failIf(u1_filenode.is_readonly()) @@ -309,7 +309,7 @@ class NewDirnode(unittest.TestCase): u3a = uri.from_string(u3.to_string()) self.failUnlessIdentical(u3a, u3a.get_readonly()) - u4 = uri.ReadonlyNewDirectoryURI(u2._filenode_uri.get_readonly()) + u4 = uri.ReadonlyDirectoryURI(u2._filenode_uri.get_readonly()) self.failUnlessEqual(u4.to_string(), u3.to_string()) self.failUnless(u4.is_readonly()) self.failUnless(u4.is_mutable()) @@ -324,8 +324,8 @@ class NewDirnode(unittest.TestCase): verifiers = [u1.get_verify_cap(), u2.get_verify_cap(), u3.get_verify_cap(), u4.get_verify_cap(), IVerifierURI(u1.get_verify_cap().to_string()), - uri.NewDirectoryURIVerifier(n.get_verify_cap()), - uri.NewDirectoryURIVerifier(n.get_verify_cap().to_string()), + uri.DirectoryURIVerifier(n.get_verify_cap()), + uri.DirectoryURIVerifier(n.get_verify_cap().to_string()), ] for v in verifiers: self.failUnless(IVerifierURI.providedBy(v)) diff --git a/src/allmydata/test/test_web.py b/src/allmydata/test/test_web.py index f7d45da0..23de764d 100644 --- a/src/allmydata/test/test_web.py +++ b/src/allmydata/test/test_web.py @@ -18,9 +18,8 @@ from allmydata.util import fileutil, base32 from allmydata.util.assertutil import precondition from allmydata.test.common import FakeDirectoryNode, FakeCHKFileNode, \ FakeMutableFileNode, create_chk_filenode, WebErrorMixin, ShouldFailMixin -from allmydata.interfaces import IURI, INewDirectoryURI, \ - IReadonlyNewDirectoryURI, IFileURI, IMutableFileURI, IMutableFileNode, \ - UnhandledCapTypeError +from allmydata.interfaces import IURI, IDirectoryURI, IReadonlyDirectoryURI, \ + IFileURI, IMutableFileURI, IMutableFileNode, UnhandledCapTypeError from allmydata.mutable import servermap, publish, retrieve import common_util as testutil from allmydata.test.no_network import GridTestMixin @@ -70,8 +69,7 @@ class FakeClient(service.MultiService): auri = readcap precondition(isinstance(auri, str), auri) u = uri.from_string(auri) - if (INewDirectoryURI.providedBy(u) - or IReadonlyNewDirectoryURI.providedBy(u)): + if (IDirectoryURI.providedBy(u) or IReadonlyDirectoryURI.providedBy(u)): return FakeDirectoryNode(self).init_from_uri(u) if IFileURI.providedBy(u): return FakeCHKFileNode(u, self) @@ -1868,7 +1866,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, unittest.TestCase): def test_POST_mkdir_no_parentdir_noredirect(self): d = self.POST("/uri?t=mkdir") def _after_mkdir(res): - uri.NewDirectoryURI.init_from_string(res) + uri.DirectoryURI.init_from_string(res) d.addCallback(_after_mkdir) return d diff --git a/src/allmydata/uri.py b/src/allmydata/uri.py index b37ea8ca..43aafc5a 100644 --- a/src/allmydata/uri.py +++ b/src/allmydata/uri.py @@ -5,7 +5,7 @@ from twisted.python.components import registerAdapter from allmydata.storage.server import si_a2b, si_b2a from allmydata.util import base32, hashutil from allmydata.interfaces import IURI, IDirnodeURI, IFileURI, IImmutableFileURI, \ - IVerifierURI, IMutableFileURI, INewDirectoryURI, IReadonlyNewDirectoryURI + IVerifierURI, IMutableFileURI, IDirectoryURI, IReadonlyDirectoryURI class BadURIError(Exception): pass @@ -330,7 +330,7 @@ class SSKVerifierURI(_BaseURI): return 'URI:SSK-Verifier:%s:%s' % (si_b2a(self.storage_index), base32.b2a(self.fingerprint)) -class _NewDirectoryBaseURI(_BaseURI): +class _DirectoryBaseURI(_BaseURI): implements(IURI, IDirnodeURI) def __init__(self, filenode_uri=None): self._filenode_uri = filenode_uri @@ -379,13 +379,13 @@ class _NewDirectoryBaseURI(_BaseURI): return True def get_verify_cap(self): - return NewDirectoryURIVerifier(self._filenode_uri.get_verify_cap()) + return DirectoryURIVerifier(self._filenode_uri.get_verify_cap()) def get_storage_index(self): return self._filenode_uri.get_storage_index() -class NewDirectoryURI(_NewDirectoryBaseURI): - implements(INewDirectoryURI) +class DirectoryURI(_DirectoryBaseURI): + implements(IDirectoryURI) BASE_STRING='URI:DIR2:' BASE_STRING_RE=re.compile('^'+BASE_STRING) @@ -395,16 +395,16 @@ class NewDirectoryURI(_NewDirectoryBaseURI): def __init__(self, filenode_uri=None): if filenode_uri: assert not filenode_uri.is_readonly() - _NewDirectoryBaseURI.__init__(self, filenode_uri) + _DirectoryBaseURI.__init__(self, filenode_uri) def is_readonly(self): return False def get_readonly(self): - return ReadonlyNewDirectoryURI(self._filenode_uri.get_readonly()) + return ReadonlyDirectoryURI(self._filenode_uri.get_readonly()) -class ReadonlyNewDirectoryURI(_NewDirectoryBaseURI): - implements(IReadonlyNewDirectoryURI) +class ReadonlyDirectoryURI(_DirectoryBaseURI): + implements(IReadonlyDirectoryURI) BASE_STRING='URI:DIR2-RO:' BASE_STRING_RE=re.compile('^'+BASE_STRING) @@ -414,7 +414,7 @@ class ReadonlyNewDirectoryURI(_NewDirectoryBaseURI): def __init__(self, filenode_uri=None): if filenode_uri: assert filenode_uri.is_readonly() - _NewDirectoryBaseURI.__init__(self, filenode_uri) + _DirectoryBaseURI.__init__(self, filenode_uri) def is_readonly(self): return True @@ -422,7 +422,7 @@ class ReadonlyNewDirectoryURI(_NewDirectoryBaseURI): def get_readonly(self): return self -class NewDirectoryURIVerifier(_NewDirectoryBaseURI): +class DirectoryURIVerifier(_DirectoryBaseURI): implements(IVerifierURI) BASE_STRING='URI:DIR2-Verifier:' @@ -460,11 +460,11 @@ def from_string(s): elif s.startswith('URI:SSK-Verifier:'): return SSKVerifierURI.init_from_string(s) elif s.startswith('URI:DIR2:'): - return NewDirectoryURI.init_from_string(s) + return DirectoryURI.init_from_string(s) elif s.startswith('URI:DIR2-RO:'): - return ReadonlyNewDirectoryURI.init_from_string(s) + return ReadonlyDirectoryURI.init_from_string(s) elif s.startswith('URI:DIR2-Verifier:'): - return NewDirectoryURIVerifier.init_from_string(s) + return DirectoryURIVerifier.init_from_string(s) return UnknownURI(s) registerAdapter(from_string, str, IURI)