Skip to content

Commit

Permalink
Drop support for Python 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed Feb 11, 2020
1 parent c64cfa2 commit fea6b24
Show file tree
Hide file tree
Showing 28 changed files with 150 additions and 213 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Changelog
=========

3.3 (unreleased)
4.0 (unreleased)
----------------

- Drop support for Python 2.

3.2.2 (2020-02-04)
------------------
Expand Down
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
with open('CHANGES.rst') as f:
CHANGES = f.read()

version = '3.3.dev0'
version = '4.0.dev0'


setup(name='DocumentTemplate',
Expand Down Expand Up @@ -50,8 +50,6 @@
"License :: OSI Approved :: Zope Public License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
Expand All @@ -61,13 +59,13 @@
"Topic :: Text Processing :: Markup",
],
keywords='DTML template zope HTML SQL web markup',
python_requires='>=3.4, <4',
install_requires=[
'AccessControl >= 4.0a5',
'Acquisition',
'ExtensionClass>=4.1a1',
'RestrictedPython >= 4.0a1',
'roman',
'six',
'zExceptions',
'zope.sequencesort',
'zope.structuredtext',
Expand Down
4 changes: 2 additions & 2 deletions src/DocumentTemplate/DT_If.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
from .DT_Util import parse_params


class If(object):
class If:
blockContinuations = ('else', 'elif')
name = 'if'
elses = None
Expand Down Expand Up @@ -131,7 +131,7 @@ def __init__(self, blocks, encoding=None):
self.simple_form = ('i',) + tuple(sections)


class Unless(object):
class Unless:
name = 'unless'
blockContinuations = ()

Expand Down
21 changes: 9 additions & 12 deletions src/DocumentTemplate/DT_In.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,6 @@
import sys
from operator import itemgetter

import six

from zope.sequencesort.ssort import _Smallest

from ._DocumentTemplate import InstanceDict
Expand All @@ -352,17 +350,15 @@
from .DT_Util import simple_name


if sys.version_info > (3, 0):
unicode = str
def cmp(a, b):
return (a > b) - (a < b)

def cmp(a, b):
return (a > b) - (a < b)

TupleType = tuple
StringTypes = six.string_types + (six.binary_type,)
StringTypes = (str, bytes)


class InFactory(object):
class InFactory:
blockContinuations = ('else', )
name = 'in'

Expand All @@ -377,7 +373,7 @@ def __call__(self, blocks, encoding=None):
In = InFactory()


class InClass(object):
class InClass:
elses = None
expr = sort = batch = mapping = no_push_item = None
start_name_re = None
Expand Down Expand Up @@ -627,7 +623,7 @@ def renderwb(self, md):
if index == first:
pkw['sequence-start'] = 0
continue
raise ValidationError('(item %s): %s' % (
raise ValidationError('(item {}): {}'.format(
index, vv), sys.exc_info()[2])
else:
client = sequence[index]
Expand Down Expand Up @@ -741,7 +737,8 @@ def renderwob(self, md):
pkw['sequence-start'] = 0
continue
raise ValidationError(
'(item %s): %s' % (index, vv), sys.exc_info()[2])
'(item {}): {}'.format(index, vv),
sys.exc_info()[2])
else:
client = sequence[index]

Expand Down Expand Up @@ -955,7 +952,7 @@ def make_sortfunctions(sortfields, md):
return sf_list


class SortBy(object):
class SortBy:
def __init__(self, multsort, sf_list):
self.multsort = multsort
self.sf_list = sf_list
Expand Down
8 changes: 4 additions & 4 deletions src/DocumentTemplate/DT_InSV.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
TupleType = tuple


class sequence_variables(object):
class sequence_variables:

alt_prefix = None

Expand Down Expand Up @@ -203,7 +203,7 @@ def statistics(self, name, key):

# Initialize all stats to empty strings:
for stat in self.statistic_names:
data['%s-%s' % (stat, name)] = ''
data['{}-{}'.format(stat, name)] = ''

count = len(values)
try: # Numeric statistics
Expand Down Expand Up @@ -250,8 +250,8 @@ def statistics(self, name, key):
except Exception:
try:
data['median-%s' % name] = (
"between %s and %s" % (values[half],
values[half - 1]))
"between {} and {}".format(values[half],
values[half - 1]))
except Exception:
pass

Expand Down
2 changes: 1 addition & 1 deletion src/DocumentTemplate/DT_Let.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from .DT_Util import ParseError


class Let(object):
class Let:

blockContinuations = ()
name = 'let'
Expand Down
2 changes: 1 addition & 1 deletion src/DocumentTemplate/DT_Raise.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class InvalidErrorTypeExpression(Exception):
pass


class Raise(object):
class Raise:

blockContinuations = ()
name = 'raise'
Expand Down
2 changes: 1 addition & 1 deletion src/DocumentTemplate/DT_Return.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from .DT_Util import parse_params


class ReturnTag(object):
class ReturnTag:

name = 'return'
expr = None
Expand Down
14 changes: 6 additions & 8 deletions src/DocumentTemplate/DT_String.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import re
from threading import Lock

import six

import DocumentTemplate as _dt
from AccessControl.class_init import InitializeClass
from AccessControl.SecurityInfo import ClassSecurityInfo
Expand All @@ -36,7 +34,7 @@
COOKLOCK = Lock()


class String(object):
class String:
"""Document templates defined from strings.
Document template strings use an extended form of python string
Expand Down Expand Up @@ -78,7 +76,7 @@ def errQuote(self, s):
@security.private
def parse_error(self, mess, tag, text, start):
raise ParseError(
"%s, for tag %s, on line %s of %s" % (
"{}, for tag {}, on line {} of {}".format(
mess, self.errQuote(tag), len(text[:start].split('\n')),
self.errQuote(self.__name__)))

Expand Down Expand Up @@ -121,9 +119,9 @@ def _parseTag(self, match_ob, command=None, sargs='', tt=type(())):
cname, module, name = command
d = {}
try:
six.exec_('from %s import %s' % (module, name), d)
exec('from {} import {}'.format(module, name), d)
except ImportError:
six.exec_('from DocumentTemplate.%s import %s' % (
exec('from DocumentTemplate.{} import {}'.format(
module, name), d)
command = d[name]
self.commands[cname] = command
Expand Down Expand Up @@ -168,7 +166,7 @@ def parseTag(self, match_ob, command=None, sargs=''):
raise ParseError('Unexpected tag', tag)
else:
# Var command
args = args and ("%s %s" % (name, args)) or name
args = args and ("{} {}".format(name, args)) or name
return tag, args, Var, None

@security.private
Expand Down Expand Up @@ -555,7 +553,7 @@ def __getstate__(self, _special=('_v_', '_p_')):
InitializeClass(String)


class FileMixin(object):
class FileMixin:
# Mix-in class to abstract certain file-related attributes
edited_source = ''

Expand Down
5 changes: 2 additions & 3 deletions src/DocumentTemplate/DT_Try.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

import sys
import traceback

from six import StringIO
from io import StringIO

from ._DocumentTemplate import InstanceDict
from ._DocumentTemplate import render_blocks
Expand All @@ -24,7 +23,7 @@
from .DT_Util import parse_params


class Try(object):
class Try:
"""Zope DTML Exception handling
usage:
Expand Down
10 changes: 5 additions & 5 deletions src/DocumentTemplate/DT_Util.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def int_param(params, md, name, default=0, st=type('')):
functype = type(int_param)


class NotBindable(object):
class NotBindable:
# Used to prevent TemplateDict from trying to bind to functions.
def __init__(self, f):
self._func = f
Expand All @@ -100,7 +100,7 @@ def __call__(self, *args, **kw):
setattr(TemplateDict, name, f)


class StringModuleWrapper(object):
class StringModuleWrapper:
# Wrap the string module so it can deal with TaintedString strings.

def __getattr__(self, key):
Expand All @@ -111,7 +111,7 @@ def __getattr__(self, key):
return attr


class StringFunctionWrapper(object):
class StringFunctionWrapper:

def __init__(self, method):
self._method = method
Expand Down Expand Up @@ -244,7 +244,7 @@ def __call__(self, **kw):
simple_name = re.compile('^[a-z][a-z0-9_]*$', re.I).match


class Add_with_prefix(object):
class Add_with_prefix:

def __init__(self, map, defprefix, prefix):
self.map = map
Expand All @@ -258,7 +258,7 @@ def __setitem__(self, name, value):
if name.startswith(dp + '-'):
map[self.prefix + name[len(dp):].replace('-', '_')] = value
else:
map['%s_%s' % (self.prefix, name)] = value
map['{}_{}'.format(self.prefix, name)] = value


def add_with_prefix(map, defprefix, prefix):
Expand Down
Loading

0 comments on commit fea6b24

Please sign in to comment.