ovs.jsonrpc: Use "not X" in place of "len(X) == 0" for testing strings.
authorBen Pfaff <blp@nicira.com>
Tue, 23 Aug 2011 17:43:26 +0000 (10:43 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 24 Aug 2011 19:06:52 +0000 (12:06 -0700)
Suggested-by: Reid Price <reid@nicira.com>
python/ovs/jsonrpc.py

index 1cc36964d5a32c18da0f37e9b20390b694de9384..1cc7fb7de9f145f5f6ac4870eacf360759f630ee 100644 (file)
@@ -249,7 +249,7 @@ class Connection(object):
             return self.status, None
 
         while True:
-            if len(self.input) == 0:
+            if not self.input:
                 error, data = self.stream.recv(4096)
                 if error:
                     if error == errno.EAGAIN:
@@ -260,7 +260,7 @@ class Connection(object):
                                         % (self.name, os.strerror(error)))
                         self.error(error)
                         return self.status, None
-                elif len(data) == 0:
+                elif not data:
                     self.error(EOF)
                     return EOF, None
                 else:
@@ -321,7 +321,7 @@ class Connection(object):
         return msg
         
     def recv_wait(self, poller):
-        if self.status or len(self.input) > 0:
+        if self.status or self.input:
             poller.immediate_wake()
         else:
             self.stream.recv_wait(poller)