]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
stop using IURI()/etc as an adapter
authorBrian Warner <warner@lothar.com>
Wed, 11 Nov 2009 22:45:42 +0000 (14:45 -0800)
committerBrian Warner <warner@lothar.com>
Wed, 11 Nov 2009 22:45:42 +0000 (14:45 -0800)
src/allmydata/dirnode.py
src/allmydata/mutable/filenode.py
src/allmydata/test/test_dirnode.py
src/allmydata/test/test_system.py
src/allmydata/test/test_upload.py
src/allmydata/test/test_uri.py
src/allmydata/uri.py

index ad5a35d791dcc1a70d639965250a29371b206739..7357865343250ae9b2b68a2bd631ef689fdff8a2 100644 (file)
@@ -9,7 +9,7 @@ from allmydata.mutable.common import NotMutableError
 from allmydata.mutable.filenode import MutableFileNode
 from allmydata.unknown import UnknownNode
 from allmydata.interfaces import IMutableFileNode, IDirectoryNode,\
-     IFileNode, IMutableFileURI, IFilesystemNode, \
+     IFileNode, IFilesystemNode, \
      ExistingChildError, NoSuchChildError, ICheckable, IDeepCheckable, \
      CannotPackUnknownNodeError
 from allmydata.check_results import DeepCheckResults, \
@@ -187,11 +187,11 @@ class DirectoryNode:
 
     def __init__(self, filenode, nodemaker, uploader):
         self._node = filenode
-        filenode_uri = IMutableFileURI(filenode.get_uri())
-        if filenode_uri.is_readonly():
-            self._uri = ReadonlyDirectoryURI(filenode_uri)
+        filenode_cap = filenode.get_cap()
+        if filenode_cap.is_readonly():
+            self._uri = ReadonlyDirectoryURI(filenode_cap)
         else:
-            self._uri = DirectoryURI(filenode_uri)
+            self._uri = DirectoryURI(filenode_cap)
         self._nodemaker = nodemaker
         self._uploader = uploader
         self._most_recent_size = None
index 5f7f40073cfa5b54e1b3410d27d00a4e2d2b1da2..4192a8fc89ca0a72f8b47c841a6c062ccccfc3ce 100644 (file)
@@ -4,7 +4,7 @@ import random
 from zope.interface import implements
 from twisted.internet import defer, reactor
 from foolscap.api import eventually
-from allmydata.interfaces import IMutableFileNode, IMutableFileURI, \
+from allmydata.interfaces import IMutableFileNode, \
      ICheckable, ICheckResults, NotEnoughSharesError
 from allmydata.util import hashutil, log
 from allmydata.util.assertutil import precondition
@@ -193,7 +193,7 @@ class MutableFileNode:
     def get_readcap(self):
         return self._uri.get_readonly()
     def get_verify_cap(self):
-        return IMutableFileURI(self._uri).get_verify_cap()
+        return self._uri.get_verify_cap()
     def get_repair_cap(self):
         if self._uri.is_readonly():
             return None
index bfffd4ffb24d412896356474473ed37f6df2a306..2136ee6e263d5f4c3403740eb0358074ed8cdfaf 100644 (file)
@@ -894,6 +894,8 @@ class FakeMutableFile:
                (contents, type(contents))
         return contents(self)
 
+    def get_cap(self):
+        return self.uri
     def get_uri(self):
         return self.uri.to_string()
     def download_best_version(self):
index 0a563309e17eccf8bdfa553014a396d764d178af..f8fcf0ed3254a4c0ddcbd0dd20f87d73569fcced 100644 (file)
@@ -15,7 +15,7 @@ from allmydata.immutable import download, filenode, offloaded, upload
 from allmydata.util import idlib, mathutil
 from allmydata.util import log, base32
 from allmydata.scripts import runner
-from allmydata.interfaces import IDirectoryNode, IFileNode, IFileURI, \
+from allmydata.interfaces import IDirectoryNode, IFileNode, \
      NoSuchChildError, NoSharesError
 from allmydata.monitor import Monitor
 from allmydata.mutable.common import NotMutableError
@@ -725,7 +725,7 @@ class SystemTest(SystemTestMixin, unittest.TestCase):
     def mangle_uri(self, gooduri):
         # change the key, which changes the storage index, which means we'll
         # be asking about the wrong file, so nobody will have any shares
