From 4d469487b968df55e2bfdf70f7f5276ac7f93153 Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Sat, 15 Jun 2024 20:39:36 +0200 Subject: [PATCH] remove Python2 crumbs --- pywebdav/lib/AuthServer.py | 1 - pywebdav/lib/INI_Parse.py | 7 +------ pywebdav/lib/WebDAVServer.py | 16 +++++++--------- pywebdav/lib/davcmd.py | 1 - pywebdav/lib/davcopy.py | 2 -- pywebdav/lib/davmove.py | 1 - pywebdav/lib/dbconn.py | 2 -- pywebdav/lib/delete.py | 2 -- pywebdav/lib/iface.py | 1 - pywebdav/lib/locks.py | 1 - pywebdav/lib/propfind.py | 1 - pywebdav/lib/report.py | 1 - pywebdav/lib/utils.py | 1 - pywebdav/server/daemonize.py | 2 -- pywebdav/server/fileauth.py | 2 -- pywebdav/server/fshandler.py | 9 ++------- pywebdav/server/mysqlauth.py | 2 -- pywebdav/server/server.py | 2 -- setup.py | 1 - 19 files changed, 10 insertions(+), 45 deletions(-) diff --git a/pywebdav/lib/AuthServer.py b/pywebdav/lib/AuthServer.py index d9092c7..15ab3e8 100644 --- a/pywebdav/lib/AuthServer.py +++ b/pywebdav/lib/AuthServer.py @@ -4,7 +4,6 @@ """ -from __future__ import absolute_import import base64 import binascii import six.moves.BaseHTTPServer diff --git a/pywebdav/lib/INI_Parse.py b/pywebdav/lib/INI_Parse.py index eb9e06d..3be27cd 100644 --- a/pywebdav/lib/INI_Parse.py +++ b/pywebdav/lib/INI_Parse.py @@ -1,9 +1,4 @@ -from __future__ import absolute_import -from __future__ import print_function -try: - from configparser import ConfigParser -except ImportError: - from six.moves.configparser import SafeConfigParser as ConfigParser +from configparser import ConfigParser class Configuration: def __init__(self, fileName): diff --git a/pywebdav/lib/WebDAVServer.py b/pywebdav/lib/WebDAVServer.py index 42dcf7d..85d6a66 100644 --- a/pywebdav/lib/WebDAVServer.py +++ b/pywebdav/lib/WebDAVServer.py @@ -3,7 +3,6 @@ This module builds on BaseHTTPServer and implements DAV commands """ -from __future__ import absolute_import from . import AuthServer from six.moves import urllib import logging @@ -25,7 +24,6 @@ from pywebdav import __version__ from xml.parsers.expat import ExpatError -import six log = logging.getLogger(__name__) @@ -77,7 +75,7 @@ def send_body(self, DATA, code=None, msg=None, desc=None, and len(DATA) > self.encode_threshold: buffer = io.BytesIO() output = gzip.GzipFile(mode='wb', fileobj=buffer) - if isinstance(DATA, str) or isinstance(DATA, six.text_type): + if isinstance(DATA, str): output.write(DATA) else: for buf in DATA: @@ -98,7 +96,7 @@ def send_body(self, DATA, code=None, msg=None, desc=None, if DATA: if isinstance(DATA, str): DATA = DATA.encode('utf-8') - if isinstance(DATA, six.text_type) or isinstance(DATA, bytes): + if isinstance(DATA, str) or isinstance(DATA, bytes): log.debug("Don't use iterator") self.wfile.write(DATA) else: @@ -152,7 +150,7 @@ def send_body_chunks(self, DATA, code, msg=None, desc=None, output.write(DATA) else: for buf in DATA: - buf = buf.encode() if isinstance(buf, six.text_type) else buf + buf = buf.encode() if isinstance(buf, str) else buf output.write(buf) output.close() buffer.seek(0) @@ -171,8 +169,8 @@ def send_body_chunks(self, DATA, code, msg=None, desc=None, self.wfile.write(GZDATA) elif DATA: - DATA = DATA.encode() if isinstance(DATA, six.text_type) else DATA - if isinstance(DATA, six.binary_type): + DATA = DATA.encode() if isinstance(DATA, str) else DATA + if isinstance(DATA, bytes): self.wfile.write(b"%s\r\n" % hex(len(DATA))[2:].encode()) self.wfile.write(DATA) self.wfile.write(b"\r\n") @@ -182,7 +180,7 @@ def send_body_chunks(self, DATA, code, msg=None, desc=None, if self._config.DAV.getboolean('http_response_use_iterator'): # Use iterator to reduce using memory for buf in DATA: - buf = buf.encode() if isinstance(buf, six.text_type) else buf + buf = buf.encode() if isinstance(buf, str) else buf self.wfile.write((hex(len(buf))[2:] + "\r\n").encode()) self.wfile.write(buf) self.wfile.write(b"\r\n") @@ -273,7 +271,7 @@ def _HEAD_GET(self, with_body=False): if with_body is False: data = None - if isinstance(data, str) or isinstance(data, six.text_type): + if isinstance(data, str): self.send_body(data, status_code, None, None, content_type, headers) else: diff --git a/pywebdav/lib/davcmd.py b/pywebdav/lib/davcmd.py index 1387de0..e4493e3 100644 --- a/pywebdav/lib/davcmd.py +++ b/pywebdav/lib/davcmd.py @@ -8,7 +8,6 @@ """ -from __future__ import absolute_import from six.moves import urllib from .utils import create_treelist, is_prefix diff --git a/pywebdav/lib/davcopy.py b/pywebdav/lib/davcopy.py index ceda983..823fad9 100644 --- a/pywebdav/lib/davcopy.py +++ b/pywebdav/lib/davcopy.py @@ -1,8 +1,6 @@ -from __future__ import absolute_import import xml.dom.minidom domimpl = xml.dom.minidom.getDOMImplementation() -import sys import string from six.moves import urllib from io import StringIO diff --git a/pywebdav/lib/davmove.py b/pywebdav/lib/davmove.py index fd5a80a..cf03161 100644 --- a/pywebdav/lib/davmove.py +++ b/pywebdav/lib/davmove.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from six.moves import urllib from . import utils diff --git a/pywebdav/lib/dbconn.py b/pywebdav/lib/dbconn.py index c27b210..b50eb1c 100644 --- a/pywebdav/lib/dbconn.py +++ b/pywebdav/lib/dbconn.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import import logging log = logging.getLogger(__name__) @@ -9,7 +8,6 @@ log.info('No SQL support - MySQLdb missing...') pass -import sys class Mconn: def connect(self,username,userpasswd,host,port,db): diff --git a/pywebdav/lib/delete.py b/pywebdav/lib/delete.py index 43970b6..41de869 100644 --- a/pywebdav/lib/delete.py +++ b/pywebdav/lib/delete.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from .utils import gen_estring, quote_uri, make_xmlresponse from .davcmd import deltree diff --git a/pywebdav/lib/iface.py b/pywebdav/lib/iface.py index c9c03d7..028c584 100644 --- a/pywebdav/lib/iface.py +++ b/pywebdav/lib/iface.py @@ -7,7 +7,6 @@ """ -from __future__ import absolute_import from xml.dom import minidom from .locks import LockManager from .errors import * diff --git a/pywebdav/lib/locks.py b/pywebdav/lib/locks.py index 7c6158d..c928f7c 100644 --- a/pywebdav/lib/locks.py +++ b/pywebdav/lib/locks.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import import time from six.moves import urllib import uuid diff --git a/pywebdav/lib/propfind.py b/pywebdav/lib/propfind.py index 2cd08d5..bc2ea20 100644 --- a/pywebdav/lib/propfind.py +++ b/pywebdav/lib/propfind.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import import xml.dom.minidom domimpl = xml.dom.minidom.getDOMImplementation() diff --git a/pywebdav/lib/report.py b/pywebdav/lib/report.py index 7d589d4..d541be1 100644 --- a/pywebdav/lib/report.py +++ b/pywebdav/lib/report.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from .propfind import PROPFIND from xml.dom import minidom domimpl = minidom.getDOMImplementation() diff --git a/pywebdav/lib/utils.py b/pywebdav/lib/utils.py index 80c5055..ec9f631 100755 --- a/pywebdav/lib/utils.py +++ b/pywebdav/lib/utils.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import import time import re import os diff --git a/pywebdav/server/daemonize.py b/pywebdav/server/daemonize.py index a8f30a1..061430e 100644 --- a/pywebdav/server/daemonize.py +++ b/pywebdav/server/daemonize.py @@ -41,8 +41,6 @@ http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012 ''' -from __future__ import absolute_import -from __future__ import print_function import sys, os, time from signal import SIGTERM diff --git a/pywebdav/server/fileauth.py b/pywebdav/server/fileauth.py index 889ac19..fefbbd6 100644 --- a/pywebdav/server/fileauth.py +++ b/pywebdav/server/fileauth.py @@ -22,8 +22,6 @@ """ -from __future__ import absolute_import -import sys import logging from pywebdav.lib.WebDAVServer import DAVRequestHandler diff --git a/pywebdav/server/fshandler.py b/pywebdav/server/fshandler.py index 618942f..d460a42 100644 --- a/pywebdav/server/fshandler.py +++ b/pywebdav/server/fshandler.py @@ -1,7 +1,5 @@ -from __future__ import absolute_import import os import textwrap -import six import logging import types import shutil @@ -11,10 +9,7 @@ from pywebdav.lib.errors import * from pywebdav.lib.iface import * from pywebdav.lib.davcmd import copyone, copytree, moveone, movetree, delone, deltree -if six.PY2: - from cgi import escape -else: - from html import escape +from html import escape log = logging.getLogger(__name__) @@ -29,7 +24,7 @@ log.info('Mimetype support DISABLED') pass -class Resource(object): +class Resource: # XXX this class is ugly def __init__(self, fp, file_size): self.__fp = fp diff --git a/pywebdav/server/mysqlauth.py b/pywebdav/server/mysqlauth.py index 0a27f68..45c1b65 100644 --- a/pywebdav/server/mysqlauth.py +++ b/pywebdav/server/mysqlauth.py @@ -15,8 +15,6 @@ #Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, #MA 02111-1307, USA -from __future__ import absolute_import -from __future__ import print_function from .fileauth import DAVAuthHandler import sys diff --git a/pywebdav/server/server.py b/pywebdav/server/server.py index 42c1402..23246d0 100755 --- a/pywebdav/server/server.py +++ b/pywebdav/server/server.py @@ -7,8 +7,6 @@ """ -from __future__ import absolute_import -from __future__ import print_function import getopt, sys, os import logging diff --git a/setup.py b/setup.py index 42b53a0..eaddabc 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -from __future__ import absolute_import from setuptools import setup, find_packages from io import open import os