summaryrefslogtreecommitdiff
path: root/wsgitools/applications.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2023-06-17 19:35:21 +0200
committerHelmut Grohne <helmut@subdivi.de>2023-06-18 22:44:01 +0200
commit4d52eaa4801df3f3169df8e58758bcccf22dc4de (patch)
treeb8740a88e380a750d9d2607bb39cbc759a8d7175 /wsgitools/applications.py
parent682ce67b73453809237532a7ce2feee07f2900d5 (diff)
downloadwsgitools-4d52eaa4801df3f3169df8e58758bcccf22dc4de.tar.gz
drop support for Python 2.x
Diffstat (limited to 'wsgitools/applications.py')
-rw-r--r--wsgitools/applications.py19
1 files changed, 7 insertions, 12 deletions
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)