]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
style fix: 2 blank lines around top-level class and function defs
authorPierce Lopez <pierce.lopez@gmail.com>
Mon, 1 Jan 2018 19:43:18 +0000 (14:43 -0500)
committerPierce Lopez <pierce.lopez@gmail.com>
Mon, 1 Jan 2018 20:57:42 +0000 (15:57 -0500)
flake8 codes E302 and E305

16 files changed:
demos/benchmark/benchmark.py
demos/benchmark/gen_benchmark.py
demos/benchmark/stack_context_benchmark.py
demos/benchmark/template_benchmark.py
demos/s3server/s3server.py
demos/twitter/twitterdemo.py
demos/websocket/chatdemo.py
maint/scripts/custom_fixers/fix_future_imports.py
maint/scripts/test_resolvers.py
maint/test/appengine/common/cgi_runtests.py
maint/test/cython/pythonmodule.py
maint/test/redbot/red_test.py
maint/test/websocket/client.py
maint/test/websocket/server.py
maint/vm/windows/bootstrap.py
tornado/test/util.py

index 1e8375d728a1bdab376ba7fab40c27339c5f6694..d1f32d33ef32afa19c8fd4edfa330cb17442917b 100755 (executable)
@@ -46,6 +46,7 @@ define("num_runs", type=int, default=1)
 
 define("ioloop", type=str, default=None)
 
+
 class RootHandler(RequestHandler):
     def get(self):
         self.write("Hello, world")
@@ -53,9 +54,11 @@ class RootHandler(RequestHandler):
     def _log(self):
         pass
 
+
 def handle_sigchld(sig, frame):
     IOLoop.current().add_callback_from_signal(IOLoop.current().stop)
 
+
 def main():
     parse_command_line()
     if options.ioloop:
@@ -63,6 +66,7 @@ def main():
     for i in xrange(options.num_runs):
         run()
 
+
 def run():
     io_loop = IOLoop(make_current=True)
     app = Application([("/", RootHandler)])
@@ -83,5 +87,6 @@ def run():
     io_loop.close()
     io_loop.clear_current()
 
+
 if __name__ == '__main__':
     main()
index 1b5281fb9d16f3b3004a8618ba7c87128383ea9e..a4629626419a83fc0f6920fa70f5a106d1f70779 100644 (file)
@@ -16,24 +16,29 @@ define('num', default=10000, help='number of iterations')
 # This removes noise from the results, but it's easy to change things
 # in a way that completely invalidates the results.
 
+
 @gen.engine
 def e2(callback):
     callback()
 
+
 @gen.engine
 def e1():
     for i in range(10):
         yield gen.Task(e2)
 
+
 @gen.coroutine
 def c2():
     pass
 
+
 @gen.coroutine
 def c1():
     for i in range(10):
         yield c2()
 
+
 def main():
     parse_command_line()
     t = Timer(e1)
@@ -43,5 +48,6 @@ def main():
     results = t.timeit(options.num) / options.num
     print('coroutine: %0.3f ms per iteration' % (results * 1000))
 
+
 if __name__ == '__main__':
     main()
index 158f06520a0f2d928db617dde0441f276b602069..2b4a388fea0acd3fa645c79c1407db0dcac0cbc7 100755 (executable)
@@ -8,6 +8,7 @@ import sys
 
 from tornado import stack_context
 
