From: Ben Darnell Date: Mon, 30 Dec 2013 04:56:37 +0000 (-0500) Subject: autopep8 whitespace fixes. X-Git-Tag: v3.2.0b1~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2b83348973c2666189afc4f0d7ccc05e3832a03;p=thirdparty%2Ftornado.git autopep8 whitespace fixes. --- diff --git a/tornado/auth.py b/tornado/auth.py index a2cef3565..f2080f1e9 100644 --- a/tornado/auth.py +++ b/tornado/auth.py @@ -988,8 +988,8 @@ class GoogleOAuth2Mixin(OAuth2Mixin): }) http.fetch(self._OAUTH_ACCESS_TOKEN_URL, - self.async_callback(self._on_access_token, callback), - method="POST", headers={'Content-Type': 'application/x-www-form-urlencoded'}, body=body) + self.async_callback(self._on_access_token, callback), + method="POST", headers={'Content-Type': 'application/x-www-form-urlencoded'}, body=body) def _on_access_token(self, future, response): """Callback function for the exchange to the access token.""" diff --git a/tornado/gen.py b/tornado/gen.py index 5ce52efd3..21f692ab9 100644 --- a/tornado/gen.py +++ b/tornado/gen.py @@ -411,6 +411,7 @@ class YieldFuture(YieldPoint): else: return self.result + class Multi(YieldPoint): """Runs multiple asynchronous operations in parallel. diff --git a/tornado/iostream.py b/tornado/iostream.py index 08430ceaf..5d4d08ac4 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -55,6 +55,7 @@ _ERRNO_WOULDBLOCK = (errno.EWOULDBLOCK, errno.EAGAIN) # They should be caught and handled less noisily than other errors. _ERRNO_CONNRESET = (errno.ECONNRESET, errno.ECONNABORTED, errno.EPIPE) + class StreamClosedError(IOError): """Exception raised by `IOStream` methods when the stream is closed. @@ -738,7 +739,7 @@ class IOStream(BaseIOStream): # localhost, so handle them the same way as an error # reported later in _handle_connect. if (e.args[0] != errno.EINPROGRESS and - e.args[0] not in _ERRNO_WOULDBLOCK): + e.args[0] not in _ERRNO_WOULDBLOCK): gen_log.warning("Connect error on fd %d: %s", self.socket.fileno(), e) self.close(exc_info=True) diff --git a/tornado/platform/asyncio.py b/tornado/platform/asyncio.py index a8f5bad47..09b2bf3d3 100644 --- a/tornado/platform/asyncio.py +++ b/tornado/platform/asyncio.py @@ -16,6 +16,7 @@ import os from tornado.ioloop import IOLoop from tornado import stack_context + class BaseAsyncIOLoop(IOLoop): def initialize(self, asyncio_loop, close_loop=False): self.asyncio_loop = asyncio_loop @@ -104,7 +105,7 @@ class BaseAsyncIOLoop(IOLoop): else: raise TypeError("Unsupported deadline %r", deadline) return self.asyncio_loop.call_later(delay, self._run_callback, - stack_context.wrap(callback)) + stack_context.wrap(callback)) def remove_timeout(self, timeout): timeout.cancel() @@ -114,8 +115,8 @@ class BaseAsyncIOLoop(IOLoop): raise RuntimeError("IOLoop is closing") if kwargs: self.asyncio_loop.call_soon_threadsafe(functools.partial( - self._run_callback, stack_context.wrap(callback), - *args, **kwargs)) + self._run_callback, stack_context.wrap(callback), + *args, **kwargs)) else: self.asyncio_loop.call_soon_threadsafe( self._run_callback, stack_context.wrap(callback), *args) @@ -128,6 +129,7 @@ class AsyncIOMainLoop(BaseAsyncIOLoop): super(AsyncIOMainLoop, self).initialize(asyncio.get_event_loop(), close_loop=False) + class AsyncIOLoop(BaseAsyncIOLoop): def initialize(self): super(AsyncIOLoop, self).initialize(asyncio.new_event_loop(), diff --git a/tornado/simple_httpclient.py b/tornado/simple_httpclient.py index 2558ada80..73bfee89e 100644 --- a/tornado/simple_httpclient.py +++ b/tornado/simple_httpclient.py @@ -94,9 +94,9 @@ class SimpleAsyncHTTPClient(AsyncHTTPClient): self.queue.append((key, request, callback)) if not len(self.active) < self.max_clients: timeout_handle = self.io_loop.add_timeout( - self.io_loop.time() + min(request.connect_timeout, - request.request_timeout), - functools.partial(self._on_timeout, key)) + self.io_loop.time() + min(request.connect_timeout, + request.request_timeout), + functools.partial(self._on_timeout, key)) else: timeout_handle = None self.waiting[key] = (request, callback, timeout_handle) @@ -136,8 +136,8 @@ class SimpleAsyncHTTPClient(AsyncHTTPClient): request, callback, timeout_handle = self.waiting[key] self.queue.remove((key, request, callback)) timeout_response = HTTPResponse( - request, 599, error=HTTPError(599, "Timeout"), - request_time=self.io_loop.time() - request.start_time) + request, 599, error=HTTPError(599, "Timeout"), + request_time=self.io_loop.time() - request.start_time) self.io_loop.add_callback(callback, timeout_response) del self.waiting[key] diff --git a/tornado/test/httpserver_test.py b/tornado/test/httpserver_test.py index 47607d4bc..5ca299350 100644 --- a/tornado/test/httpserver_test.py +++ b/tornado/test/httpserver_test.py @@ -211,15 +211,15 @@ class HTTPConnectionTest(AsyncHTTPTestCase): b"X-Header-encoding-test: \xe9", ], b"\r\n".join([ - b"Content-Disposition: form-data; name=argument", - b"", - u("\u00e1").encode("utf-8"), - b"--1234567890", - u('Content-Disposition: form-data; name="files"; filename="\u00f3"').encode("utf8"), - b"", - u("\u00fa").encode("utf-8"), - b"--1234567890--", - b"", + b"Content-Disposition: form-data; name=argument", + b"", + u("\u00e1").encode("utf-8"), + b"--1234567890", + u('Content-Disposition: form-data; name="files"; filename="\u00f3"').encode("utf8"), + b"", + u("\u00fa").encode("utf-8"), + b"--1234567890--", + b"", ])) data = json_decode(response.body) self.assertEqual(u("\u00e9"), data["header"]) @@ -548,7 +548,6 @@ class UnixSocketTest(AsyncTestCase): self.assertEqual(response, b"") - class KeepAliveTest(AsyncHTTPTestCase): """Tests various scenarios for HTTP 1.1 keep-alive support. diff --git a/tornado/test/web_test.py b/tornado/test/web_test.py index e12f7ec0e..5029cd526 100644 --- a/tornado/test/web_test.py +++ b/tornado/test/web_test.py @@ -1743,6 +1743,7 @@ class Default404Test(WebTestCase): b'404: Not Found' b'404: Not Found') + @wsgi_safe class Custom404Test(WebTestCase): def get_handlers(self): @@ -1761,6 +1762,7 @@ class Custom404Test(WebTestCase): self.assertEqual(response.code, 404) self.assertEqual(response.body, b'custom 404 response') + @wsgi_safe class DefaultHandlerArgumentsTest(WebTestCase): def get_handlers(self): diff --git a/tornado/test/websocket_test.py b/tornado/test/websocket_test.py index 7eb6a1163..d5cc1ceb4 100644 --- a/tornado/test/websocket_test.py +++ b/tornado/test/websocket_test.py @@ -11,6 +11,7 @@ try: except ImportError: speedups = None + class TestWebSocketHandler(WebSocketHandler): """Base class for testing handlers that exposes the on_close event. @@ -153,6 +154,7 @@ class PythonMaskFunctionTest(MaskFunctionMixin, unittest.TestCase): def mask(self, mask, data): return _websocket_mask_python(mask, data) + @unittest.skipIf(speedups is None, "tornado.speedups module not present") class CythonMaskFunctionTest(MaskFunctionMixin, unittest.TestCase): def mask(self, mask, data): diff --git a/tornado/web.py b/tornado/web.py index 2f7e92ea0..65a76cd47 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -1912,7 +1912,7 @@ class StaticFileHandler(RequestHandler): # content, or when a suffix with length 0 is specified self.set_status(416) # Range Not Satisfiable self.set_header("Content-Type", "text/plain") - self.set_header("Content-Range", "bytes */%s" %(size, )) + self.set_header("Content-Range", "bytes */%s" % (size, )) return if start is not None and start < 0: start += size diff --git a/tornado/websocket.py b/tornado/websocket.py index 8c2f5a647..9bec9bbae 100644 --- a/tornado/websocket.py +++ b/tornado/websocket.py @@ -381,12 +381,12 @@ class WebSocketProtocol76(WebSocketProtocol): "Sec-WebSocket-Location: %(scheme)s://%(host)s%(uri)s\r\n" "%(subprotocol)s" "\r\n" % (dict( - version=tornado.version, - origin=self.request.headers["Origin"], - scheme=scheme, - host=self.request.host, - uri=self.request.uri, - subprotocol=subprotocol_header)))) + version=tornado.version, + origin=self.request.headers["Origin"], + scheme=scheme, + host=self.request.host, + uri=self.request.uri, + subprotocol=subprotocol_header)))) self.stream.read_bytes(8, self._handle_challenge) def challenge_response(self, challenge): @@ -891,6 +891,7 @@ def websocket_connect(url, io_loop=None, callback=None, connect_timeout=None): io_loop.add_future(conn.connect_future, callback) return conn.connect_future + def _websocket_mask_python(mask, data): """Websocket masking function. diff --git a/tornado/wsgi.py b/tornado/wsgi.py index 8e5ddedb9..615f2e1fd 100644 --- a/tornado/wsgi.py +++ b/tornado/wsgi.py @@ -294,7 +294,7 @@ class WSGIContainer(object): "REQUEST_METHOD": request.method, "SCRIPT_NAME": "", "PATH_INFO": to_wsgi_str(escape.url_unescape( - request.path, encoding=None, plus=False)), + request.path, encoding=None, plus=False)), "QUERY_STRING": request.query, "REMOTE_ADDR": request.remote_ip, "SERVER_NAME": host,