Skip to content

Commit

Permalink
Use Python 3 syntax for inheriting from object.
Browse files Browse the repository at this point in the history
More elegant.
  • Loading branch information
Dusty Phillips committed Jan 24, 2010
1 parent 639fe53 commit da9d38a
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 31 deletions.
6 changes: 3 additions & 3 deletions psyclone/auth.py
Expand Up @@ -59,7 +59,7 @@ def _on_auth(self, user):
import uuid


class OpenIdMixin(object):
class OpenIdMixin:
"""Abstract implementation of OpenID and Attribute Exchange.
See GoogleMixin below for example implementations.
Expand Down Expand Up @@ -195,7 +195,7 @@ def get_ax_arg(uri):
callback(user)


class OAuthMixin(object):
class OAuthMixin:
"""Abstract implementation of OAuth.
See TwitterMixin and FriendFeedMixin below for example implementations.
Expand Down Expand Up @@ -661,7 +661,7 @@ def _oauth_get_user(self, access_token, callback):
OpenIdMixin.get_authenticated_user(self, callback)


class FacebookMixin(object):
class FacebookMixin:
"""Facebook Connect authentication.
To authenticate with Facebook, register your application with
Expand Down
8 changes: 4 additions & 4 deletions psyclone/httpclient.py
Expand Up @@ -29,7 +29,7 @@
import time


class HTTPClient(object):
class HTTPClient:
"""A blocking HTTP client backed with pycurl.
Typical usage looks like this:
Expand Down Expand Up @@ -75,7 +75,7 @@ def fetch(self, request, **kwargs):
buffer.close()


class AsyncHTTPClient(object):
class AsyncHTTPClient:
"""An non-blocking HTTP client backed with pycurl.
Example usage:
Expand Down Expand Up @@ -250,7 +250,7 @@ def _finish(self, curl, curl_error=None, curl_message=None):
request_time=time.time() - info["start_time"]))


class HTTPRequest(object):
class HTTPRequest:
def __init__(self, url, method="GET", headers={}, body=None,
auth_username=None, auth_password=None,
connect_timeout=None, request_timeout=None,
Expand Down Expand Up @@ -279,7 +279,7 @@ def __init__(self, url, method="GET", headers={}, body=None,
self.streaming_callback = streaming_callback


class HTTPResponse(object):
class HTTPResponse:
def __init__(self, request, code, headers={}, body="", effective_url=None,
error=None, request_time=None):
self.request = request
Expand Down
6 changes: 3 additions & 3 deletions psyclone/httpserver.py
Expand Up @@ -33,7 +33,7 @@
ssl = None


class HTTPServer(object):
class HTTPServer:
"""A non-blocking, single-threaded HTTP server.
A server is defined by a request callback that takes an HTTPRequest
Expand Down Expand Up @@ -208,7 +208,7 @@ def _handle_events(self, fd, events):
logging.error("Error in connection callback", exc_info=True)


class HTTPConnection(object):
class HTTPConnection:
"""Handles a connection to an HTTP client, executing HTTP requests.
We parse HTTP headers and bodies, and execute the request callback
Expand Down Expand Up @@ -334,7 +334,7 @@ def _parse_mime_body(self, boundary, data):
self._request.arguments.setdefault(name, []).append(value)


class HTTPRequest(object):
class HTTPRequest:
"""A single HTTP request.
GET/POST arguments are available in the arguments property, which
Expand Down
12 changes: 6 additions & 6 deletions psyclone/ioloop.py
Expand Up @@ -26,7 +26,7 @@
import time


class IOLoop(object):
class IOLoop:
"""A level-triggered I/O loop.
We use epoll if it is available, or else we fall back on select(). If
Expand Down Expand Up @@ -110,7 +110,7 @@ def instance(cls):
a default argument to enable programs with multiple IOLoops
but not require the argument for simpler applications:
class MyClass(object):
class MyClass:
def __init__(self, io_loop=None):
self.io_loop = io_loop or IOLoop.instance()
"""
Expand Down Expand Up @@ -276,7 +276,7 @@ def _set_nonblocking(self, fd):
fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)


class _Timeout(object):
class _Timeout:
"""An IOLoop timeout, a UNIX timestamp and a callback"""
def __init__(self, deadline, callback):
self.deadline = deadline
Expand All @@ -291,7 +291,7 @@ def __cmp__(self, other):
(other.deadline, id(other.callback)))


