Skip to content

Commit

Permalink
Upgrade class syntax to python3
Browse files Browse the repository at this point in the history
Python3 classes do not need to inherit from object.

Signed-off-by: Oz Tiram <[email protected]>
  • Loading branch information
oz123 committed May 15, 2024
1 parent 373ae10 commit 2f11bc8
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions veilchen.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def makelist(data): # This is just too handy
return []


class DictProperty(object):
class DictProperty:
""" Property that maps to a key in a local dict-like attribute. """

def __init__(self, attr, key=None, read_only=False):
Expand All @@ -177,7 +177,7 @@ def __delete__(self, obj):
del getattr(obj, self.attr)[self.key]


class lazy_attribute(object):
class lazy_attribute:
""" A property that caches itself to the class object. """

def __init__(self, func):
Expand Down Expand Up @@ -235,7 +235,7 @@ def _re_flatten(p):
len(m.group(1)) % 2 else m.group(1) + '(?:', p)


class Router(object):
class Router:
""" A Router is an ordered collection of route->target pairs. It is used to
efficiently match WSGI requests against a number of routes and return
the first target that satisfies the request. The target may be anything,
Expand Down Expand Up @@ -437,7 +437,7 @@ def match(self, environ):
raise HTTPError(404, "Not found: " + repr(path))


class Route(object):
class Route:
""" This class wraps a route callback along with route specific metadata and
configuration and applies Plugins on demand. It is also responsible for
turning an URL path rule into a regular expression usable by the Router.
Expand Down Expand Up @@ -548,7 +548,7 @@ def __repr__(self):
###############################################################################


class Veilchen(object):
class Veilchen:
""" Each Veilchen object represents a single, distinct web application and
consists of routes, callbacks, plugins, resources and configuration.
Instances are callable WSGI applications.
Expand Down Expand Up @@ -1087,7 +1087,7 @@ def __setattr__(self, name, value):
###############################################################################


class BaseRequest(object):
class BaseRequest:
""" A wrapper for WSGI environment dictionaries that adds a lot of
convenient access methods and properties. Most of them are read-only.
Expand Down Expand Up @@ -1550,7 +1550,7 @@ def _hval(value):
return value


class HeaderProperty(object):
class HeaderProperty:
def __init__(self, name, reader=None, writer=None, default=''):
self.name, self.default = name, default
self.reader, self.writer = reader, writer
Expand All @@ -1568,7 +1568,7 @@ def __delete__(self, obj):
del obj[self.name]


class BaseResponse(object):
class BaseResponse:
""" Storage class for a response body as well as headers and cookies.
This class does support dict-like case-insensitive item-access to
Expand Down Expand Up @@ -1911,7 +1911,7 @@ class PluginError(VeilchenException):
pass


class JSONPlugin(object):
class JSONPlugin:
name = 'json'
api = 2

Expand Down Expand Up @@ -1955,7 +1955,7 @@ def wrapper(*a, **ka):
return wrapper


class TemplatePlugin(object):
class TemplatePlugin:
""" This plugin applies the :func:`view` decorator to all routes with a
`template` config parameter. If the parameter is a tuple, the second
element must be a dict with additional options (e.g. `template_engine`)
Expand All @@ -1977,7 +1977,7 @@ def apply(self, callback, route):


#: Not a plugin, but part of the plugin API. TODO: Find a better place.
class _ImportRedirect(object):
class _ImportRedirect:
def __init__(self, name, impmask):
""" Create a virtual package that redirects imports (see PEP 302). """
self.name = name
Expand Down Expand Up @@ -2521,7 +2521,7 @@ def default(self):
return self.push()


class WSGIFileWrapper(object):
class WSGIFileWrapper:
def __init__(self, fp, buffer_size=1024 * 64):
self.fp, self.buffer_size = fp, buffer_size
for attr in 'fileno', 'close', 'read', 'readlines', 'tell', 'seek':
Expand All @@ -2535,7 +2535,7 @@ def __iter__(self):
part = read(buff)


class _closeiter(object):
class _closeiter:
""" This only exists to be able to attach a .close method to iterators that
do not support attribute assignment (most of itertools). """

Expand All @@ -2551,7 +2551,7 @@ def close(self):
func()


class ResourceManager(object):
class ResourceManager:
""" This class manages a list of search paths and helps to find and open
application-bound resources (files).
Expand Down Expand Up @@ -2637,7 +2637,7 @@ def open(self, name, mode='r', *args, **kwargs):
return self.opener(fname, mode=mode, *args, **kwargs)


class FileUpload(object):
class FileUpload:
def __init__(self, fileobj, name, filename, headers=None):
""" Wrapper for file uploads. """
#: Open file(-like) object (BytesIO buffer or temporary file)
Expand Down Expand Up @@ -3115,7 +3115,7 @@ def wrapper(*a, **ka):
# - https:/bottlepy/bottle/pull/647#issuecomment-60152870
# - https:/bottlepy/bottle/pull/865#issuecomment-242795341

class ServerAdapter(object):
class ServerAdapter:
quiet = False

def __init__(self, host='127.0.0.1', port=8080, **options):
Expand Down Expand Up @@ -3413,7 +3413,7 @@ class TemplateError(VeilchenException):
pass


class BaseTemplate(object):
class BaseTemplate:
""" Base class and minimal API for template adapters """
extensions = ['tpl', 'html', 'thtml', 'stpl']
settings = {} #used in prepare()
Expand Down Expand Up @@ -3603,7 +3603,7 @@ class StplSyntaxError(TemplateError):
pass


class StplParser(object):
class StplParser:
""" Parser for stpl templates. """
_re_cache = {} #: Cache for compiled re patterns

Expand Down

0 comments on commit 2f11bc8

Please sign in to comment.