summaryrefslogtreecommitdiff
path: root/paste/deploy
diff options
context:
space:
mode:
Diffstat (limited to 'paste/deploy')
-rw-r--r--paste/deploy/config.py8
-rw-r--r--paste/deploy/loadwsgi.py31
-rw-r--r--paste/deploy/util.py2
3 files changed, 12 insertions, 29 deletions
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 @@ class DispatchingConfig(object):
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 @@ class PrefixMiddleware(object):
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 @@ class NicerConfigParser(ConfigParser):
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 @@ class NicerConfigParser(ConfigParser):
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 @@ class NicerConfigParser(ConfigParser):
############################################################
-class _ObjectType(object):
+class _ObjectType:
name = None
egg_protocols = None
@@ -125,7 +108,7 @@ class _ObjectType(object):
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 @@ _loaders['call'] = _loadfunc
############################################################
-class _Loader(object):
+class _Loader:
def get_app(self, name=None, global_conf=None):
return self.app_context(
@@ -694,7 +677,7 @@ class FuncLoader(_Loader):
)
-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