wsdump, examples, setup, _abnf, _http, _utils: [PEP 8] Fix spacing
This commit is contained in:
@@ -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()
|
||||
|
@@ -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()
|
||||
|
4
setup.py
4
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')
|
||||
|
@@ -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)
|
||||
|
@@ -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]
|
||||
|
||||
|
@@ -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(
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user