From: Ben Darnell Date: Thu, 9 Feb 2012 07:22:51 +0000 (-0800) Subject: Standardize future imports for all files in the package. X-Git-Tag: v2.3.0~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da6d821e0c1c69bd8d9adc3e1087906ab4d7b3da;p=thirdparty%2Ftornado.git Standardize future imports for all files in the package. --- diff --git a/tornado/__init__.py b/tornado/__init__.py index 12a94b3f4..8ab36594d 100644 --- a/tornado/__init__.py +++ b/tornado/__init__.py @@ -16,6 +16,8 @@ """The Tornado web server and tools.""" +from __future__ import absolute_import, with_statement + # version is a human-readable version number. # version_info is a four-tuple for programmatic comparison. The first diff --git a/tornado/auth.py b/tornado/auth.py index a71621053..9f1a7a7a6 100644 --- a/tornado/auth.py +++ b/tornado/auth.py @@ -44,6 +44,8 @@ Example usage for Google OpenID:: # Save the user with, e.g., set_secure_cookie() """ +from __future__ import absolute_import, with_statement + import base64 import binascii import hashlib diff --git a/tornado/autoreload.py b/tornado/autoreload.py index 7e3a3d73c..4d23f1984 100644 --- a/tornado/autoreload.py +++ b/tornado/autoreload.py @@ -26,7 +26,7 @@ and Google AppEngine. It also will not work correctly when HTTPServer's multi-process mode is used. """ -from __future__ import with_statement +from __future__ import absolute_import, with_statement import functools import logging diff --git a/tornado/curl_httpclient.py b/tornado/curl_httpclient.py index a338cb8d6..9cfbbb74c 100644 --- a/tornado/curl_httpclient.py +++ b/tornado/curl_httpclient.py @@ -16,7 +16,7 @@ """Blocking and non-blocking HTTP client implementations using pycurl.""" -from __future__ import with_statement +from __future__ import absolute_import, with_statement import cStringIO import collections diff --git a/tornado/database.py b/tornado/database.py index 977171376..26e4a603a 100644 --- a/tornado/database.py +++ b/tornado/database.py @@ -16,6 +16,8 @@ """A lightweight wrapper around MySQLdb.""" +from __future__ import absolute_import, with_statement + import copy import MySQLdb.constants import MySQLdb.converters diff --git a/tornado/escape.py b/tornado/escape.py index 4010b1c92..a9de7e396 100644 --- a/tornado/escape.py +++ b/tornado/escape.py @@ -20,6 +20,8 @@ Also includes a few other miscellaneous string manipulation functions that have crept in over time. """ +from __future__ import absolute_import, with_statement + import htmlentitydefs import re import sys diff --git a/tornado/gen.py b/tornado/gen.py index 51be53760..21ba8f827 100644 --- a/tornado/gen.py +++ b/tornado/gen.py @@ -62,7 +62,7 @@ it was called with one argument, the result is that argument. If it was called with more than one argument or any keyword arguments, the result is an `Arguments` object, which is a named tuple ``(args, kwargs)``. """ -from __future__ import with_statement +from __future__ import absolute_import, with_statement import functools import operator diff --git a/tornado/httpclient.py b/tornado/httpclient.py index 354d907c3..5b4bac240 100644 --- a/tornado/httpclient.py +++ b/tornado/httpclient.py @@ -29,6 +29,8 @@ you use a recent version of ``libcurl`` and ``pycurl``. Currently the minimum supported version is 7.18.2, and the recommended version is 7.21.1 or newer. """ +from __future__ import absolute_import, with_statement + import calendar import email.utils import httplib diff --git a/tornado/httpserver.py b/tornado/httpserver.py index e24c3768e..11602d287 100644 --- a/tornado/httpserver.py +++ b/tornado/httpserver.py @@ -24,6 +24,8 @@ This module also defines the `HTTPRequest` class which is exposed via `tornado.web.RequestHandler.request`. """ +from __future__ import absolute_import, with_statement + import Cookie import logging import socket diff --git a/tornado/httputil.py b/tornado/httputil.py index 2398ade95..a197707b0 100644 --- a/tornado/httputil.py +++ b/tornado/httputil.py @@ -16,6 +16,8 @@ """HTTP utility code shared by clients and servers.""" +from __future__ import absolute_import, with_statement + import logging import urllib import re diff --git a/tornado/ioloop.py b/tornado/ioloop.py index edd2fec2e..1f3f9bc27 100644 --- a/tornado/ioloop.py +++ b/tornado/ioloop.py @@ -26,7 +26,7 @@ In addition to I/O events, the `IOLoop` can also schedule time-based events. `IOLoop.add_timeout` is a non-blocking alternative to `time.sleep`. """ -from __future__ import with_statement +from __future__ import absolute_import, with_statement import datetime import errno diff --git a/tornado/iostream.py b/tornado/iostream.py index db7895f0e..95c659615 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -16,7 +16,7 @@ """A utility class to write to and read from a non-blocking socket.""" -from __future__ import with_statement +from __future__ import absolute_import, with_statement import collections import errno diff --git a/tornado/locale.py b/tornado/locale.py index 61cdb7e7e..dd2a0e233 100644 --- a/tornado/locale.py +++ b/tornado/locale.py @@ -39,6 +39,8 @@ supported by gettext and related tools). If neither method is called, the locale.translate method will simply return the original string. """ +from __future__ import absolute_import, with_statement + import csv import datetime import logging diff --git a/tornado/netutil.py b/tornado/netutil.py index 1e1bcbf91..517367791 100644 --- a/tornado/netutil.py +++ b/tornado/netutil.py @@ -16,6 +16,8 @@ """Miscellaneous network utility code.""" +from __future__ import absolute_import, with_statement + import errno import logging import os diff --git a/tornado/options.py b/tornado/options.py index 5fb91e1fe..a7344421b 100644 --- a/tornado/options.py +++ b/tornado/options.py @@ -48,6 +48,8 @@ kwarg to define). We also accept multi-value options. See the documentation for define() below. """ +from __future__ import absolute_import, with_statement + import datetime import logging import logging.handlers diff --git a/tornado/platform/auto.py b/tornado/platform/auto.py index e76d731b3..086fe70b5 100644 --- a/tornado/platform/auto.py +++ b/tornado/platform/auto.py @@ -23,6 +23,8 @@ Most code that needs access to this functionality should do e.g.:: from tornado.platform.auto import set_close_exec """ +from __future__ import absolute_import, with_statement + import os if os.name == 'nt': diff --git a/tornado/platform/interface.py b/tornado/platform/interface.py index 20f0f7161..0879b5a0b 100644 --- a/tornado/platform/interface.py +++ b/tornado/platform/interface.py @@ -21,6 +21,8 @@ for other tornado.platform modules. Most code should import the appropriate implementation from `tornado.platform.auto`. """ +from __future__ import absolute_import, with_statement + def set_close_exec(fd): """Sets the close-on-exec bit (``FD_CLOEXEC``)for a file descriptor.""" raise NotImplementedError() diff --git a/tornado/platform/posix.py b/tornado/platform/posix.py index aa09b31c7..40afbad4e 100644 --- a/tornado/platform/posix.py +++ b/tornado/platform/posix.py @@ -16,6 +16,8 @@ """Posix implementations of platform-specific functionality.""" +from __future__ import absolute_import, with_statement + import fcntl import os diff --git a/tornado/platform/twisted.py b/tornado/platform/twisted.py index 5d406d347..ed426fcc3 100644 --- a/tornado/platform/twisted.py +++ b/tornado/platform/twisted.py @@ -44,7 +44,7 @@ before closing the `IOLoop`. This module has been tested with Twisted versions 11.0.0 and 11.1.0. """ -from __future__ import with_statement, absolute_import +from __future__ import absolute_import, with_statement import functools import logging diff --git a/tornado/platform/windows.py b/tornado/platform/windows.py index 1735f1b38..cef82e901 100644 --- a/tornado/platform/windows.py +++ b/tornado/platform/windows.py @@ -1,6 +1,8 @@ # NOTE: win32 support is currently experimental, and not recommended # for production use. + +from __future__ import absolute_import, with_statement import ctypes import ctypes.wintypes import socket diff --git a/tornado/process.py b/tornado/process.py index 06f6aa9b0..4958fa499 100644 --- a/tornado/process.py +++ b/tornado/process.py @@ -16,6 +16,8 @@ """Utilities for working with multiple processes.""" +from __future__ import absolute_import, with_statement + import errno import logging import os diff --git a/tornado/simple_httpclient.py b/tornado/simple_httpclient.py index c301295a5..a6cba17ba 100644 --- a/tornado/simple_httpclient.py +++ b/tornado/simple_httpclient.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -from __future__ import with_statement +from __future__ import absolute_import, with_statement from tornado.escape import utf8, _unicode, native_str from tornado.httpclient import HTTPRequest, HTTPResponse, HTTPError, AsyncHTTPClient, main diff --git a/tornado/stack_context.py b/tornado/stack_context.py index 1ba3730c3..fe229cdcb 100644 --- a/tornado/stack_context.py +++ b/tornado/stack_context.py @@ -66,7 +66,7 @@ Here are a few rules of thumb for when it's necessary: block that references your `StackContext`. ''' -from __future__ import with_statement +from __future__ import absolute_import, with_statement import contextlib import functools diff --git a/tornado/template.py b/tornado/template.py index 139667dce..69813eb5a 100644 --- a/tornado/template.py +++ b/tornado/template.py @@ -172,7 +172,7 @@ with ``{# ... #}``. Same as the python ``while`` statement. """ -from __future__ import with_statement +from __future__ import absolute_import, with_statement import cStringIO import datetime diff --git a/tornado/test/auth_test.py b/tornado/test/auth_test.py index 204790409..06903a0bc 100644 --- a/tornado/test/auth_test.py +++ b/tornado/test/auth_test.py @@ -3,6 +3,8 @@ # and ensure that it doesn't blow up (e.g. with unicode/bytes issues in # python 3) + +from __future__ import absolute_import, with_statement from tornado.auth import OpenIdMixin, OAuthMixin, OAuth2Mixin from tornado.escape import json_decode from tornado.testing import AsyncHTTPTestCase, LogTrapTestCase diff --git a/tornado/test/curl_httpclient_test.py b/tornado/test/curl_httpclient_test.py index afa56f8f7..35aaf9758 100644 --- a/tornado/test/curl_httpclient_test.py +++ b/tornado/test/curl_httpclient_test.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import, with_statement from tornado.test.httpclient_test import HTTPClientCommonTestCase try: diff --git a/tornado/test/escape_test.py b/tornado/test/escape_test.py index 42ba50bbf..b34fcab50 100644 --- a/tornado/test/escape_test.py +++ b/tornado/test/escape_test.py @@ -1,5 +1,7 @@ #!/usr/bin/env python + +from __future__ import absolute_import, with_statement import tornado.escape import unittest diff --git a/tornado/test/gen_test.py b/tornado/test/gen_test.py index 935b40948..2f40e774d 100644 --- a/tornado/test/gen_test.py +++ b/tornado/test/gen_test.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import, with_statement import functools from tornado.escape import url_escape from tornado.httpclient import AsyncHTTPClient diff --git a/tornado/test/httpclient_test.py b/tornado/test/httpclient_test.py index 8388338b4..bf1e19cd2 100644 --- a/tornado/test/httpclient_test.py +++ b/tornado/test/httpclient_test.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -from __future__ import with_statement +from __future__ import absolute_import, with_statement import base64 import binascii diff --git a/tornado/test/httpserver_test.py b/tornado/test/httpserver_test.py index 132af561b..ba0e18d2e 100644 --- a/tornado/test/httpserver_test.py +++ b/tornado/test/httpserver_test.py @@ -1,5 +1,7 @@ #!/usr/bin/env python + +from __future__ import absolute_import, with_statement from tornado import httpclient, simple_httpclient, netutil from tornado.escape import json_decode, utf8, _unicode, recursive_unicode, native_str from tornado.httpserver import HTTPServer diff --git a/tornado/test/httputil_test.py b/tornado/test/httputil_test.py index e2f4421c9..00f740d82 100644 --- a/tornado/test/httputil_test.py +++ b/tornado/test/httputil_test.py @@ -1,5 +1,7 @@ #!/usr/bin/env python + +from __future__ import absolute_import, with_statement from tornado.httputil import url_concat, parse_multipart_form_data, HTTPHeaders from tornado.escape import utf8 from tornado.testing import LogTrapTestCase diff --git a/tornado/test/import_test.py b/tornado/test/import_test.py index 7da1a1ef9..7a25fdb5a 100644 --- a/tornado/test/import_test.py +++ b/tornado/test/import_test.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import, with_statement import unittest class ImportTest(unittest.TestCase): diff --git a/tornado/test/ioloop_test.py b/tornado/test/ioloop_test.py index 74bb60282..b01afce13 100644 --- a/tornado/test/ioloop_test.py +++ b/tornado/test/ioloop_test.py @@ -1,5 +1,7 @@ #!/usr/bin/env python + +from __future__ import absolute_import, with_statement import datetime import unittest import time diff --git a/tornado/test/iostream_test.py b/tornado/test/iostream_test.py index 895a3de95..0509205f9 100644 --- a/tornado/test/iostream_test.py +++ b/tornado/test/iostream_test.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import, with_statement from tornado import netutil from tornado.ioloop import IOLoop from tornado.iostream import IOStream diff --git a/tornado/test/process_test.py b/tornado/test/process_test.py index de9ae523b..1546f3dde 100644 --- a/tornado/test/process_test.py +++ b/tornado/test/process_test.py @@ -1,5 +1,7 @@ #!/usr/bin/env python + +from __future__ import absolute_import, with_statement import logging import os import signal diff --git a/tornado/test/run_pyversion_tests.py b/tornado/test/run_pyversion_tests.py index 8c4e9671c..672d49561 100755 --- a/tornado/test/run_pyversion_tests.py +++ b/tornado/test/run_pyversion_tests.py @@ -1,6 +1,8 @@ #!/usr/bin/env python """Runs the tornado test suite with all supported python interpreters.""" +from __future__ import absolute_import, with_statement + import os import subprocess import sys diff --git a/tornado/test/runtests.py b/tornado/test/runtests.py index 92bd2ac0a..14782ac7b 100755 --- a/tornado/test/runtests.py +++ b/tornado/test/runtests.py @@ -1,4 +1,6 @@ #!/usr/bin/env python + +from __future__ import absolute_import, with_statement import unittest TEST_MODULES = [ diff --git a/tornado/test/simple_httpclient_test.py b/tornado/test/simple_httpclient_test.py index 030876beb..4d241b027 100644 --- a/tornado/test/simple_httpclient_test.py +++ b/tornado/test/simple_httpclient_test.py @@ -1,4 +1,4 @@ -from __future__ import with_statement +from __future__ import absolute_import, with_statement import collections import gzip diff --git a/tornado/test/stack_context_test.py b/tornado/test/stack_context_test.py index b79f1e328..1fbfa4d72 100644 --- a/tornado/test/stack_context_test.py +++ b/tornado/test/stack_context_test.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -from __future__ import with_statement +from __future__ import absolute_import, with_statement from tornado.stack_context import StackContext, wrap from tornado.testing import AsyncHTTPTestCase, AsyncTestCase, LogTrapTestCase diff --git a/tornado/test/template_test.py b/tornado/test/template_test.py index c2a05333a..bf9b3f039 100644 --- a/tornado/test/template_test.py +++ b/tornado/test/template_test.py @@ -1,4 +1,4 @@ -from __future__ import with_statement +from __future__ import absolute_import, with_statement import traceback diff --git a/tornado/test/testing_test.py b/tornado/test/testing_test.py index bdca031ed..3a40fb4af 100644 --- a/tornado/test/testing_test.py +++ b/tornado/test/testing_test.py @@ -1,4 +1,6 @@ #!/usr/bin/env python + +from __future__ import absolute_import, with_statement import unittest from tornado.testing import AsyncTestCase, LogTrapTestCase diff --git a/tornado/test/twisted_test.py b/tornado/test/twisted_test.py index ba53c7897..9d4e5c9d8 100644 --- a/tornado/test/twisted_test.py +++ b/tornado/test/twisted_test.py @@ -17,6 +17,8 @@ Unittest for the twisted-style reactor. """ +from __future__ import absolute_import, with_statement + import os import thread import threading diff --git a/tornado/test/web_test.py b/tornado/test/web_test.py index 9f4c860eb..c84755523 100644 --- a/tornado/test/web_test.py +++ b/tornado/test/web_test.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import, with_statement from tornado.escape import json_decode, utf8, to_unicode, recursive_unicode, native_str from tornado.iostream import IOStream from tornado.template import DictLoader diff --git a/tornado/test/wsgi_test.py b/tornado/test/wsgi_test.py index 9c3ff7fd5..ac4564e4f 100644 --- a/tornado/test/wsgi_test.py +++ b/tornado/test/wsgi_test.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import, with_statement from wsgiref.validate import validator from tornado.testing import AsyncHTTPTestCase, LogTrapTestCase diff --git a/tornado/testing.py b/tornado/testing.py index b2b983dd0..15b59ae0f 100644 --- a/tornado/testing.py +++ b/tornado/testing.py @@ -18,7 +18,7 @@ inheritance. See the docstrings for each class/function below for more information. """ -from __future__ import with_statement +from __future__ import absolute_import, with_statement from cStringIO import StringIO try: diff --git a/tornado/util.py b/tornado/util.py index 6752401af..f597becb7 100644 --- a/tornado/util.py +++ b/tornado/util.py @@ -1,5 +1,7 @@ """Miscellaneous utility functions.""" +from __future__ import absolute_import, with_statement + class ObjectDict(dict): """Makes a dictionary behave like an object.""" def __getattr__(self, name): diff --git a/tornado/web.py b/tornado/web.py index c31eb674b..910089362 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -49,7 +49,7 @@ threads it is important to use IOLoop.add_callback to transfer control back to the main thread before finishing the request. """ -from __future__ import with_statement +from __future__ import absolute_import, with_statement import Cookie import base64 diff --git a/tornado/websocket.py b/tornado/websocket.py index 8aa777716..773b94bfc 100644 --- a/tornado/websocket.py +++ b/tornado/websocket.py @@ -16,6 +16,8 @@ communication between the browser and server. overriding `WebSocketHandler.allow_draft76` (see that method's documentation for caveats). """ + +from __future__ import absolute_import, with_statement # Author: Jacob Kristhammar, 2010 import array diff --git a/tornado/wsgi.py b/tornado/wsgi.py index e8f878bb4..08ce4eaa9 100644 --- a/tornado/wsgi.py +++ b/tornado/wsgi.py @@ -29,6 +29,8 @@ provides WSGI support in two ways: and Tornado handlers in a single server. """ +from __future__ import absolute_import, with_statement + import Cookie import cgi import httplib