wsdump, examples, setup, _abnf, _http, _utils: [PEP 8] Fix spacing

This commit is contained in:
Allan Lewis
2016-04-27 12:11:07 +01:00
parent 9ebe59b5d7
commit 953d469280
7 changed files with 21 additions and 20 deletions

View File

@@ -33,9 +33,10 @@ class VAction(argparse.Action):
try: try:
values = int(values) values = int(values)
except ValueError: except ValueError:
values = values.count("v")+1 values = values.count("v") + 1
setattr(args, self.dest, values) setattr(args, self.dest, values)
def parse_args(): def parse_args():
parser = argparse.ArgumentParser(description="WebSocket Simple Dump Tool") parser = argparse.ArgumentParser(description="WebSocket Simple Dump Tool")
parser.add_argument("url", metavar="ws_url", parser.add_argument("url", metavar="ws_url",
@@ -113,7 +114,7 @@ def main():
options["subprotocols"] = args.subprotocols options["subprotocols"] = args.subprotocols
opts = {} opts = {}
if args.nocert: 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) ws = websocket.create_connection(args.url, sslopt=opts, **options)
if args.raw: if args.raw:
console = NonInteractive() console = NonInteractive()

View File

@@ -41,8 +41,8 @@ if __name__ == "__main__":
else: else:
host = sys.argv[1] host = sys.argv[1]
ws = websocket.WebSocketApp(host, ws = websocket.WebSocketApp(host,
on_message = on_message, on_message=on_message,
on_error = on_error, on_error=on_error,
on_close = on_close) on_close=on_close)
ws.on_open = on_open ws.on_open = on_open
ws.run_forever() ws.run_forever()

View File

@@ -2,12 +2,12 @@ from setuptools import setup
import sys import sys
VERSION = "0.37.0" VERSION = "0.37.0"
NAME="websocket_client" NAME = "websocket_client"
install_requires = ["six"] install_requires = ["six"]
tests_require = [] tests_require = []
if sys.version_info[0] == 2: 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') install_requires.append('backports.ssl_match_hostname')
if sys.version_info[1] < 7: if sys.version_info[1] < 7:
tests_require.append('unittest2==0.8.0') tests_require.append('unittest2==0.8.0')

View File

@@ -150,7 +150,7 @@ class ABNF(object):
@staticmethod @staticmethod
def _is_valid_close_status(code): 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): def __str__(self):
return "fin=" + str(self.fin) \ return "fin=" + str(self.fin) \

View File

@@ -245,7 +245,7 @@ class WebSocketApp(object):
return [] return []
if data and len(data) >= 2: 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') reason = data[2:].decode('utf-8')
return [code, reason] return [code, reason]

View File

@@ -143,8 +143,8 @@ def _wrap_sni_socket(sock, sslopt, hostname, check_hostname):
context.check_hostname = check_hostname context.check_hostname = check_hostname
if 'ciphers' in sslopt: if 'ciphers' in sslopt:
context.set_ciphers(sslopt['ciphers']) context.set_ciphers(sslopt['ciphers'])
if 'cert_chain' in sslopt : if 'cert_chain' in sslopt:
certfile,keyfile,password = sslopt['cert_chain'] certfile, keyfile, password = sslopt['cert_chain']
context.load_cert_chain(certfile, keyfile, password) context.load_cert_chain(certfile, keyfile, password)
return context.wrap_socket( return context.wrap_socket(

View File

@@ -69,7 +69,7 @@ except ImportError:
def _decode(state, codep, ch): def _decode(state, codep, ch):
tp = _UTF8D[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] state = _UTF8D[256 + state + tp]
return state, codep return state, codep