-        u = IFileURI(gooduri)
+        u = uri.from_string(gooduri)
         u2 = uri.CHKFileURI(key=self.flip_bit(u.key),
                             uri_extension_hash=u.uri_extension_hash,
                             needed_shares=u.needed_shares,
index 6399e46e3b6b619bbc75692c8cabb5ac97eaa08e..8af3487e74e7664dfcb34e7de5533bf82eb6e42b 100644 (file)
@@ -10,7 +10,7 @@ from foolscap.api import fireEventually
 import allmydata # for __full_version__
 from allmydata import uri, monitor, client
 from allmydata.immutable import upload
-from allmydata.interfaces import IFileURI, FileTooLargeError, NoSharesError, \
+from allmydata.interfaces import FileTooLargeError, NoSharesError, \
      NotEnoughSharesError
 from allmydata.util.assertutil import precondition
 from allmydata.util.deferredutil import DeferredListShouldSucceed
@@ -250,12 +250,12 @@ class GoodServer(unittest.TestCase, ShouldFailMixin):
         self.node.DEFAULT_ENCODING_PARAMETERS = p
 
     def _check_small(self, newuri, size):
-        u = IFileURI(newuri)
+        u = uri.from_string(newuri)
         self.failUnless(isinstance(u, uri.LiteralFileURI))
         self.failUnlessEqual(len(u.data), size)
 
     def _check_large(self, newuri, size):
-        u = IFileURI(newuri)
+        u = uri.from_string(newuri)
         self.failUnless(isinstance(u, uri.CHKFileURI))
         self.failUnless(isinstance(u.storage_index, str))
         self.failUnlessEqual(len(u.storage_index), 16)
@@ -380,7 +380,7 @@ class ServerErrors(unittest.TestCase, ShouldFailMixin):
         self.u.parent = self.node
 
     def _check_large(self, newuri, size):
-        u = IFileURI(newuri)
+        u = uri.from_string(newuri)
         self.failUnless(isinstance(u, uri.CHKFileURI))
         self.failUnless(isinstance(u.storage_index, str))
         self.failUnlessEqual(len(u.storage_index), 16)
@@ -468,7 +468,7 @@ class PeerSelection(unittest.TestCase):
         return DATA[:size]
 
     def _check_large(self, newuri, size):
-        u = IFileURI(newuri)
+        u = uri.from_string(newuri)
         self.failUnless(isinstance(u, uri.CHKFileURI))
         self.failUnless(isinstance(u.storage_index, str))
         self.failUnlessEqual(len(u.storage_index), 16)
index 744bd3a66b0db4d1e9c1a5eca0a08e95431c4dfb..efdbf22e920dfb189e8d30604b34faff6de34dbf 100644 (file)
@@ -92,8 +92,6 @@ class CHKFile(unittest.TestCase):
         self.failIf(u.is_mutable())
         u_ro = u.get_readonly()
         self.failUnlessIdentical(u, u_ro)
-        u1a = IFileURI(u.to_string())
-        self.failUnlessEqual(u1a, u)
         he = u.to_human_encoding()
         self.failUnlessEqual(he, "http://127.0.0.1:3456/uri/" + u.to_string())
         self.failUnlessEqual(uri.CHKFileURI.init_from_human_encoding(he), u)
@@ -207,8 +205,6 @@ class Mutable(unittest.TestCase):
         self.failUnless(IMutableFileURI.providedBy(u))
         self.failIf(IDirnodeURI.providedBy(u))
         self.failUnless("WriteableSSKFileURI" in str(u))
-        u1a = IMutableFileURI(u.to_string())
-        self.failUnlessEqual(u1a, u)
 
         he = u.to_human_encoding()
         u_h = uri.WriteableSSKFileURI.init_from_human_encoding(he)
@@ -254,9 +250,6 @@ class Mutable(unittest.TestCase):
         u5 = u4.get_verify_cap()
         self.failUnless(IVerifierURI.providedBy(u5))
         self.failUnlessEqual(u5.storage_index, u.storage_index)
-        u6 = IVerifierURI(u5.to_string())
-        self.failUnless(IVerifierURI.providedBy(u6))
-        self.failUnlessEqual(u6.storage_index, u.storage_index)
         u7 = u.get_verify_cap()
         self.failUnless(IVerifierURI.providedBy(u7))
         self.failUnlessEqual(u7.storage_index, u.storage_index)
@@ -282,8 +275,6 @@ class NewDirnode(unittest.TestCase):
         u1_filenode = u1.get_filenode_cap()
         self.failUnless(u1_filenode.is_mutable())
         self.failIf(u1_filenode.is_readonly())
-        u1a = IDirnodeURI(u1.to_string())
-        self.failUnlessEqual(u1a, u1)
 
         u2 = uri.from_string(u1.to_string())
         self.failUnlessEqual(u1.to_string(), u2.to_string())
@@ -323,9 +314,7 @@ 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.DirectoryURIVerifier(n.get_verify_cap()),
-                     uri.DirectoryURIVerifier(n.get_verify_cap().to_string()),
                      ]
         for v in verifiers:
             self.failUnless(IVerifierURI.providedBy(v))
index 531b88cad8a5487ddd6a09bee28be58957508722..dce0115fe4d9d4818a7f1f761eadada447295ea3 100644 (file)
@@ -472,7 +472,7 @@ class DirectoryURIVerifier(_DirectoryBaseURI):
 
     def __init__(self, filenode_uri=None):
         if filenode_uri:
-            filenode_uri = IVerifierURI(filenode_uri)
+            assert IVerifierURI.providedBy(filenode_uri)
         self._filenode_uri = filenode_uri
 
     def get_filenode_cap(self):