diff --git a/MANIFEST.in b/MANIFEST.in index 8586f10..938fb5c 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,14 @@ -include docs/*.txt -include license.txt +graft .github graft tests graft paste/deploy/paster_templates +include docs/*.txt +include license.txt +include pytest.ini +include tox.ini +include rtd.txt +include pyproject.toml +include contributing.md + global-exclude __pycache__ *.py[cod] global-exclude .DS_Store diff --git a/paste/deploy/config.py b/paste/deploy/config.py index a503007..f448350 100644 --- a/paste/deploy/config.py +++ b/paste/deploy/config.py @@ -24,7 +24,7 @@ def local_dict(): return result -class DispatchingConfig(object): +class DispatchingConfig: """ This is a configuration object that can be used globally, @@ -135,7 +135,7 @@ def __setitem__(self, key, value): CONFIG = DispatchingConfig() -class ConfigMiddleware(object): +class ConfigMiddleware: """ A WSGI middleware that adds a ``paste.config`` key to the request @@ -194,7 +194,7 @@ def make_config_filter(app, global_conf, **local_conf): make_config_middleware = ConfigMiddleware.__doc__ -class PrefixMiddleware(object): +class PrefixMiddleware: """Translate a given prefix into a SCRIPT_NAME for the filtered application. @@ -277,7 +277,7 @@ def __call__(self, environ, start_response): if self.force_port is not None: host = environ.get('HTTP_HOST', '').split(':', 1)[0] if self.force_port: - host = '%s:%s' % (host, self.force_port) + host = f'{host}:{self.force_port}' environ['SERVER_PORT'] = str(self.force_port) else: if environ['wsgi.url_scheme'] == 'http': diff --git a/paste/deploy/loadwsgi.py b/paste/deploy/loadwsgi.py index 2c8f827..c5471e5 100644 --- a/paste/deploy/loadwsgi.py +++ b/paste/deploy/loadwsgi.py @@ -58,10 +58,7 @@ class NicerConfigParser(ConfigParser): def __init__(self, filename, *args, **kw): ConfigParser.__init__(self, *args, **kw) self.filename = filename - if hasattr(self, '_interpolation'): - self._interpolation = self.InterpolateWrapper(self._interpolation) - - read_file = getattr(ConfigParser, 'read_file', ConfigParser.readfp) + self._interpolation = self.InterpolateWrapper(self._interpolation) def defaults(self): """Return the defaults, with their values interpolated (with the @@ -74,21 +71,7 @@ def defaults(self): defaults[key] = self.get('DEFAULT', key) or val return defaults - def _interpolate(self, section, option, rawval, vars): - # Python < 3.2 - try: - return ConfigParser._interpolate( - self, section, option, rawval, vars) - except Exception: - e = sys.exc_info()[1] - args = list(e.args) - args[0] = 'Error in file %s: %s' % (self.filename, e) - e.args = tuple(args) - e.message = args[0] - raise - - class InterpolateWrapper(object): - # Python >= 3.2 + class InterpolateWrapper: def __init__(self, original): self._original = original @@ -102,7 +85,7 @@ def before_get(self, parser, section, option, value, defaults): except Exception: e = sys.exc_info()[1] args = list(e.args) - args[0] = 'Error in file %s: %s' % (parser.filename, e) + args[0] = f'Error in file {parser.filename}: {e}' e.args = tuple(args) e.message = args[0] raise @@ -113,7 +96,7 @@ def before_get(self, parser, section, option, value, defaults): ############################################################ -class _ObjectType(object): +class _ObjectType: name = None egg_protocols = None @@ -125,7 +108,7 @@ def __init__(self): self.config_prefixes = [_aslist(p) for p in _aslist(self.config_prefixes)] def __repr__(self): - return '<%s protocols=%r prefixes=%r>' % ( + return '<{} protocols={!r} prefixes={!r}>'.format( self.name, self.egg_protocols, self.config_prefixes) def invoke(self, context): @@ -349,7 +332,7 @@ def _loadfunc(object_type, uri, spec, name, relative_to, ############################################################ -class _Loader(object): +class _Loader: def get_app(self, name=None, global_conf=None): return self.app_context( @@ -694,7 +677,7 @@ def get_context(self, object_type, name=None, global_conf=None): ) -class LoaderContext(object): +class LoaderContext: def __init__(self, obj, object_type, protocol, global_conf, local_conf, loader, diff --git a/paste/deploy/util.py b/paste/deploy/util.py index 2a56a07..d30466a 100644 --- a/paste/deploy/util.py +++ b/paste/deploy/util.py @@ -33,7 +33,7 @@ def fix_type_error(exc_info, callable, varargs, kwargs): kwargs = sorted(kwargs.items()) args += ', '.join(['%s=...' % n for n, v in kwargs]) gotspec = '(%s)' % args - msg = '%s; got %s, wanted %s' % (exc_info[1], gotspec, argspec) + msg = f'{exc_info[1]}; got {gotspec}, wanted {argspec}' exc_info[1].args = (msg,) return exc_info diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..89a9175 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools >= 41"] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg index f15c017..1544721 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,68 @@ -[wheel] -universal = true +[metadata] +name = PasteDeploy +version = 2.1.1 +author = Ian Bicking +author_email = pylons-discuss@googlegroups.com +maintainer = Chris Dent +maintainer_email = pylons-discuss@googlegroups.com +license = MIT +description = Load, configure, and compose WSGI applications and servers +keywords = + web + wsgi + application + server +url = https://docs.pylonsproject.org/projects/pastedeploy/en/latest/ +long_description = file: README.rst +long_description_content_type = text/x-rst +classifiers = + Development Status :: 6 - Mature + Intended Audience :: Developers + License :: OSI Approved :: MIT License + Programming Language :: Python + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: Implementation :: CPython + Programming Language :: Python :: Implementation :: PyPy + Topic :: Internet :: WWW/HTTP + Topic :: Internet :: WWW/HTTP :: Dynamic Content + Topic :: Internet :: WWW/HTTP :: WSGI + Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware + Topic :: Software Development :: Libraries :: Python Modules + Framework :: Paste +project_urls = + Documentation = https://docs.pylonsproject.org/projects/pastedeploy/en/latest/ + Changelog = https://docs.pylonsproject.org/projects/pastedeploy/en/latest/news.html + Issue Tracker = https://github.com/Pylons/pastedeploy/issues + +[options] +packages = find: +zip_safe = False +install_requires = + setuptools +include_package_data = True +namespace_packages = + paste + +[options.packages.find] +exclude = + tests + +[options.extras_require] +config = +paste = + Paste +docs = + Sphinx >= 1.7.5 + pylons-sphinx-themes + +[options.entry_points] +paste.filter_app_factory = + config = paste.deploy.config:make_config_filter [Config] + prefix = paste.deploy.config:make_prefix_middleware + +paste.paster_create_template = + paste_deploy = paste.deploy.paster_templates:PasteDeploy diff --git a/setup.py b/setup.py index 866112a..6068493 100644 --- a/setup.py +++ b/setup.py @@ -1,68 +1,3 @@ -import os +from setuptools import setup -from setuptools import setup, find_packages - -here = os.path.dirname(__file__) -readme_path = os.path.join(here, "README.rst") -readme = open(readme_path).read() - -docs_extras = [ - "Sphinx >= 1.7.5", # Read The Docs minimum version - "pylons-sphinx-themes", -] - -setup( - name="PasteDeploy", - version="3.0.dev0", - description="Load, configure, and compose WSGI applications and servers", - long_description=readme, - classifiers=[ - "Development Status :: 6 - Mature", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - "Topic :: Internet :: WWW/HTTP", - "Topic :: Internet :: WWW/HTTP :: Dynamic Content", - "Topic :: Internet :: WWW/HTTP :: WSGI", - "Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware", - "Topic :: Software Development :: Libraries :: Python Modules", - "Framework :: Paste", - ], - keywords="web wsgi application server", - author="Ian Bicking", - author_email="pylons-discuss@googlegroups.com", - maintainer="Chris Dent", - maintainer_email="pylons-discuss@googlegroups.com", - url="https://pylonsproject.org/", - project_urls={ - "Documentation": "https://docs.pylonsproject.org/projects/pastedeploy/en/latest/", - "Changelog": "https://docs.pylonsproject.org/projects/pastedeploy/en/latest/news.html", - "Issue Tracker": "https://github.com/Pylons/pastedeploy/issues", - }, - license="MIT", - namespace_packages=["paste"], - packages=find_packages(exclude=["tests"]), - include_package_data=True, - zip_safe=False, - install_requires=['setuptools'], - extras_require={ - "Config": [], - "Paste": ["Paste"], - "docs": docs_extras, - }, - entry_points=""" - [paste.filter_app_factory] - config = paste.deploy.config:make_config_filter [Config] - prefix = paste.deploy.config:make_prefix_middleware - - [paste.paster_create_template] - paste_deploy=paste.deploy.paster_templates:PasteDeploy - """ -) +setup() diff --git a/tests/fake_packages/FakeApp.egg/fakeapp/apps.py b/tests/fake_packages/FakeApp.egg/fakeapp/apps.py index cae7eba..9ab5183 100644 --- a/tests/fake_packages/FakeApp.egg/fakeapp/apps.py +++ b/tests/fake_packages/FakeApp.egg/fakeapp/apps.py @@ -35,7 +35,7 @@ def make_remote_addr(loader, global_conf, **conf): dispatcher.map[addrs[name]] = apps[name] return dispatcher -class RemoteAddrDispatch(object): +class RemoteAddrDispatch: def __init__(self, map=None): self.map = map or {} @@ -53,7 +53,7 @@ def cap_filter(app): return CapFilter(app, global_conf, method_to_call) return cap_filter -class CapFilter(object): +class CapFilter: def __init__(self, app, global_conf, method_to_call='upper'): self.app = app diff --git a/tests/fake_packages/FakeApp.egg/fakeapp/configapps.py b/tests/fake_packages/FakeApp.egg/fakeapp/configapps.py index ef13182..8e125e8 100644 --- a/tests/fake_packages/FakeApp.egg/fakeapp/configapps.py +++ b/tests/fake_packages/FakeApp.egg/fakeapp/configapps.py @@ -1,4 +1,4 @@ -class SimpleApp(object): +class SimpleApp: def __init__(self, global_conf, local_conf, name): self.global_conf = global_conf self.local_conf = local_conf