Permalink
Browse files

Update autopep8 to 0.8.5 and run it.

  • Loading branch information...
bdarnell committed Jan 19, 2013
1 parent 3a8a0eb commit e582e5879220937cf4ad67ac0947cc53724fadb7
Showing with 314 additions and 249 deletions.
  1. +2 −2 maint/requirements.txt
  2. +26 −26 tornado/auth.py
  3. +2 −1 tornado/autoreload.py
  4. +5 −0 tornado/concurrent.py
  5. +2 −2 tornado/curl_httpclient.py
  6. +1 −1 tornado/escape.py
  7. +2 −1 tornado/httpclient.py
  8. +2 −1 tornado/httpserver.py
  9. +2 −1 tornado/httputil.py
  10. +6 −6 tornado/ioloop.py
  11. +4 −1 tornado/iostream.py
  12. +5 −5 tornado/locale.py
  13. +19 −17 tornado/log.py
  14. +3 −3 tornado/netutil.py
  15. +3 −0 tornado/options.py
  16. +1 −1 tornado/platform/common.py
  17. +1 −0 tornado/platform/epoll.py
  18. +3 −2 tornado/platform/kqueue.py
  19. +2 −1 tornado/platform/select.py
  20. +4 −2 tornado/platform/twisted.py
  21. +2 −0 tornado/process.py
  22. +17 −17 tornado/simple_httpclient.py
  23. +6 −6 tornado/template.py
  24. +5 −3 tornado/test/auth_test.py
  25. +2 −1 tornado/test/concurrent_test.py
  26. +3 −2 tornado/test/curl_httpclient_test.py
  27. +5 −5 tornado/test/escape_test.py
  28. +7 −7 tornado/test/gen_test.py
  29. +5 −1 tornado/test/httpclient_test.py
  30. +32 −29 tornado/test/httpserver_test.py
  31. +19 −19 tornado/test/httputil_test.py
  32. +4 −0 tornado/test/ioloop_test.py
  33. +6 −2 tornado/test/iostream_test.py
  34. +2 −1 tornado/test/log_test.py
  35. +2 −0 tornado/test/netutil_test.py
  36. +2 −0 tornado/test/options_test.py
  37. +5 −3 tornado/test/process_test.py
  38. +4 −2 tornado/test/runtests.py
  39. +2 −2 tornado/test/simple_httpclient_test.py
  40. +1 −1 tornado/test/stack_context_test.py
  41. +15 −15 tornado/test/template_test.py
  42. +13 −11 tornado/test/twisted_test.py
  43. +4 −0 tornado/test/util_test.py
  44. +18 −12 tornado/test/web_test.py
  45. +4 −4 tornado/test/wsgi_test.py
  46. +7 −7 tornado/testing.py
  47. +1 −1 tornado/util.py
  48. +18 −17 tornado/web.py
  49. +8 −8 tornado/websocket.py
