Răsfoiți Sursa

Applied pyflakes & pep8

Taddeus Kroes 12 ani în urmă
părinte
comite
b561904233
3 a modificat fișierele cu 9 adăugiri și 10 ștergeri
  1. 1 1
      connection.py
  2. 2 4
      frame.py
  3. 6 5
      websocket.py

+ 1 - 1
connection.py

@@ -146,7 +146,7 @@ class Connection(object):
             frame = self.sock.recv()
             frame = self.sock.recv()
 
 
             if frame.opcode != OPCODE_CLOSE:
             if frame.opcode != OPCODE_CLOSE:
-                raise ValueError('expected CLOSE frame, got %s instead' % frame)
+                raise ValueError('expected CLOSE frame, got %s' % frame)
 
 
             res_code, res_reason = frame.unpack_close()
             res_code, res_reason = frame.unpack_close()
 
 

+ 2 - 4
frame.py

@@ -3,8 +3,6 @@ import socket
 from os import urandom
 from os import urandom
 from string import printable
 from string import printable
 
 
-from errors import SocketClosed
-
 
 
 OPCODE_CONTINUATION = 0x0
 OPCODE_CONTINUATION = 0x0
 OPCODE_TEXT = 0x1
 OPCODE_TEXT = 0x1
@@ -154,7 +152,7 @@ class Frame(object):
         pl = printstr(self.payload)[:max_pl_disp]
         pl = printstr(self.payload)[:max_pl_disp]
 
 
         if len(self.payload) > max_pl_disp:
         if len(self.payload) > max_pl_disp:
-             pl += '...'
+            pl += '...'
 
 
         return s + ' payload=%s>' % pl
         return s + ' payload=%s>' % pl
 
 
@@ -176,7 +174,7 @@ class ControlFrame(Frame):
         125 bytes.
         125 bytes.
         """
         """
         if len(self.payload) > 125:
         if len(self.payload) > 125:
-            raise ValueError('control frames must not be larger than 125' \
+            raise ValueError('control frames must not be larger than 125 '
                              'bytes')
                              'bytes')
 
 
         return Frame.pack(self)
         return Frame.pack(self)

+ 6 - 5
websocket.py

@@ -42,8 +42,8 @@ class websocket(object):
     >>> sock.connect(('', 8000))
     >>> sock.connect(('', 8000))
     >>> sock.send(twspy.Frame(twspy.OPCODE_TEXT, 'Hello, Server!'))
     >>> sock.send(twspy.Frame(twspy.OPCODE_TEXT, 'Hello, Server!'))
     """
     """
-    def __init__(self, sock=None, protocols=[], extensions=[], sfamily=socket.AF_INET,
-                 sproto=0):
+    def __init__(self, sock=None, protocols=[], extensions=[],
+                 sfamily=socket.AF_INET, sproto=0):
         """
         """
         Create a regular TCP socket of family `family` and protocol
         Create a regular TCP socket of family `family` and protocol
 
 
@@ -251,10 +251,12 @@ class websocket(object):
             # Request protocols and extension, these are later checked with the
             # Request protocols and extension, these are later checked with the
             # actual supported values from the server's response
             # actual supported values from the server's response
             if self.protocols:
             if self.protocols:
-                shake += 'Sec-WebSocket-Protocol: %s\r\n' % ', '.join(self.protocols)
+                shake += 'Sec-WebSocket-Protocol: %s\r\n' \
+                         % ', '.join(self.protocols)
 
 
             if self.extensions:
             if self.extensions:
-                shake += 'Sec-WebSocket-Extensions: %s\r\n' % ', '.join(self.extensions)
+                shake += 'Sec-WebSocket-Extensions: %s\r\n' \
+                         % ', '.join(self.extensions)
 
 
             if auth:
             if auth:
                 shake += 'Authorization: %s\r\n' % auth
                 shake += 'Authorization: %s\r\n' % auth
@@ -351,7 +353,6 @@ class websocket(object):
         self.handshake_started = True
         self.handshake_started = True
         receive_response(send_request(location))
         receive_response(send_request(location))
 
 
-
     def enable_ssl(self, *args, **kwargs):
     def enable_ssl(self, *args, **kwargs):
         """
         """
         Transforms the regular socket.socket to an ssl.SSLSocket for secure
         Transforms the regular socket.socket to an ssl.SSLSocket for secure