+
 class Benchmark(object):
     def enter_exit(self, count):
         """Measures the overhead of the nested "with" statements
@@ -37,6 +38,7 @@ class Benchmark(object):
             queue.append(stack_context.wrap(
                 functools.partial(self.call_wrapped_inner, queue, count - 1)))
 
+
 class StackBenchmark(Benchmark):
     def make_context(self):
         return stack_context.StackContext(self.__context)
@@ -45,6 +47,7 @@ class StackBenchmark(Benchmark):
     def __context(self):
         yield
 
+
 class ExceptionBenchmark(Benchmark):
     def make_context(self):
         return stack_context.ExceptionStackContext(self.__handle_exception)
@@ -52,6 +55,7 @@ class ExceptionBenchmark(Benchmark):
     def __handle_exception(self, typ, value, tb):
         pass
 
+
 def main():
     base_cmd = [
         sys.executable, '-m', 'timeit', '-s',
@@ -71,5 +75,6 @@ def main():
         print(cmd)
         subprocess.check_call(base_cmd + [cmd])
 
+
 if __name__ == '__main__':
     main()
index 08055fb66bb6e6ff89bf8fb4fc3f88df10875aa6..c0e67cecd6894d68de558b8930cd6093d32e4822 100755 (executable)
@@ -51,9 +51,11 @@ tmpl = Template("""\
 </html>\
 """)
 
+
 def render():
     tmpl.generate(**context)
 
+
 def main():
     parse_command_line()
     if options.dump:
@@ -63,5 +65,6 @@ def main():
     results = t.timeit(options.num) / options.num
     print('%0.3f ms per iteration' % (results * 1000))
 
+
 if __name__ == '__main__':
     main()
index ff289f025179e36ba478c9d4fc2ab3a66e80e107..6ca104d1ed944a2ed31c79170e170b35fecb213a 100644 (file)
@@ -43,6 +43,7 @@ from tornado import httpserver
 from tornado import ioloop
 from tornado import web
 
+
 def start(port, root_directory="/tmp/s3", bucket_depth=0):
     """Starts the mock S3 server on the given port at the given path."""
     application = S3Application(root_directory, bucket_depth)
index 73aa6ba3f96186841c758f2fdfcc0c7f948e942d..c674c65c2de49a964abc1bb0b6d0788fb251e4ae 100644 (file)
@@ -39,6 +39,7 @@ define('cookie_secret', type=str, group='application',
        default='__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE__',
        help="signing key for secure cookies")
 
+
 class BaseHandler(RequestHandler):
     COOKIE_NAME = 'twitterdemo_user'
 
@@ -48,6 +49,7 @@ class BaseHandler(RequestHandler):
             return None
         return json_decode(user_json)
 
+
 class MainHandler(BaseHandler, TwitterMixin):
     @authenticated
     @gen.coroutine
@@ -57,6 +59,7 @@ class MainHandler(BaseHandler, TwitterMixin):
             access_token=self.current_user['access_token'])
         self.render('home.html', timeline=timeline)
 
+
 class LoginHandler(BaseHandler, TwitterMixin):
     @gen.coroutine
     def get(self):
@@ -68,10 +71,12 @@ class LoginHandler(BaseHandler, TwitterMixin):
         else:
             yield self.authorize_redirect(callback_uri=self.request.full_url())
 
+
 class LogoutHandler(BaseHandler):
     def get(self):
         self.clear_cookie(self.COOKIE_NAME)
 
+
 def main():
     parse_command_line(final=False)
     parse_config_file(options.config_file)
@@ -89,5 +94,6 @@ def main():
     logging.info('Listening on http://localhost:%d' % options.port)
     IOLoop.current().start()
 
+
 if __name__ == '__main__':
     main()
index 36b0ed06d562c51889a5419a3ca2927fec3f0f3b..a3fa2a69f0714b9630305cb1125ac17eeab48feb 100755 (executable)
@@ -51,6 +51,7 @@ class MainHandler(tornado.web.RequestHandler):
     def get(self):
         self.render("index.html", messages=ChatSocketHandler.cache)
 
+
 class ChatSocketHandler(tornado.websocket.WebSocketHandler):
     waiters = set()
     cache = []
index 45aff61af627b54491752592169885df4df79da1..48553c4a6761af343ed4f290d35297635918fac8 100644 (file)
@@ -5,11 +5,13 @@ from lib2to3 import pytree
 from lib2to3.pgen2 import token
 from lib2to3.fixer_util import FromImport, Name, Comma, Newline
 
+
 # copied from fix_tuple_params.py
 def is_docstring(stmt):
     return isinstance(stmt, pytree.Node) and \
            stmt.children[0].type == token.STRING
 
+
 class FixFutureImports(fixer_base.BaseFix):
     BM_compatible = True
 
index 971395ba03d319b51adff5668249631ffa97d22b..2a466c1ac9d06a888bc596e5036469167392e42c 100644 (file)
@@ -22,6 +22,7 @@ except ImportError:
 define('family', default='unspec',
        help='Address family to query: unspec, inet, or inet6')
 
+
 @gen.coroutine
 def main():
     args = parse_command_line()
@@ -54,5 +55,6 @@ def main():
                               pprint.pformat(addrinfo)))
         print()
 
+
 if __name__ == '__main__':
     IOLoop.instance().run_sync(main)
index 44ddf7ae881a7dffea7960ab4e051bfa53d3108d..7041a42d9d21f7073dec0e123408b9d745b351b1 100644 (file)
@@ -36,9 +36,11 @@ TEST_MODULES = [
     #'tornado.test.wsgi_test',
 ]
 
+
 def all():
     return unittest.defaultTestLoader.loadTestsFromNames(TEST_MODULES)
 
+
 def main():
     print "Content-Type: text/plain\r\n\r\n",
 
@@ -50,5 +52,6 @@ def main():
         else:
             raise
 
+
 if __name__ == '__main__':
     main()
index e532693d1dd0bc1ee2d454bb358413017e083e77..e7c2af517d6962d3d0c5b5f1ba291ae583dbdefd 100644 (file)
@@ -1,5 +1,6 @@
 from tornado import gen
 
+
 @gen.coroutine
 def hello():
     yield gen.sleep(0.001)
index f4733490718794eec6f2e7fb4efcdf91c0b6925c..055b479565d81aa23d0d1deca75f9f85ddf746d3 100644 (file)
@@ -11,19 +11,23 @@ from tornado.testing import AsyncHTTPTestCase
 from tornado.web import RequestHandler, Application, asynchronous
 import unittest
 
+
 class HelloHandler(RequestHandler):
     def get(self):
         self.write("Hello world")
 
+
 class RedirectHandler(RequestHandler):
     def get(self, path):
         self.redirect(path, status=int(self.get_argument('status', '302')))
 
+
 class PostHandler(RequestHandler):
     def post(self):
         assert self.get_argument('foo') == 'bar'
         self.redirect('/hello', status=303)
 
+
 class ChunkedHandler(RequestHandler):
     @asynchronous
     @gen.engine
@@ -34,6 +38,7 @@ class ChunkedHandler(RequestHandler):
         yield gen.Task(self.flush)
         self.finish()
 
+
 class CacheHandler(RequestHandler):
     def get(self, computed_etag):
         self.write(computed_etag)
@@ -41,6 +46,7 @@ class CacheHandler(RequestHandler):
     def compute_etag(self):
         return self._write_buffer[0]
 
+
 class TestMixin(object):
     def get_handlers(self):
         return [
@@ -231,10 +237,12 @@ class TestMixin(object):
             headers=[('If-None-Match', etags)],
             expected_status=200)
 
+
 class DefaultHTTPTest(AsyncHTTPTestCase, TestMixin):
     def get_app(self):
         return Application(self.get_handlers(), **self.get_app_kwargs())
 
+
 class GzipHTTPTest(AsyncHTTPTestCase, TestMixin):
     def get_app(self):
         return Application(self.get_handlers(), gzip=True, **self.get_app_kwargs())
@@ -249,6 +257,7 @@ class GzipHTTPTest(AsyncHTTPTestCase, TestMixin):
             rs.VARY_ETAG_DOESNT_CHANGE,
         ]
 
+
 if __name__ == '__main__':
     parse_command_line()
     unittest.main()
index 9df1a82a449e516d5bf7d6b2c6841bcc78ce295a..d1b1aaf56a4b519dabc1141cc94ea6effb3455fa 100644 (file)
@@ -10,6 +10,7 @@ from tornado.websocket import websocket_connect
 define('url', default='ws://localhost:9001')
 define('name', default='Tornado')
 
+
 @gen.engine
 def run_tests():
     url = options.url + '/getCaseCount'
@@ -35,6 +36,7 @@ def run_tests():
     assert msg is None
     IOLoop.instance().stop()
 
+
 def main():
     parse_command_line()
 
@@ -42,5 +44,6 @@ def main():
 
     IOLoop.instance().start()
 
+
 if __name__ == '__main__':
     main()
index 40b5eeabaffb3025567a2ce42fd283845c34de47..5d86b1316e67479898694ac307b1d03188f26571 100644 (file)
@@ -7,6 +7,7 @@ from tornado.web import Application
 
 define('port', default=9000)
 
+
 class EchoHandler(WebSocketHandler):
     def on_message(self, message):
         self.write_message(message, binary=isinstance(message, bytes))
@@ -14,6 +15,7 @@ class EchoHandler(WebSocketHandler):
     def get_compression_options(self):
         return {}
 
+
 if __name__ == '__main__':
     parse_command_line()
     app = Application([
index d481d034d5573ddd0c54a0b47ff88d6fd08da531..e795e97f79aa9ed0c9294c2ade0b03f044c078e6 100644 (file)
@@ -37,6 +37,7 @@ EASY_INSTALL = os.path.join(SCRIPTS_DIR, 'easy_install.exe')
 
 PY_PACKAGES = ['tox', 'virtualenv', 'pip']
 
+
 def download_to_cache(url, local_name=None):
     if local_name is None:
         local_name = url.split('/')[-1]
@@ -47,6 +48,7 @@ def download_to_cache(url, local_name=None):
             f.write(data)
     return filename
 
+
 def main():
     if not os.path.exists(TMPDIR):
         os.mkdir(TMPDIR)
index 1d34ec083310d89dc9d38fcdfa4cd3f334d6e5f0..1d998f0ea7996faa96719651efda9b63db8bf0d3 100644 (file)
@@ -41,6 +41,7 @@ skipPypy3V58 = unittest.skipIf(platform.python_implementation() == 'PyPy' and
                                sys.pypy_version_info < (5, 9),
                                'pypy3 5.8 has buggy ssl module')
 
+
 def _detect_ipv6():
     if not socket.has_ipv6:
         # socket.has_ipv6 check reports whether ipv6 was present at compile
@@ -57,6 +58,7 @@ def _detect_ipv6():
             sock.close()
     return True
 
+
 skipIfNoIPv6 = unittest.skipIf(not _detect_ipv6(), 'ipv6 support not present')