Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:16.0:FactoryCandidates
python-bobo
drop-py27.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File drop-py27.patch of Package python-bobo
From 5a2f2ebbbb858b663ba7b283a250fb357d5e2afb Mon Sep 17 00:00:00 2001 From: Michael Howitz <mh@gocept.com> Date: Fri, 10 Feb 2023 10:10:12 +0100 Subject: [PATCH] Config with zope product template 2c7189fc (#23) * Drop support for Python 2.7 up to 3.6. * Remove not needed files. * Bumped version for breaking release. * Remove no necessary version pins. --- buildout.cfg | 8 -- setup.cfg | 22 ++++- setup.py | 18 ++--- src/bobo.py | 69 ++++++++-------- src/boboserver.py | 42 +++++----- tox.ini | 80 ++++++++++++------- 15 files changed, 239 insertions(+), 160 deletions(-) Index: bobo-2.4.0/src/bobo.py =================================================================== --- bobo-2.4.0.orig/src/bobo.py +++ bobo-2.4.0/src/bobo.py @@ -32,15 +32,15 @@ __all__ = ( 'subroute', ) -__metaclass__ = type import inspect import logging import re import sys +import urllib + import webob -import six -from six.moves import filter, urllib + log = logging.getLogger(__name__) @@ -50,7 +50,6 @@ _default_content_type = 'text/html; char _json_content_type = re.compile('application/json;?').match -getargspec = inspect.getargspec if six.PY2 else inspect.getfullargspec class Application: """Create a WSGI application. @@ -175,7 +174,7 @@ class Application: self.config = config bobo_configure = config.get('bobo_configure', '') - if isinstance(bobo_configure, six.string_types): + if isinstance(bobo_configure, str): bobo_configure = ( _get_global(name) for name in filter(None, _uncomment(bobo_configure).split()) @@ -185,7 +184,7 @@ class Application: bobo_errors = config.get('bobo_errors') if bobo_errors is not None: - if isinstance(bobo_errors, six.string_types): + if isinstance(bobo_errors, str): bobo_errors = _uncomment(bobo_errors) if ':' in bobo_errors: bobo_errors = _get_global(bobo_errors) @@ -198,7 +197,7 @@ class Application: _maybe_copy(bobo_errors, 'exception', self) bobo_resources = config.get('bobo_resources', '') - if isinstance(bobo_resources, six.string_types): + if isinstance(bobo_resources, str): bobo_resources = _uncomment(bobo_resources, True) if bobo_resources: self.handlers = _route_config(bobo_resources) @@ -208,7 +207,7 @@ class Application: self.handlers = [r.bobo_response for r in bobo_resources] handle_exceptions = config.get('bobo_handle_exceptions', True) - if isinstance(handle_exceptions, six.string_types): + if isinstance(handle_exceptions, str): handle_exceptions = handle_exceptions.lower() == 'true' self.reraise_exceptions = not handle_exceptions @@ -285,9 +284,9 @@ class Application: return response body = data.body - if isinstance(body, six.text_type): + if isinstance(body, str): response.text = body - elif isinstance(body, six.binary_type): + elif isinstance(body, bytes): response.body = body elif _json_content_type(content_type): import json @@ -328,7 +327,7 @@ def _err_response(status, method, title, response.unicode_body = _html_template % (title, message) return response -_html_template = u"""<html> +_html_template = """<html> <head><title>%s</title></head> <body>%s</body> </html> @@ -344,10 +343,7 @@ def redirect(url, status=302, body=None, in the ``url`` argument. """ if body is None: - body = u'See %s' % url - - # if isinstance(url, six.text_type): - # url = url.encode('utf-8') + body = 'See %s' % url response = webob.Response(status=status, headerlist=[('Location', url)]) response.content_type = content_type @@ -378,7 +374,7 @@ def _scan_module(module_name): return resources = [] - for resource in six.itervalues(module.__dict__): + for resource in module.__dict__.values(): bobo_response = getattr(resource, 'bobo_response', None) if bobo_response is None: continue @@ -457,7 +453,7 @@ def resources(resources): """ handlers = _MultiResource() for resource in resources: - if isinstance(resource, six.string_types): + if isinstance(resource, str): if ':' in resource: resource = _get_global(resource) else: @@ -475,13 +471,13 @@ def reroute(route, resource): The resource can be a string, in which case it should be a global name, of the form ``module:expression``. """ - if isinstance(resource, six.string_types): + if isinstance(resource, str): resource = _get_global(resource) try: bobo_reroute = resource.bobo_reroute except AttributeError: - if isinstance(resource, six.class_types): + if isinstance(resource, type): return Subroute(route, resource) raise TypeError("Expected a reroutable") return bobo_reroute(route) @@ -498,7 +494,7 @@ def preroute(route, resource): bobo_response function, then a resource is computed that tries each of the resources found in the module in order. """ - if isinstance(resource, six.string_types): + if isinstance(resource, str): if ':' in resource: resource = _get_global(resource) else: @@ -583,7 +579,7 @@ def early(): """ return order() + _early_base -class _cached_property(object): +class _cached_property: def __init__(self, func): self.func = func def __get__(self, inst, class_): @@ -610,7 +606,7 @@ class _Handler: if ext: route += '.'+ext.group(1) self.bobo_route = route - if isinstance(method, six.string_types): + if isinstance(method, str): method = (method, ) self.bobo_methods = method @@ -675,11 +671,11 @@ class _Handler: @property def func_code(self): - return six.get_function_code(self.bobo_original) + return self.bobo_original.__code__ @property def func_defaults(self): - return six.get_function_defaults(self.bobo_original) + return self.bobo_original.__defaults__ @property def __name__(self): @@ -703,7 +699,7 @@ class _UnboundHandler: return _BoundHandler(self.im_func, inst, self.im_class) def __repr__(self): - return "<unbound resource %s.%s>" % ( + return "<unbound resource {}.{}>".format( self.im_class.__name__, self.im_func.__name__, ) @@ -727,7 +723,7 @@ class _BoundHandler: self.im_class = class_ def __repr__(self): - return "<bound resource %s.%s of %r>" % ( + return "<bound resource {}.{} of {!r}>".format( self.im_class.__name__, self.im_func.__name__, self.im_self, @@ -741,12 +737,12 @@ class _BoundHandler: def _handler(route, func=None, **kw): if func is None: - if route is None or isinstance(route, six.string_types): + if route is None or isinstance(route, str): return lambda f: _handler(route, f, **kw) func = route route = None elif route is not None: - assert isinstance(route, six.string_types) + assert isinstance(route, str) if route and not route.startswith('/'): raise ValueError("Non-empty routes must start with '/'.", route) @@ -1192,7 +1188,7 @@ def _compile_route(route, partial=False) if m is None: return m path = path[len(m.group(0)):] - return (dict(item for item in six.iteritems(m.groupdict()) + return (dict(item for item in m.groupdict().items() if item[1] is not None), path, ) @@ -1204,7 +1200,7 @@ def _compile_route(route, partial=False) m = match(path) if m is None: return m - return dict(item for item in six.iteritems(m.groupdict()) + return dict(item for item in m.groupdict().items() if item[1] is not None) return route_data @@ -1229,7 +1225,7 @@ def _make_bobo_handle(func, original, ch _no_jget = {}.get def _make_caller(obj, paramsattr): - spec = getargspec(obj) + spec = inspect.getfullargspec(obj) nargs = nrequired = len(spec.args) if spec.defaults: nrequired -= len(spec.defaults) @@ -1301,7 +1297,7 @@ def _subroute(route, ob, scan): scan_class(ob) return _subroute_class(route, ob) - if isinstance(ob, six.class_types): + if isinstance(ob, type): return _subroute_class(route, ob) return Subroute(route, ob) @@ -1369,7 +1365,7 @@ def subroute(route=None, scan=False, ord if route is None: return lambda ob: _subroute('/'+ob.__name__, ob, scan) - if isinstance(route, six.string_types): + if isinstance(route, str): return lambda ob: _subroute(route, ob, scan) return _subroute('/'+route.__name__, route, scan) @@ -1434,7 +1430,7 @@ def scan_class(class_): resources = {} for c in reversed(inspect.getmro(class_)): - for name, resource in six.iteritems(c.__dict__): + for name, resource in c.__dict__.items(): br = getattr(resource, 'bobo_response', None) if br is None: continue @@ -1445,7 +1441,7 @@ def scan_class(class_): handlers = [] for (order, (name, resource)) in sorted( (order, (name, resource)) - for (name, (order, resource)) in six.iteritems(resources) + for (name, (order, resource)) in resources.items() ): route = getattr(resource, 'bobo_route', None) if route is not None: Index: bobo-2.4.0/src/boboserver.py =================================================================== --- bobo-2.4.0.orig/src/boboserver.py +++ bobo-2.4.0/src/boboserver.py @@ -13,9 +13,6 @@ ############################################################################## """Create WSGI-based web applications. """ -from __future__ import print_function -import six -from six.moves import map __all__ = ( 'Debug', @@ -24,20 +21,22 @@ __all__ = ( 'static', ) -__metaclass__ = type -import bobo +import mimetypes import optparse import os -import mimetypes -import pdb +import pdb # noqa: T100 import for pdb found import re import sys import traceback import types -import webob import wsgiref.simple_server +import webob + +import bobo + + mimetypes.init() def run_server(app, port): @@ -60,14 +59,14 @@ class Directory: for name in sorted(os.listdir(self.path)): if os.path.isdir(os.path.join(self.path, name)): name += '/' - links.append('<a href="%s">%s</a>' % (name, name)) + links.append('<a href="{}">{}</a>'.format(name, name)) return """<html> - <head><title>%s</title></head> + <head><title>{}</title></head> <body> - %s + {} </body> </html> - """ % (self.path[len(self.root):], '<br>\n '.join(links)) + """.format(self.path[len(self.root):], '<br>\n '.join(links)) @bobo.subroute('/:name') def traverse(self, request, name): @@ -93,7 +92,7 @@ class File: response.content_type = content_type try: response.body = open(self.path, 'rb').read() - except IOError: + except OSError: raise bobo.NotFound return response @@ -133,11 +132,11 @@ class Reload: mtimes[name] = (filename, os.stat(filename).st_mtime) def __call__(self, environ, start_response): - for name, (path, mtime) in sorted(six.iteritems(self.mtimes)): + for name, (path, mtime) in sorted(self.mtimes.items()): if os.stat(path).st_mtime != mtime: print('Reloading %s' % name) - six.exec_(compile(open(path).read(), path, 'exec'), - sys.modules[name].__dict__) + exec(compile(open(path).read(), path, 'exec'), + sys.modules[name].__dict__) self.app.__init__(self.app.config) self.mtimes[name] = path, os.stat(path).st_mtime @@ -187,9 +186,7 @@ def server(args=None, Application=bobo.A import logging; logging.basicConfig() args = sys.argv[1:] - usage = "%prog [options] name=value ..." - if sys.version_info >= (2, 5): - usage = 'Usage: ' + usage + usage = "Usage: %prog [options] name=value ..." parser = optparse.OptionParser(usage) parser.add_option( '--port', '-p', type='int', dest='port', default=8080, @@ -223,8 +220,7 @@ def server(args=None, Application=bobo.A for path in options.file or (): module = types.ModuleType(mname) module.__file__ = path - six.exec_(compile(open(module.__file__).read(), - module.__file__, 'exec'), + exec(compile(open(module.__file__).read(), module.__file__, 'exec'), module.__dict__) sys.modules[module.__name__] = module resources.append(module.__name__) @@ -232,7 +228,7 @@ def server(args=None, Application=bobo.A for s in options.static or (): route, path = s.split('=', 1) - resources.append("boboserver:static(%r,%r)" % (route, path)) + resources.append("boboserver:static({!r},{!r})".format(route, path)) if not resources: error("No resources were specified.") @@ -255,5 +251,5 @@ def server(args=None, Application=bobo.A if options.debug: app = Debug(app) - print("Serving %s on port %s..." % (resources, options.port)) + print("Serving {} on port {}...".format(resources, options.port)) run_server(app, options.port) Index: bobo-2.4.0/setup.py =================================================================== --- bobo-2.4.0.orig/setup.py +++ bobo-2.4.0/setup.py @@ -46,7 +46,7 @@ setup( long_description=read('README.rst') + '\n\n' + read('CHANGES.rst'), py_modules = ['bobo', 'boboserver'], package_dir = {'':'src'}, - install_requires = ["WebOb", "six"], + install_requires = ["WebOb"], entry_points = entry_points, tests_require = [ 'bobodoctestumentation >=%s, <%s.999' % (version, version)], Index: bobo-2.4.0/src/bobo.egg-info/requires.txt =================================================================== --- bobo-2.4.0.orig/src/bobo.egg-info/requires.txt +++ bobo-2.4.0/src/bobo.egg-info/requires.txt @@ -1,2 +1 @@ WebOb -six
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor