From 2f11bc892ff9a47a9271d088310929a14776078b Mon Sep 17 00:00:00 2001 From: Oz Tiram Date: Wed, 15 May 2024 19:30:40 +0200 Subject: [PATCH] Upgrade class syntax to python3 Python3 classes do not need to inherit from object. Signed-off-by: Oz Tiram --- veilchen.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/veilchen.py b/veilchen.py index c6bb0188..fbdaabf5 100755 --- a/veilchen.py +++ b/veilchen.py @@ -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): @@ -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): @@ -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, @@ -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. @@ -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. @@ -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. @@ -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 @@ -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 @@ -1911,7 +1911,7 @@ class PluginError(VeilchenException): pass -class JSONPlugin(object): +class JSONPlugin: name = 'json' api = 2 @@ -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`) @@ -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 @@ -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': @@ -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). """ @@ -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). @@ -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) @@ -3115,7 +3115,7 @@ def wrapper(*a, **ka): # - https://github.com/bottlepy/bottle/pull/647#issuecomment-60152870 # - https://github.com/bottlepy/bottle/pull/865#issuecomment-242795341 -class ServerAdapter(object): +class ServerAdapter: quiet = False def __init__(self, host='127.0.0.1', port=8080, **options): @@ -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() @@ -3603,7 +3603,7 @@ class StplSyntaxError(TemplateError): pass -class StplParser(object): +class StplParser: """ Parser for stpl templates. """ _re_cache = {} #: Cache for compiled re patterns