From 4d52eaa4801df3f3169df8e58758bcccf22dc4de Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Sat, 17 Jun 2023 19:35:21 +0200 Subject: drop support for Python 2.x --- wsgitools/applications.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'wsgitools/applications.py') diff --git a/wsgitools/applications.py b/wsgitools/applications.py index df304db..9894cf8 100644 --- a/wsgitools/applications.py +++ b/wsgitools/applications.py @@ -2,13 +2,8 @@ import os.path __all__ = [] -try: - basestring -except NameError: - basestring = str - __all__.append("StaticContent") -class StaticContent(object): +class StaticContent: """ This wsgi application provides static content on whatever request it receives with method GET or HEAD (content stripped). If not present, a @@ -60,7 +55,7 @@ class StaticContent(object): return self.content __all__.append("StaticFile") -class StaticFile(object): +class StaticFile: """ This wsgi application provides the content of a static file on whatever request it receives with method GET or HEAD (content stripped). If not @@ -94,7 +89,7 @@ class StaticFile(object): if not data: break yield data - if isinstance(self.filelike, basestring): + if isinstance(self.filelike, str): stream.close() def __call__(self, environ, start_response): @@ -110,7 +105,7 @@ class StaticFile(object): stream = None size = -1 try: - if isinstance(self.filelike, basestring): + if isinstance(self.filelike, str): # raises IOError stream = open(self.filelike, "rb") size = os.path.getsize(self.filelike) @@ -133,16 +128,16 @@ class StaticFile(object): start_response(self.status, headers) if environ["REQUEST_METHOD"].upper() == "HEAD": - if isinstance(self.filelike, basestring): + if isinstance(self.filelike, str): stream.close() return [] - if isinstance(self.filelike, basestring) and 'wsgi.file_wrapper' in environ: + if isinstance(self.filelike, str) and 'wsgi.file_wrapper' in environ: return environ['wsgi.file_wrapper'](stream, self.blocksize) if 0 <= size <= self.blocksize: data = stream.read(size) - if isinstance(self.filelike, basestring): + if isinstance(self.filelike, str): stream.close() return [data] return self._serve_in_chunks(stream) -- cgit v1.2.3