From 953d46928030705057f16c7e1a3420cd666e9b34 Mon Sep 17 00:00:00 2001 From: Allan Lewis Date: Wed, 27 Apr 2016 12:11:07 +0100 Subject: [PATCH] wsdump, examples, setup, _abnf, _http, _utils: [PEP 8] Fix spacing --- bin/wsdump.py | 5 +++-- examples/echoapp_client.py | 6 +++--- setup.py | 4 ++-- websocket/_abnf.py | 16 ++++++++-------- websocket/_app.py | 2 +- websocket/_http.py | 6 +++--- websocket/_utils.py | 2 +- 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/bin/wsdump.py b/bin/wsdump.py index 88a6638..d85e4fc 100755 --- a/bin/wsdump.py +++ b/bin/wsdump.py @@ -33,9 +33,10 @@ class VAction(argparse.Action): try: values = int(values) except ValueError: - values = values.count("v")+1 + values = values.count("v") + 1 setattr(args, self.dest, values) + def parse_args(): parser = argparse.ArgumentParser(description="WebSocket Simple Dump Tool") parser.add_argument("url", metavar="ws_url", @@ -113,7 +114,7 @@ def main(): options["subprotocols"] = args.subprotocols opts = {} if args.nocert: - opts = { "cert_reqs": websocket.ssl.CERT_NONE, "check_hostname": False } + opts = {"cert_reqs": websocket.ssl.CERT_NONE, "check_hostname": False} ws = websocket.create_connection(args.url, sslopt=opts, **options) if args.raw: console = NonInteractive() diff --git a/examples/echoapp_client.py b/examples/echoapp_client.py index 48850b9..8689379 100644 --- a/examples/echoapp_client.py +++ b/examples/echoapp_client.py @@ -41,8 +41,8 @@ if __name__ == "__main__": else: host = sys.argv[1] ws = websocket.WebSocketApp(host, - on_message = on_message, - on_error = on_error, - on_close = on_close) + on_message=on_message, + on_error=on_error, + on_close=on_close) ws.on_open = on_open ws.run_forever() diff --git a/setup.py b/setup.py index 13778d7..c0d1654 100644 --- a/setup.py +++ b/setup.py @@ -2,12 +2,12 @@ from setuptools import setup import sys VERSION = "0.37.0" -NAME="websocket_client" +NAME = "websocket_client" install_requires = ["six"] tests_require = [] if sys.version_info[0] == 2: - if sys.version_info[1] < 7 or (sys.version_info[1] == 7 and sys.version_info[2]< 9): + if sys.version_info[1] < 7 or (sys.version_info[1] == 7 and sys.version_info[2] < 9): install_requires.append('backports.ssl_match_hostname') if sys.version_info[1] < 7: tests_require.append('unittest2==0.8.0') diff --git a/websocket/_abnf.py b/websocket/_abnf.py index 476bd4d..ed10470 100644 --- a/websocket/_abnf.py +++ b/websocket/_abnf.py @@ -78,12 +78,12 @@ class ABNF(object): """ # operation code values. - OPCODE_CONT = 0x0 - OPCODE_TEXT = 0x1 + OPCODE_CONT = 0x0 + OPCODE_TEXT = 0x1 OPCODE_BINARY = 0x2 - OPCODE_CLOSE = 0x8 - OPCODE_PING = 0x9 - OPCODE_PONG = 0xa + OPCODE_CLOSE = 0x8 + OPCODE_PING = 0x9 + OPCODE_PONG = 0xa # available operation code value tuple OPCODES = (OPCODE_CONT, OPCODE_TEXT, OPCODE_BINARY, OPCODE_CLOSE, @@ -100,7 +100,7 @@ class ABNF(object): } # data length threshold. - LENGTH_7 = 0x7e + LENGTH_7 = 0x7e LENGTH_16 = 1 << 16 LENGTH_63 = 1 << 63 @@ -150,7 +150,7 @@ class ABNF(object): @staticmethod def _is_valid_close_status(code): - return code in VALID_CLOSE_STATUS or (3000 <= code <5000) + return code in VALID_CLOSE_STATUS or (3000 <= code < 5000) def __str__(self): return "fin=" + str(self.fin) \ @@ -256,7 +256,7 @@ class frame_buffer(object): self.mask = None def has_received_header(self): - return self.header is None + return self.header is None def recv_header(self): header = self.recv_strict(2) diff --git a/websocket/_app.py b/websocket/_app.py index 891a97e..180a1fc 100644 --- a/websocket/_app.py +++ b/websocket/_app.py @@ -245,7 +245,7 @@ class WebSocketApp(object): return [] if data and len(data) >= 2: - code = 256*six.byte2int(data[0:1]) + six.byte2int(data[1:2]) + code = 256 * six.byte2int(data[0:1]) + six.byte2int(data[1:2]) reason = data[2:].decode('utf-8') return [code, reason] diff --git a/websocket/_http.py b/websocket/_http.py index 14a5c7e..b99c264 100644 --- a/websocket/_http.py +++ b/websocket/_http.py @@ -44,7 +44,7 @@ class proxy_info(object): self.host = options.get("http_proxy_host", None) if self.host: self.port = options.get("http_proxy_port", 0) - self.auth = options.get("http_proxy_auth", None) + self.auth = options.get("http_proxy_auth", None) self.no_proxy = options.get("http_no_proxy", None) else: self.port = 0 @@ -143,8 +143,8 @@ def _wrap_sni_socket(sock, sslopt, hostname, check_hostname): context.check_hostname = check_hostname if 'ciphers' in sslopt: context.set_ciphers(sslopt['ciphers']) - if 'cert_chain' in sslopt : - certfile,keyfile,password = sslopt['cert_chain'] + if 'cert_chain' in sslopt: + certfile, keyfile, password = sslopt['cert_chain'] context.load_cert_chain(certfile, keyfile, password) return context.wrap_socket( diff --git a/websocket/_utils.py b/websocket/_utils.py index 71d0e00..a7dd65c 100644 --- a/websocket/_utils.py +++ b/websocket/_utils.py @@ -69,7 +69,7 @@ except ImportError: def _decode(state, codep, ch): tp = _UTF8D[ch] - codep = (ch & 0x3f ) | (codep << 6) if (state != _UTF8_ACCEPT) else (0xff >> tp) & ch + codep = (ch & 0x3f) | (codep << 6) if (state != _UTF8_ACCEPT) else (0xff >> tp) & ch state = _UTF8D[256 + state + tp] return state, codep