From 9ebe59b5d7768b250ec517908cbc6cdabfe85707 Mon Sep 17 00:00:00 2001 From: Allan Lewis Date: Wed, 27 Apr 2016 12:08:03 +0100 Subject: [PATCH] _abnf, _app, _http, _url: [PEP 8] Fix indents --- websocket/_abnf.py | 6 +++--- websocket/_app.py | 17 +++++++++-------- websocket/_handshake.py | 2 +- websocket/_http.py | 4 ++-- websocket/_url.py | 5 +++-- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/websocket/_abnf.py b/websocket/_abnf.py index 5f6c206..476bd4d 100644 --- a/websocket/_abnf.py +++ b/websocket/_abnf.py @@ -68,7 +68,7 @@ VALID_CLOSE_STATUS = ( STATUS_MESSAGE_TOO_BIG, STATUS_INVALID_EXTENSION, STATUS_UNEXPECTED_CONDITION, - ) +) class ABNF(object): """ @@ -87,7 +87,7 @@ class ABNF(object): # available operation code value tuple OPCODES = (OPCODE_CONT, OPCODE_TEXT, OPCODE_BINARY, OPCODE_CLOSE, - OPCODE_PING, OPCODE_PONG) + OPCODE_PING, OPCODE_PONG) # opcode human readable string OPCODE_MAP = { @@ -97,7 +97,7 @@ class ABNF(object): OPCODE_CLOSE: "close", OPCODE_PING: "ping", OPCODE_PONG: "pong" - } + } # data length threshold. LENGTH_7 = 0x7e diff --git a/websocket/_app.py b/websocket/_app.py index 215bff1..891a97e 100644 --- a/websocket/_app.py +++ b/websocket/_app.py @@ -168,16 +168,16 @@ class WebSocketApp(object): close_frame = None try: - self.sock = WebSocket(self.get_mask_key, - sockopt=sockopt, sslopt=sslopt, + self.sock = WebSocket( + self.get_mask_key, sockopt=sockopt, sslopt=sslopt, fire_cont_frame=self.on_cont_message and True or False, skip_utf8_validation=skip_utf8_validation) self.sock.settimeout(getdefaulttimeout()) - self.sock.connect(self.url, header=self.header, cookie=self.cookie, + self.sock.connect( + self.url, header=self.header, cookie=self.cookie, http_proxy_host=http_proxy_host, - http_proxy_port=http_proxy_port, - http_no_proxy=http_no_proxy, http_proxy_auth=http_proxy_auth, - subprotocols=self.subprotocols, + http_proxy_port=http_proxy_port, http_no_proxy=http_no_proxy, + http_proxy_auth=http_proxy_auth, subprotocols=self.subprotocols, host=host, origin=origin) self._callback(self.on_open) @@ -227,8 +227,9 @@ class WebSocketApp(object): thread.join() self.keep_running = False self.sock.close() - self._callback(self.on_close, - *self._get_close_args(close_frame.data if close_frame else None)) + close_args = self._get_close_args( + close_frame.data if close_frame else None) + self._callback(self.on_close, *close_args) self.sock = None def _get_close_args(self, data): diff --git a/websocket/_handshake.py b/websocket/_handshake.py index 67b16e4..cfc228d 100644 --- a/websocket/_handshake.py +++ b/websocket/_handshake.py @@ -124,7 +124,7 @@ def _get_resp_headers(sock, success_status=101): _HEADERS_TO_CHECK = { "upgrade": "websocket", "connection": "upgrade", - } +} def _validate(headers, key, subprotocols): diff --git a/websocket/_http.py b/websocket/_http.py index 8fae73f..14a5c7e 100644 --- a/websocket/_http.py +++ b/websocket/_http.py @@ -82,8 +82,8 @@ def connect(url, options, proxy, socket): def _get_addrinfo_list(hostname, port, is_secure, proxy): - phost, pport, pauth = get_proxy_info(hostname, is_secure, - proxy.host, proxy.port, proxy.auth, proxy.no_proxy) + phost, pport, pauth = get_proxy_info( + hostname, is_secure, proxy.host, proxy.port, proxy.auth, proxy.no_proxy) if not phost: addrinfo_list = socket.getaddrinfo(hostname, port, 0, 0, socket.SOL_TCP) return addrinfo_list, False, None diff --git a/websocket/_url.py b/websocket/_url.py index 9d705fd..7299e5c 100644 --- a/websocket/_url.py +++ b/websocket/_url.py @@ -82,8 +82,9 @@ def _is_no_proxy_host(hostname, no_proxy): return hostname in no_proxy -def get_proxy_info(hostname, is_secure, - proxy_host=None, proxy_port=0, proxy_auth=None, no_proxy=None): +def get_proxy_info( + hostname, is_secure, proxy_host=None, proxy_port=0, proxy_auth=None, + no_proxy=None): """ try to retrieve proxy host and port from environment if not provided in options.