View
@@ -8,9 +8,9 @@ pycurl==7.19.0
# Other useful tools
Sphinx==1.1.3
-autopep8==0.8.1
+autopep8==0.8.5
coverage==3.5.2
-pep8==1.3.3
+pep8==1.4.1
pyflakes==0.5.0
tox==1.4.2
virtualenv==1.8.2
View
@@ -113,9 +113,9 @@ def _openid_args(self, callback_uri, ax_attrs=[], oauth_scope=None):
args = {
"openid.ns": "http://specs.openid.net/auth/2.0",
"openid.claimed_id":
- "http://specs.openid.net/auth/2.0/identifier_select",
+ "http://specs.openid.net/auth/2.0/identifier_select",
"openid.identity":
- "http://specs.openid.net/auth/2.0/identifier_select",
+ "http://specs.openid.net/auth/2.0/identifier_select",
"openid.return_to": url,
"openid.realm": urlparse.urljoin(url, '/'),
"openid.mode": "checkid_setup",
@@ -132,11 +132,11 @@ def _openid_args(self, callback_uri, ax_attrs=[], oauth_scope=None):
required += ["firstname", "fullname", "lastname"]
args.update({
"openid.ax.type.firstname":
- "http://axschema.org/namePerson/first",
+ "http://axschema.org/namePerson/first",
"openid.ax.type.fullname":
- "http://axschema.org/namePerson",
+ "http://axschema.org/namePerson",
"openid.ax.type.lastname":
- "http://axschema.org/namePerson/last",
+ "http://axschema.org/namePerson/last",
})
known_attrs = {
"email": "http://axschema.org/contact/email",
@@ -150,7 +150,7 @@ def _openid_args(self, callback_uri, ax_attrs=[], oauth_scope=None):
if oauth_scope:
args.update({
"openid.ns.oauth":
- "http://specs.openid.net/extensions/oauth/1.0",
+ "http://specs.openid.net/extensions/oauth/1.0",
"openid.oauth.consumer": self.request.host.split(":")[0],
"openid.oauth.scope": oauth_scope,
})
@@ -167,7 +167,7 @@ def _on_authentication_verified(self, callback, response):
ax_ns = None
for name in self.request.arguments.keys():
if name.startswith("openid.ns.") and \
- self.get_argument(name) == u("http://openid.net/srv/ax/1.0"):
+ self.get_argument(name) == u("http://openid.net/srv/ax/1.0"):
ax_ns = name[10:]
break
@@ -256,7 +256,7 @@ def authorize_redirect(self, callback_uri=None, extra_params=None,
self.async_callback(
self._on_request_token,
self._OAUTH_AUTHORIZE_URL,
- callback_uri))
+ callback_uri))
else:
http_client.fetch(
self._oauth_request_token_url(),
@@ -370,7 +370,7 @@ def _on_access_token(self, callback, response):
access_token = _oauth_parse_response(response.body)
self._oauth_get_user(access_token, self.async_callback(
- self._on_oauth_get_user, access_token, callback))
+ self._on_oauth_get_user, access_token, callback))
def _oauth_get_user(self, access_token, callback):
raise NotImplementedError()
@@ -403,7 +403,7 @@ def _oauth_request_parameters(self, url, access_token, parameters={},
args.update(parameters)
if getattr(self, "_OAUTH_VERSION", "1.0a") == "1.0a":
signature = _oauth10a_signature(consumer_token, method, url, args,
- access_token)
+ access_token)
else:
signature = _oauth_signature(consumer_token, method, url, args,
access_token)
@@ -433,13 +433,13 @@ def authorize_redirect(self, redirect_uri=None, client_id=None,
process.
"""
args = {
- "redirect_uri": redirect_uri,
- "client_id": client_id
+ "redirect_uri": redirect_uri,
+ "client_id": client_id
}
if extra_params:
args.update(extra_params)
self.redirect(
- url_concat(self._OAUTH_AUTHORIZE_URL, args))
+ url_concat(self._OAUTH_AUTHORIZE_URL, args))
def _oauth_request_token_url(self, redirect_uri=None, client_id=None,
client_secret=None, code=None,
@@ -450,7 +450,7 @@ def _oauth_request_token_url(self, redirect_uri=None, client_id=None,
code=code,
client_id=client_id,
client_secret=client_secret,
- )
+ )
if extra_params:
args.update(extra_params)
return url_concat(url, args)
@@ -508,7 +508,7 @@ def authenticate_redirect(self, callback_uri=None):
self._on_request_token, self._OAUTH_AUTHENTICATE_URL, None))
def twitter_request(self, path, callback, access_token=None,
- post_args=None, **args):
+ post_args=None, **args):
"""Fetches the given API path, e.g., "/statuses/user_timeline/btaylor"
The path should not include the format (we automatically append
@@ -771,7 +771,7 @@ def get_authenticated_user(self, callback):
oauth_ns = ""
for name, values in self.request.arguments.iteritems():
if name.startswith("openid.ns.") and \
- values[-1] == u("http://specs.openid.net/extensions/oauth/1.0"):
+ values[-1] == u("http://specs.openid.net/extensions/oauth/1.0"):
oauth_ns = name[10:]
break
token = self.get_argument("openid." + oauth_ns + ".request_token", "")
@@ -994,7 +994,7 @@ class FacebookGraphMixin(OAuth2Mixin):
_OAUTH_NO_CALLBACKS = False
def get_authenticated_user(self, redirect_uri, client_id, client_secret,
- code, callback, extra_fields=None):
+ code, callback, extra_fields=None):
"""Handles the login for the Facebook user, returning a user object.
Example usage::
@@ -1022,10 +1022,10 @@ def _on_login(self, user):
"""
http = self.get_auth_http_client()
args = {
- "redirect_uri": redirect_uri,
- "code": code,
- "client_id": client_id,
- "client_secret": client_secret,
+ "redirect_uri": redirect_uri,
+ "code": code,
+ "client_id": client_id,
+ "client_secret": client_secret,
}
fields = set(['id', 'name', 'first_name', 'last_name',
@@ -1034,11 +1034,11 @@ def _on_login(self, user):
fields.update(extra_fields)
http.fetch(self._oauth_request_token_url(**args),
- self.async_callback(self._on_access_token, redirect_uri, client_id,
- client_secret, callback, fields))
+ self.async_callback(self._on_access_token, redirect_uri, client_id,
+ client_secret, callback, fields))
def _on_access_token(self, redirect_uri, client_id, client_secret,
- callback, fields, response):
+ callback, fields, response):
if response.error:
gen_log.warning('Facebook auth error: %s' % str(response))
callback(None)
@@ -1056,7 +1056,7 @@ def _on_access_token(self, redirect_uri, client_id, client_secret,
self._on_get_user_info, callback, session, fields),
access_token=session["access_token"],
fields=",".join(fields)
- )
+ )
def _on_get_user_info(self, callback, session, fields, user):
if user is None:
@@ -1071,7 +1071,7 @@ def _on_get_user_info(self, callback, session, fields, user):
callback(fieldmap)
def facebook_request(self, path, callback, access_token=None,
- post_args=None, **args):
+ post_args=None, **args):
"""Fetches the given relative API path, e.g., "/btaylor/picture"
If the request is a POST, post_args should be provided. Query
View
@@ -92,6 +92,7 @@
_reload_attempted = False
_io_loops = weakref.WeakKeyDictionary()
+
def start(io_loop=None, check_time=500):
"""Restarts the process automatically when a module is modified.
@@ -205,7 +206,7 @@ def _reload():
# to ensure that the new process sees the same path we did.
path_prefix = '.' + os.pathsep
if (sys.path[0] == '' and
- not os.environ.get("PYTHONPATH", "").startswith(path_prefix)):
+ not os.environ.get("PYTHONPATH", "").startswith(path_prefix)):
os.environ["PYTHONPATH"] = (path_prefix +
os.environ.get("PYTHONPATH", ""))
if sys.platform == 'win32':
View
@@ -87,6 +87,7 @@ def _set_done(self):
else:
Future = futures.Future
+
class DummyExecutor(object):
def submit(self, fn, *args, **kwargs):
future = Future()
@@ -98,6 +99,7 @@ def submit(self, fn, *args, **kwargs):
dummy_executor = DummyExecutor()
+
def run_on_executor(fn):
@functools.wraps(fn)
def wrapper(self, *args, **kwargs):
@@ -109,13 +111,16 @@ def wrapper(self, *args, **kwargs):
return wrapper
# TODO: this needs a better name
+
+
def future_wrap(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
future = Future()
if kwargs.get('callback') is not None:
future.add_done_callback(kwargs.pop('callback'))
kwargs['callback'] = future.set_result
+
def handle_error(typ, value, tb):
future.set_exception(value)
return True
@@ -247,7 +247,7 @@ def _finish(self, curl, curl_error=None, curl_message=None):
starttransfer=curl.getinfo(pycurl.STARTTRANSFER_TIME),
total=curl.getinfo(pycurl.TOTAL_TIME),
redirect=curl.getinfo(pycurl.REDIRECT_TIME),
- )
+ )
try:
info["callback"](HTTPResponse(
request=info["request"], code=code, headers=info["headers"],
@@ -329,7 +329,7 @@ def _curl_setup_request(curl, request, buffer, headers):
curl.setopt(pycurl.PROXYPORT, request.proxy_port)
if request.proxy_username:
credentials = '%s:%s' % (request.proxy_username,
- request.proxy_password)
+ request.proxy_password)
curl.setopt(pycurl.PROXYUSERPWD, credentials)
else:
curl.setopt(pycurl.PROXY, '')
View
@@ -289,7 +289,7 @@ def make_link(m):
# (no more slug, etc), so it really just provides a little
# extra indication of shortening.
url = url[:proto_len] + parts[0] + "/" + \
- parts[1][:8].split('?')[0].split('.')[0]
+ parts[1][:8].split('?')[0].split('.')[0]
if len(url) > max_len * 1.5: # still too long
url = url[:max_len]
View
@@ -133,7 +133,7 @@ def configurable_default(cls):
def _async_clients(cls):
attr_name = '_async_client_dict_' + cls.__name__
if not hasattr(cls, attr_name):
- setattr(cls, attr_name, weakref.WeakKeyDictionary())
+ setattr(cls, attr_name, weakref.WeakKeyDictionary())
return getattr(cls, attr_name)
def __new__(cls, io_loop=None, force_instance=False, **kwargs):
@@ -406,6 +406,7 @@ def __init__(self, code, message=None, response=None):
self.response = response
Exception.__init__(self, "HTTP %d: %s" % (self.code, message))
+
class _RequestProxy(object):
"""Combines an object with a dictionary of defaults.
View
@@ -43,6 +43,7 @@ class except to start a server at the beginning of the process
except ImportError:
import http.cookies as Cookie # py3
+
class HTTPServer(TCPServer):
r"""A non-blocking, single-threaded HTTP server.
@@ -259,7 +260,7 @@ def _on_headers(self, data):
# HTTPRequest wants an IP, not a full socket address
if getattr(self.stream.socket, 'family', socket.AF_INET) in (
- socket.AF_INET, socket.AF_INET6):
+ socket.AF_INET, socket.AF_INET6):
# Jython 2.5.2 doesn't have the socket.family attribute,
# so just assume IP in that case.
remote_ip = self.address[0]
View
@@ -34,6 +34,7 @@
except ImportError:
from urllib.parse import urlencode # py3
+
class HTTPHeaders(dict):
"""A dictionary that maintains Http-Header-Case for all keys.
@@ -68,7 +69,7 @@ def __init__(self, *args, **kwargs):
self._as_list = {}
self._last_key = None
if (len(args) == 1 and len(kwargs) == 0 and
- isinstance(args[0], HTTPHeaders)):
+ isinstance(args[0], HTTPHeaders)):
# Copy constructor
for k, v in args[0].get_all():
self.add(k, v)
View
@@ -252,8 +252,8 @@ def log_stack(self, signal, frame):
For use with set_blocking_signal_threshold.
"""
gen_log.warning('IOLoop blocked for %f seconds in\n%s',
- self._blocking_signal_threshold,
- ''.join(traceback.format_stack(frame)))
+ self._blocking_signal_threshold,
+ ''.join(traceback.format_stack(frame)))
def start(self):
"""Starts the I/O loop.
@@ -351,6 +351,7 @@ def add_callback_from_signal(self, callback, *args, **kwargs):
_FUTURE_TYPES = (futures.Future, DummyFuture)
else:
_FUTURE_TYPES = DummyFuture
+
def add_future(self, future, callback):
"""Schedules a callback on the IOLoop when the given future is finished.
@@ -384,7 +385,6 @@ def handle_callback_exception(self, callback):
app_log.error("Exception in callback %r", callback, exc_info=True)
-
class PollIOLoop(IOLoop):
"""Base class for IOLoops built around a select-like function.
@@ -447,7 +447,7 @@ def remove_handler(self, fd):
def set_blocking_signal_threshold(self, seconds, action):
if not hasattr(signal, "setitimer"):
gen_log.error("set_blocking_signal_threshold requires a signal module "
- "with the setitimer method")
+ "with the setitimer method")
return
self._blocking_signal_threshold = seconds
if seconds is not None:
@@ -614,7 +614,7 @@ def add_callback(self, callback, *args, **kwargs):
raise RuntimeError("IOLoop is closing")
list_empty = not self._callbacks
self._callbacks.append(functools.partial(
- stack_context.wrap(callback), *args, **kwargs))
+ stack_context.wrap(callback), *args, **kwargs))
if list_empty and thread.get_ident() != self._thread_ident:
# If we're in the IOLoop's thread, we know it's not currently
# polling. If we're not, and we added the first callback to an
@@ -640,7 +640,7 @@ def add_callback_from_signal(self, callback, *args, **kwargs):
# either the old or new version of self._callbacks,
# but either way will work.
self._callbacks.append(functools.partial(
- stack_context.wrap(callback), *args, **kwargs))
+ stack_context.wrap(callback), *args, **kwargs))
class _Timeout(object):
View
@@ -45,9 +45,11 @@
except ImportError:
_set_nonblocking = None
+
class StreamClosedError(IOError):
pass
+
class BaseIOStream(object):
"""A utility class to write to and read from a non-blocking file or socket.
@@ -234,7 +236,7 @@ def close(self, exc_info=False):
def _maybe_run_close_callback(self):
if (self.closed() and self._close_callback and
- self._pending_callbacks == 0):
+ self._pending_callbacks == 0):
# if there are pending callbacks, don't run the close callback
# until they're done (see _maybe_add_error_handler)
cb = self._close_callback
@@ -818,6 +820,7 @@ def read_from_fd(self):
return None
return chunk
+
class PipeIOStream(BaseIOStream):
"""Pipe-based IOStream implementation.
Oops, something went wrong.

0 comments on commit e582e58

Please sign in to comment.