Skip to content

Commit

Permalink
Drop support for Python 2.7 up to 3.6.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed Feb 9, 2023
1 parent 665db42 commit dc38719
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 31 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def read(*rnames):
name="z3c.rml",
version='5.0.dev0',
author="Stephan Richter and the Zope Community",
author_email="zope-dev@zope.org",
author_email="zope-dev@zope.dev",
description="An alternative implementation of RML",
long_description=(
read('README.rst')
Expand Down
8 changes: 1 addition & 7 deletions src/z3c/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
# this is a namespace package
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
3 changes: 0 additions & 3 deletions src/z3c/rml/attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,6 @@ def fromUnicode(self, value):
if self.doNotOpen:
return value
# Open/Download the file
# We can't use urlopen directly because it has problems with data URIs
# in 2.7 and 3.3 which are resolved in 3.4. Fortunately Reportlab
# already has a utility function to help us work around this issue.
fileObj = reportlab.lib.utils.open_for_read(value)
sio = io.BytesIO(fileObj.read())
fileObj.close()
Expand Down
6 changes: 3 additions & 3 deletions src/z3c/rml/dtd.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def generateElement(name, signature, seen):
subElementList += occurence
else:
subElementList = ' EMPTY'
text = '\n<!ELEMENT %s%s>' % (name, subElementList)
text = '\n<!ELEMENT {}{}>'.format(name, subElementList)
# Create a list of attributes for this element.
for attrName, field in fields:
# Ignore text nodes, since they are not attributes.
Expand All @@ -73,12 +73,12 @@ def generateElement(name, signature, seen):
else:
required = '#IMPLIED'
# Put it all together
text += '\n<!ATTLIST %s %s %s %s>' % (name, attrName, type, required)
text += f'\n<!ATTLIST {name} {attrName} {type} {required}>'
text += '\n'
# DTD does not support redefinition of an element type or have context
# specific elements.
if (name, signature) in seen:
text = '\n<!--' + text + '-->\n'
text = f'\n<!--{text}-->\n'
seen.append((name, signature))
# Walk through all sub-elements, creating the DTD entries for them.
for occurence in signature.queryTaggedValue('directives', ()):
Expand Down
1 change: 0 additions & 1 deletion src/z3c/rml/paraparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ def breakLines(self, *args, **kwargs):

unprocessed_frags = self.frags
bust_cache = any(isinstance(f, ParaFragWrapper) for f in self.frags)
# Paragraph is an old-style class in Python 2 so we can't use super()
result = super().breakLines(*args, **kwargs)
if bust_cache:
self.frags = unprocessed_frags
Expand Down
2 changes: 1 addition & 1 deletion src/z3c/rml/pdfinclude.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def _process(self, inputFile1, dir):
mergedFile = os.path.join(dir, 'merged.pdf')
do('{} {} cat {} output {}'.format(
self.EXECUTABLE,
' '.join('{}="{}"'.format(l_, p) for l_, p in file_map.items()),
' '.join(f'{l_}="{p}"' for l_, p in file_map.items()),
' '.join(merges),
mergedFile))

Expand Down
2 changes: 1 addition & 1 deletion src/z3c/rml/platypus.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, maxWidth, maxHeight, content=[], mergeSpace=1,
self.maxHeight = maxHeight
self.mode = mode
assert mode in ('error', 'overflow', 'shrink', 'truncate'), \
'{} invalid mode value {}'.format(self.identity(), mode)
f'{self.identity()} invalid mode value {mode}'
# This is an unnecessary check, since wrap() handles None just fine!
# assert maxHeight>=0, \
# '%s invalid maxHeight value %s' % (self.identity(),maxHeight)
Expand Down
8 changes: 4 additions & 4 deletions src/z3c/rml/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ def formatField(field):

def formatChoice(field):
choices = ', '.join([repr(choice) for choice in field.choices.keys()])
return '%s of (%s)' % (field.__class__.__name__, choices)
return '{} of ({})'.format(field.__class__.__name__, choices)


def formatSequence(field):
vtFormatter = typeFormatters.get(field.value_type.__class__, formatField)
return '%s of %s' % (field.__class__.__name__,
vtFormatter(field.value_type))
return '{} of {}'.format(
field.__class__.__name__, vtFormatter(field.value_type))


def formatGrid(field):
Expand All @@ -134,7 +134,7 @@ def formatGrid(field):
def formatCombination(field):
vts = [typeFormatters.get(vt.__class__, formatField)(vt)
for vt in field.value_types]
return '%s of %s' % (field.__class__.__name__, ', '.join(vts))
return '{} of {}'.format(field.__class__.__name__, ', '.join(vts))


typeFormatters = {
Expand Down
12 changes: 4 additions & 8 deletions src/z3c/rml/tests/test_rml.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,13 @@
import tempfile
import unittest

from PIL import Image
from PIL import ImageChops

import z3c.rml.tests
from z3c.rml import rml2pdf


try:
import Image
import ImageChops
except ImportError:
from PIL import Image
from PIL import ImageChops

LOG_FILE = os.path.join(os.path.dirname(__file__), 'render.log')


Expand Down Expand Up @@ -183,7 +179,7 @@ def test_suite():
here = os.path.dirname(z3c.rml.tests.__file__)
inputDir = os.path.join(here, 'input')
outputDir = tempfile.mkdtemp('z3c.rml-output')
print('output dir: {}'.format(outputDir))
print(f'output dir: {outputDir}')
expectDir = os.path.join(here, 'expected')
for filename in os.listdir(inputDir):
if not filename.endswith(".rml"):
Expand Down
3 changes: 1 addition & 2 deletions src/z3c/rml/tests/test_rml2pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

import io
import unittest

import mock
from unittest import mock

from z3c.rml import rml2pdf

Expand Down
Empty file added test.pdf
Empty file.

0 comments on commit dc38719

Please sign in to comment.