BIND 10 trac1427, updated. e7019de8a8ec9ff562557c9fc2a0bd28a4c64829 [1427] Style fixes

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Dec 2 11:54:17 UTC 2011


The branch, trac1427 has been updated
       via  e7019de8a8ec9ff562557c9fc2a0bd28a4c64829 (commit)
      from  9300ad5a1030e50ab76ff8a6f87b4d91d2d2b124 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e7019de8a8ec9ff562557c9fc2a0bd28a4c64829
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Dec 2 12:54:03 2011 +0100

    [1427] Style fixes

-----------------------------------------------------------------------

Summary of changes:
 src/lib/python/isc/bind10/socket_cache.py          |   15 ++++----
 .../python/isc/bind10/tests/socket_cache_test.py   |   37 +++++++++++---------
 2 files changed, 28 insertions(+), 24 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/bind10/socket_cache.py b/src/lib/python/isc/bind10/socket_cache.py
index 9ce4873..d7a1ae1 100644
--- a/src/lib/python/isc/bind10/socket_cache.py
+++ b/src/lib/python/isc/bind10/socket_cache.py
@@ -20,6 +20,7 @@ Here's the cache for sockets from socket creator.
 import os
 import random
 import isc.bind10.sockcreator
+from copy import copy
 
 class SocketError(Exception):
     """
@@ -75,7 +76,7 @@ class Socket:
         """
         os.close(self.fileno)
 
-    def shareCompatible(self, mode, name):
+    def share_compatible(self, mode, name):
         """
         Checks if the given share mode and name is compatible with the ones
         already installed here.
@@ -200,7 +201,7 @@ class Cache:
                 self._sockets[protocol][addr_str] = {}
             self._sockets[protocol][addr_str][port] = socket
         # Now we get the token, check it is compatible
-        if not socket.shareCompatible(share_mode, share_name):
+        if not socket.share_compatible(share_mode, share_name):
             raise ShareError("Cached socket not compatible with mode " +
                              share_mode + " and name " + share_name)
         # Grab yet unused token
@@ -263,19 +264,19 @@ class Cache:
         del socket.active_tokens[token]
         del self._active_tokens[token]
         self._active_apps[app].remove(token)
-        if self._active_apps[app] == set():
+        if len(self._active_apps[app]) == 0:
             del self._active_apps[app]
         self._live_tokens.remove(token)
         # The socket is not used by anything now, so remove it
-        if socket.active_tokens == {} and socket.waiting_tokens == set():
+        if len(socket.active_tokens) == 0 and len(socket.waiting_tokens) == 0:
             addr = str(socket.address)
             port = socket.port
             proto = socket.protocol
             del self._sockets[proto][addr][port]
             # Clean up empty branches of the structure
-            if self._sockets[proto][addr] == {}:
+            if len(self._sockets[proto][addr]) == 0:
                 del self._sockets[proto][addr]
-            if self._sockets[proto] == {}:
+            if len(self._sockets[proto]) == 0:
                 del self._sockets[proto]
 
     def drop_application(self, application):
@@ -291,7 +292,7 @@ class Cache:
             # Get a copy. Who knows how iteration works through sets if we
             # delete from it during the time, so we'll just have our own copy
             # to iterate
-            to_drop = set(self._active_apps[application])
+            to_drop = copy(self._active_apps[application])
         except KeyError:
             raise ValueError("Application " + str(application) +
                              " doesn't hold any sockets")
diff --git a/src/lib/python/isc/bind10/tests/socket_cache_test.py b/src/lib/python/isc/bind10/tests/socket_cache_test.py
index f3feded..bbbf776 100644
--- a/src/lib/python/isc/bind10/tests/socket_cache_test.py
+++ b/src/lib/python/isc/bind10/tests/socket_cache_test.py
@@ -84,42 +84,45 @@ class SocketTest(Test):
         modes = ['NO', 'SAMEAPP', 'ANY']
         # If there are no shares, it is compatible with everything.
         for mode in modes:
-            self.assertTrue(self.__socket.shareCompatible(mode, 'anything'))
+            self.assertTrue(self.__socket.share_compatible(mode, 'anything'))
 
         # There's an NO already, so it is incompatible with everything.
         self.__socket.shares = {'token': ('NO', 'anything')}
         for mode in modes:
-            self.assertFalse(self.__socket.shareCompatible(mode, 'anything'))
+            self.assertFalse(self.__socket.share_compatible(mode, 'anything'))
 
         # If there's SAMEAPP, it is compatible with ANY and SAMEAPP with the
         # same name.
         self.__socket.shares = {'token': ('SAMEAPP', 'app')}
-        self.assertFalse(self.__socket.shareCompatible('NO', 'app'))
-        self.assertFalse(self.__socket.shareCompatible('SAMEAPP', 'something'))
-        self.assertTrue(self.__socket.shareCompatible('SAMEAPP', 'app'))
-        self.assertTrue(self.__socket.shareCompatible('ANY', 'app'))
-        self.assertFalse(self.__socket.shareCompatible('ANY', 'something'))
+        self.assertFalse(self.__socket.share_compatible('NO', 'app'))
+        self.assertFalse(self.__socket.share_compatible('SAMEAPP',
+                                                        'something'))
+        self.assertTrue(self.__socket.share_compatible('SAMEAPP', 'app'))
+        self.assertTrue(self.__socket.share_compatible('ANY', 'app'))
+        self.assertFalse(self.__socket.share_compatible('ANY', 'something'))
 
         # If there's ANY, then ANY and SAMEAPP with the same name is compatible
         self.__socket.shares = {'token': ('ANY', 'app')}
-        self.assertFalse(self.__socket.shareCompatible('NO', 'app'))
-        self.assertFalse(self.__socket.shareCompatible('SAMEAPP', 'something'))
-        self.assertTrue(self.__socket.shareCompatible('SAMEAPP', 'app'))
-        self.assertTrue(self.__socket.shareCompatible('ANY', 'something'))
+        self.assertFalse(self.__socket.share_compatible('NO', 'app'))
+        self.assertFalse(self.__socket.share_compatible('SAMEAPP',
+                                                        'something'))
+        self.assertTrue(self.__socket.share_compatible('SAMEAPP', 'app'))
+        self.assertTrue(self.__socket.share_compatible('ANY', 'something'))
 
         # In case there are multiple already inside
         self.__socket.shares = {
             'token': ('ANY', 'app'),
             'another': ('SAMEAPP', 'app')
         }
-        self.assertFalse(self.__socket.shareCompatible('NO', 'app'))
-        self.assertFalse(self.__socket.shareCompatible('SAMEAPP', 'something'))
-        self.assertTrue(self.__socket.shareCompatible('SAMEAPP', 'app'))
-        self.assertFalse(self.__socket.shareCompatible('ANY', 'something'))
-        self.assertTrue(self.__socket.shareCompatible('ANY', 'app'))
+        self.assertFalse(self.__socket.share_compatible('NO', 'app'))
+        self.assertFalse(self.__socket.share_compatible('SAMEAPP',
+                                                        'something'))
+        self.assertTrue(self.__socket.share_compatible('SAMEAPP', 'app'))
+        self.assertFalse(self.__socket.share_compatible('ANY', 'something'))
+        self.assertTrue(self.__socket.share_compatible('ANY', 'app'))
 
         # Invalid inputs are rejected
-        self.assertRaises(ValueError, self.__socket.shareCompatible, 'bad',
+        self.assertRaises(ValueError, self.__socket.share_compatible, 'bad',
                           'bad')
 
 class SocketCacheTest(Test):




More information about the bind10-changes mailing list