Eliminate 'foo if test else bar' syntax that isn't supported by Python 2.4
authordavid-sarah <david-sarah@jacaranda.org>
Fri, 29 Jan 2010 03:52:10 +0000 (19:52 -0800)
committerdavid-sarah <david-sarah@jacaranda.org>
Fri, 29 Jan 2010 03:52:10 +0000 (19:52 -0800)
src/allmydata/nodemaker.py
src/allmydata/test/test_web.py

index 8cc5052cbf5c47554a328b919540dc0846ed5917..a30efbffdb209f0c67146da4237ac245061c7fe5 100644 (file)
@@ -58,7 +58,10 @@ class NodeMaker:
 
         # The name doesn't matter for caching since it's only used in the error
         # attribute of an UnknownNode, and we don't cache those.
-        memokey = ("I" if deep_immutable else "M") + bigcap
+        if deep_immutable:
+            memokey = "I" + bigcap
+        else:
+            memokey = "M" + bigcap
         if memokey in self._node_cache:
             return self._node_cache[memokey]
         cap = uri.from_string(bigcap, deep_immutable=deep_immutable, name=name)
index 6b363c5747d11d4bb892571aa07550b04bef7b2a..6b2f9653e8a274fad3a2cda6d2b23f5d6a33b2e1 100644 (file)
@@ -3265,7 +3265,10 @@ class Grid(GridTestMixin, WebErrorMixin, unittest.TestCase, ShouldFailMixin):
             mo = re.search(r'<a href="([^"]+)">More Info</a>', res)
             info_url = mo.group(1)
             self.failUnlessEqual(info_url, "%s?t=info" % (str(name),))
-        d.addCallback(_check_directory_html, "-IMM" if immutable else "")
+        if immutable:
+            d.addCallback(_check_directory_html, "-IMM")
+        else:
+            d.addCallback(_check_directory_html, "")
 
         d.addCallback(lambda ign: self.GET(self.rooturl+"?t=json"))
         def _check_directory_json(res, expect_rw_uri):
@@ -3277,8 +3280,10 @@ class Grid(GridTestMixin, WebErrorMixin, unittest.TestCase, ShouldFailMixin):
                 self.failUnlessEqual(f[1]["rw_uri"], future_write_uri)
             else:
                 self.failIfIn("rw_uri", f[1])
-            self.failUnlessEqual(f[1]["ro_uri"],
-                                 ("imm." if immutable else "ro.") + future_read_uri)
+            if immutable:
+                self.failUnlessEqual(f[1]["ro_uri"], "imm." + future_read_uri)
+            else:
+                self.failUnlessEqual(f[1]["ro_uri"], "ro." + future_read_uri)
             self.failUnless("metadata" in f[1])
         d.addCallback(_check_directory_json, expect_rw_uri=not immutable)
 
@@ -3311,8 +3316,17 @@ class Grid(GridTestMixin, WebErrorMixin, unittest.TestCase, ShouldFailMixin):
                 self.failUnlessEqual(data[1]["rw_uri"], future_write_uri)
             else:
                 self.failIfIn("rw_uri", data[1])
-            self.failUnlessEqual(data[1]["ro_uri"],
-                                 ("imm." if immutable else "ro.") + future_read_uri)
+
+            if immutable:
+                self.failUnlessEqual(data[1]["ro_uri"], "imm." + future_read_uri)
+                self.failUnlessEqual(data[1]["mutable"], False)
+            elif expect_rw_uri:
+                self.failUnlessEqual(data[1]["ro_uri"], "ro." + future_read_uri)
+                self.failUnlessEqual(data[1]["mutable"], True)
+            else:
+                self.failUnlessEqual(data[1]["ro_uri"], "ro." + future_read_uri)
+                self.failIf("mutable" in data[1], data[1])
+
             # TODO: check metadata contents
             self.failUnless("metadata" in data[1])
 
@@ -3323,7 +3337,11 @@ class Grid(GridTestMixin, WebErrorMixin, unittest.TestCase, ShouldFailMixin):
         # rendered too. This version will not have future_write_uri, whether
         # or not future_node was immutable.
         d.addCallback(lambda ign: self.GET(self.rourl))
-        d.addCallback(_check_directory_html, "-IMM" if immutable else "-RO")
+        if immutable:
+            d.addCallback(_check_directory_html, "-IMM")
+        else:
+            d.addCallback(_check_directory_html, "-RO")
+
         d.addCallback(lambda ign: self.GET(self.rourl+"?t=json"))
         d.addCallback(_check_directory_json, expect_rw_uri=False)