class PeriodicCallback(object):
class PeriodicCallback:
"""Schedules the given callback to be called periodically.
The callback is called every callback_time milliseconds.
Expand All @@ -318,7 +318,7 @@ def _run(self):
self.start()


class _KQueue(object):
class _KQueue:
"""A kqueue-based event loop for BSD/Mac systems."""
def __init__(self):
self._kqueue = select.kqueue()
Expand Down Expand Up @@ -359,7 +359,7 @@ def poll(self, timeout):
return events


class _Select(object):
class _Select:
"""A simple, select()-based IOLoop implementation for non-Linux systems"""
def __init__(self):
self.read_fds = set()
Expand Down
2 changes: 1 addition & 1 deletion psyclone/iostream.py
Expand Up @@ -22,7 +22,7 @@
import socket


class IOStream(object):
class IOStream:
"""A utility class to write to and read from a non-blocking socket.
We support three methods: write(), read_until(), and read_bytes().
Expand Down
2 changes: 1 addition & 1 deletion psyclone/locale.py
Expand Up @@ -133,7 +133,7 @@ def get_supported_locales(cls):
return _supported_locales


class Locale(object):
class Locale:
@classmethod
def get_closest(cls, *locale_codes):
"""Returns the closest match for the given locale code."""
Expand Down
2 changes: 1 addition & 1 deletion psyclone/options.py
Expand Up @@ -173,7 +173,7 @@ def __getattr__(self, name):
raise Error("Unrecognized option %r" % name)


class _Option(object):
class _Option:
def __init__(self, name, default=None, type=str, help=None, metavar=None,
multiple=False, file_name=None):
if default is None and multiple:
Expand Down
10 changes: 5 additions & 5 deletions psyclone/template.py
Expand Up @@ -89,7 +89,7 @@ def add(x, y):
import re


class Template(object):
class Template:
"""A compiled template.
We compile into Python from the given template_string. You can generate
Expand Down Expand Up @@ -158,7 +158,7 @@ def _get_ancestors(self, loader):
return ancestors


class Loader(object):
class Loader:
"""A template loader that loads from a single root directory.
You must use a template loader to use template constructs like
Expand Down Expand Up @@ -186,7 +186,7 @@ def load(self, name, parent_path=None):
return self.templates[name]


class _Node(object):
class _Node:
def each_child(self):
return ()

Expand Down Expand Up @@ -349,7 +349,7 @@ class ParseError(Exception):
pass


class _CodeWriter(object):
class _CodeWriter:
def __init__(self, file, named_blocks, loader, current_template,
compress_whitespace):
self.file = file
Expand Down Expand Up @@ -382,7 +382,7 @@ def write_line(self, line, indent=None):
print(line, file=self.file)


class _TemplateReader(object):
class _TemplateReader:
def __init__(self, name, text):
self.name = name
self.text = text
Expand Down
10 changes: 5 additions & 5 deletions psyclone/web.py
Expand Up @@ -71,7 +71,7 @@ def get(self):
import uuid


class RequestHandler(object):
class RequestHandler:
"""Subclass this class and define get() or post() to make a handler.
If you want to support more methods than the standard GET/HEAD/POST, you
Expand Down Expand Up @@ -848,7 +848,7 @@ def wrapper(self, *args, **kwargs):
return wrapper


class Application(object):
class Application:
"""A collection of request handlers that make up a web application.
Instances of this class are callable and can be passed directly to
Expand Down Expand Up @@ -1155,7 +1155,7 @@ def prepare(self):
self._finished = True


class OutputTransform(object):
class OutputTransform:
"""A transform modifies the result of an HTTP request (e.g., GZip encoding)
A new transform instance is created for every request. See the
Expand Down Expand Up @@ -1263,7 +1263,7 @@ def wrapper(self, *args, **kwargs):
return wrapper


class UIModule(object):
class UIModule:
"""A UI re-usable, modular unit on a page.
UI modules often execute additional queries, and they can include
Expand Down Expand Up @@ -1303,7 +1303,7 @@ def html_head(self):
def render_string(self, path, **kwargs):
return self.handler.render_string(path, **kwargs)

class URLSpec(object):
class URLSpec:
"""Specifies mappings between URLs and handlers."""
def __init__(self, pattern, handler_class, kwargs={}, name=None):
"""Creates a URLSpec.
Expand Down
4 changes: 2 additions & 2 deletions psyclone/wsgi.py
Expand Up @@ -84,7 +84,7 @@ def __call__(self, environ, start_response):
return handler._write_buffer


class HTTPRequest(object):
class HTTPRequest:
"""Mimics httpserver.HTTPRequest for WSGI applications."""
def __init__(self, environ):
"""Parses the given WSGI environ to construct the request."""
Expand Down Expand Up @@ -184,7 +184,7 @@ def _parse_mime_body(self, boundary):
self.arguments.setdefault(name, []).append(value)


class WSGIContainer(object):
class WSGIContainer:
"""Makes a WSGI-compatible function runnable on Tornado's HTTP server.
Wrap a WSGI function in a WSGIContainer and pass it to HTTPServer to
Expand Down

0 comments on commit da9d38a

Please sign in to comment.