Skip to content

Commit

Permalink
remove Python2 crumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
a-detiste authored and andrewleech committed Jul 2, 2024
1 parent 1fcfd7a commit 4d46948
Show file tree
Hide file tree
Showing 19 changed files with 10 additions and 45 deletions.
1 change: 0 additions & 1 deletion pywebdav/lib/AuthServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""

from __future__ import absolute_import
import base64
import binascii
import six.moves.BaseHTTPServer
Expand Down
7 changes: 1 addition & 6 deletions pywebdav/lib/INI_Parse.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
16 changes: 7 additions & 9 deletions pywebdav/lib/WebDAVServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,7 +24,6 @@
from pywebdav import __version__

from xml.parsers.expat import ExpatError
import six

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion pywebdav/lib/davcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"""

from __future__ import absolute_import
from six.moves import urllib

from .utils import create_treelist, is_prefix
Expand Down
2 changes: 0 additions & 2 deletions pywebdav/lib/davcopy.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion pywebdav/lib/davmove.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import absolute_import
from six.moves import urllib

from . import utils
Expand Down
2 changes: 0 additions & 2 deletions pywebdav/lib/dbconn.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import absolute_import
import logging

log = logging.getLogger(__name__)
Expand All @@ -9,7 +8,6 @@
log.info('No SQL support - MySQLdb missing...')
pass

import sys

class Mconn:
def connect(self,username,userpasswd,host,port,db):
Expand Down
2 changes: 0 additions & 2 deletions pywebdav/lib/delete.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import

from .utils import gen_estring, quote_uri, make_xmlresponse
from .davcmd import deltree

Expand Down
1 change: 0 additions & 1 deletion pywebdav/lib/iface.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""

from __future__ import absolute_import
from xml.dom import minidom
from .locks import LockManager
from .errors import *
Expand Down
1 change: 0 additions & 1 deletion pywebdav/lib/locks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import absolute_import
import time
from six.moves import urllib
import uuid
Expand Down
1 change: 0 additions & 1 deletion pywebdav/lib/propfind.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import absolute_import
import xml.dom.minidom
domimpl = xml.dom.minidom.getDOMImplementation()

Expand Down
1 change: 0 additions & 1 deletion pywebdav/lib/report.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import absolute_import
from .propfind import PROPFIND
from xml.dom import minidom
domimpl = minidom.getDOMImplementation()
Expand Down
1 change: 0 additions & 1 deletion pywebdav/lib/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import absolute_import
import time
import re
import os
Expand Down
2 changes: 0 additions & 2 deletions pywebdav/server/daemonize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions pywebdav/server/fileauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
"""

from __future__ import absolute_import
import sys
import logging

from pywebdav.lib.WebDAVServer import DAVRequestHandler
Expand Down
9 changes: 2 additions & 7 deletions pywebdav/server/fshandler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import absolute_import
import os
import textwrap
import six
import logging
import types
import shutil
Expand All @@ -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__)

Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions pywebdav/server/mysqlauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions pywebdav/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
"""

from __future__ import absolute_import
from __future__ import print_function
import getopt, sys, os
import logging

Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 4d46948

Please sign in to comment.