From: Brian Warner Date: Fri, 20 Nov 2009 07:22:39 +0000 (-0800) Subject: class name cleanups: s/FileNode/ImmutableFileNode/ X-Git-Url: https://git.rkrishnan.org/pf/content/%22news.html/frontends/provisioning?a=commitdiff_plain;h=d2badbea78376bc948666c445c36f3780eb6ec9b;p=tahoe-lafs%2Ftahoe-lafs.git class name cleanups: s/FileNode/ImmutableFileNode/ also fix test/bench_dirnode.py for recent dirnode changes --- diff --git a/src/allmydata/immutable/filenode.py b/src/allmydata/immutable/filenode.py index fbc4adb7..3b239687 100644 --- a/src/allmydata/immutable/filenode.py +++ b/src/allmydata/immutable/filenode.py @@ -72,9 +72,9 @@ class DownloadCache: self.cachefile = None self.download_in_progress = False # five states: - # new FileNode, no downloads ever performed - # new FileNode, leftover file (partial) - # new FileNode, leftover file (whole) + # new ImmutableFileNode, no downloads ever performed + # new ImmutableFileNode, leftover file (partial) + # new ImmutableFileNode, leftover file (whole) # download in progress, not yet complete # download complete @@ -178,7 +178,7 @@ class DownloadCache: pass -class FileNode(_ImmutableFileNodeBase, log.PrefixingLogMixin): +class ImmutableFileNode(_ImmutableFileNodeBase, log.PrefixingLogMixin): def __init__(self, filecap, storage_broker, secret_holder, downloader, history, cachedirectorymanager): assert isinstance(filecap, CHKFileURI) diff --git a/src/allmydata/interfaces.py b/src/allmydata/interfaces.py index 2366d864..38427bdf 100644 --- a/src/allmydata/interfaces.py +++ b/src/allmydata/interfaces.py @@ -956,9 +956,9 @@ class IDirectoryNode(IMutableFilesystemNode): def add_file(name, uploadable, metadata=None, overwrite=True): """I upload a file (using the given IUploadable), then attach the - resulting FileNode to the directory at the given name. I set metadata - the same way as set_uri and set_node. The child name must be a - unicode string. + resulting ImmutableFileNode to the directory at the given name. I set + metadata the same way as set_uri and set_node. The child name must be + a unicode string. I return a Deferred that fires (with the IFileNode of the uploaded file) when the operation completes.""" @@ -2069,7 +2069,7 @@ class IClient(Interface): @return: an instance that provides IFilesystemNode (or more usefully one of its subclasses). File-specifying URIs will result in IFileNode or IMutableFileNode -providing instances, like - FileNode, LiteralFileNode, or MutableFileNode. + ImmutableFileNode, LiteralFileNode, or MutableFileNode. Directory-specifying URIs will result in IDirectoryNode-providing instances, like DirectoryNode. """ diff --git a/src/allmydata/nodemaker.py b/src/allmydata/nodemaker.py index db49d362..495070f9 100644 --- a/src/allmydata/nodemaker.py +++ b/src/allmydata/nodemaker.py @@ -2,7 +2,7 @@ import weakref from zope.interface import implements from allmydata.util.assertutil import precondition from allmydata.interfaces import INodeMaker, NotDeepImmutableError -from allmydata.immutable.filenode import FileNode, LiteralFileNode +from allmydata.immutable.filenode import ImmutableFileNode, LiteralFileNode from allmydata.immutable.upload import Data from allmydata.mutable.filenode import MutableFileNode from allmydata.dirnode import DirectoryNode, pack_children @@ -33,9 +33,9 @@ class NodeMaker: def _create_lit(self, cap): return LiteralFileNode(cap) def _create_immutable(self, cap): - return FileNode(cap, self.storage_broker, self.secret_holder, - self.downloader, self.history, - self.download_cache_dirman) + return ImmutableFileNode(cap, self.storage_broker, self.secret_holder, + self.downloader, self.history, + self.download_cache_dirman) def _create_mutable(self, cap): n = MutableFileNode(self.storage_broker, self.secret_holder, self.default_encoding_parameters, diff --git a/src/allmydata/test/bench_dirnode.py b/src/allmydata/test/bench_dirnode.py index 06928c43..e5a47f80 100644 --- a/src/allmydata/test/bench_dirnode.py +++ b/src/allmydata/test/bench_dirnode.py @@ -2,14 +2,17 @@ import hotshot.stats, os, random, sys from pyutil import benchutil, randutil # http://allmydata.org/trac/pyutil +from zope.interface import implements from allmydata import dirnode, uri -from allmydata.mutable import filenode as mut_filenode -from allmydata.immutable import filenode as immut_filenode +from allmydata.interfaces import IFileNode +from allmydata.mutable.filenode import MutableFileNode +from allmydata.immutable.filenode import ImmutableFileNode children = [] # tuples of (k, v) (suitable for passing to dict()) packstr = None class ContainerNode: + implements(IFileNode) # dirnodes sit on top of a "container" filenode, from which it extracts a # writekey def __init__(self): @@ -18,6 +21,8 @@ class ContainerNode: self._cap = uri.WriteableSSKFileURI(self._writekey, self._fingerprint) def get_writekey(self): return self._writekey + def get_cap(self): + return self._cap def get_uri(self): return self._cap.to_string() def is_readonly(self): @@ -45,17 +50,17 @@ def random_fsnode(): random.randrange(1, 5), random.randrange(6, 15), random.randrange(99, 1000000000000)) - return immut_filenode.FileNode(cap, None, None, None, None, None) + return ImmutableFileNode(cap, None, None, None, None, None) elif coin == 1: cap = uri.WriteableSSKFileURI(randutil.insecurerandstr(16), randutil.insecurerandstr(32)) - n = mut_filenode.MutableFileNode(None, None, encoding_parameters, None) + n = MutableFileNode(None, None, encoding_parameters, None) return n.init_from_cap(cap) else: assert coin == 2 cap = uri.WriteableSSKFileURI(randutil.insecurerandstr(16), randutil.insecurerandstr(32)) - n = mut_filenode.MutableFileNode(None, None, encoding_parameters, None) + n = MutableFileNode(None, None, encoding_parameters, None) n.init_from_cap(cap) return dirnode.DirectoryNode(n, nodemaker, uploader=None) diff --git a/src/allmydata/test/test_filenode.py b/src/allmydata/test/test_filenode.py index 24aaa70a..feeda226 100644 --- a/src/allmydata/test/test_filenode.py +++ b/src/allmydata/test/test_filenode.py @@ -2,7 +2,8 @@ from twisted.trial import unittest from allmydata import uri, client from allmydata.monitor import Monitor -from allmydata.immutable import filenode, download +from allmydata.immutable import download +from allmydata.immutable.filenode import ImmutableFileNode, LiteralFileNode from allmydata.mutable.filenode import MutableFileNode from allmydata.util import hashutil, cachedir from allmydata.test.common import download_to_data @@ -32,8 +33,8 @@ class Node(unittest.TestCase): size=1000) c = FakeClient() cf = cachedir.CacheFile("none") - fn1 = filenode.FileNode(u, None, None, None, None, cf) - fn2 = filenode.FileNode(u, None, None, None, None, cf) + fn1 = ImmutableFileNode(u, None, None, None, None, cf) + fn2 = ImmutableFileNode(u, None, None, None, None, cf) self.failUnlessEqual(fn1, fn2) self.failIfEqual(fn1, "I am not a filenode") self.failIfEqual(fn1, NotANode()) @@ -56,8 +57,8 @@ class Node(unittest.TestCase): DATA = "I am a short file." u = uri.LiteralFileURI(data=DATA) c = None - fn1 = filenode.LiteralFileNode(u) - fn2 = filenode.LiteralFileNode(u) + fn1 = LiteralFileNode(u) + fn2 = LiteralFileNode(u) self.failUnlessEqual(fn1, fn2) self.failIfEqual(fn1, "I am not a filenode") self.failIfEqual(fn1, NotANode()) @@ -151,7 +152,7 @@ class LiteralChecker(unittest.TestCase): def test_literal_filenode(self): DATA = "I am a short file." u = uri.LiteralFileURI(data=DATA) - fn1 = filenode.LiteralFileNode(u) + fn1 = LiteralFileNode(u) d = fn1.check(Monitor()) def _check_checker_results(cr): diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index 6fd99a14..423657db 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -11,7 +11,8 @@ import allmydata from allmydata import uri from allmydata.storage.mutable import MutableShareFile from allmydata.storage.server import si_a2b -from allmydata.immutable import download, filenode, offloaded, upload +from allmydata.immutable import download, offloaded, upload +from allmydata.immutable.filenode import ImmutableFileNode, LiteralFileNode from allmydata.util import idlib, mathutil from allmydata.util import log, base32 from allmydata.scripts import runner @@ -1770,7 +1771,7 @@ class SystemTest(SystemTestMixin, unittest.TestCase): d.addCallback(lambda res: self._personal_node.get(u"big file")) def _got_chk_filenode(n): - self.failUnless(isinstance(n, filenode.FileNode)) + self.failUnless(isinstance(n, ImmutableFileNode)) d = n.check(Monitor()) def _check_filenode_results(r): self.failUnless(r.is_healthy()) @@ -1782,7 +1783,7 @@ class SystemTest(SystemTestMixin, unittest.TestCase): d.addCallback(lambda res: self._personal_node.get(u"sekrit data")) def _got_lit_filenode(n): - self.failUnless(isinstance(n, filenode.LiteralFileNode)) + self.failUnless(isinstance(n, LiteralFileNode)) d = n.check(Monitor()) def _check_lit_filenode_results(r): self.failUnlessEqual(r, None)