From 55d687c032312b85b7102063c36dca2a3a65df55 Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Sat, 4 May 2024 16:11:21 +0200 Subject: [PATCH] remove Python2 crumbs --- setup.py | 2 +- tox.ini | 1 - trml2pdf/canv.py | 6 +++--- trml2pdf/doc.py | 5 ++--- trml2pdf/flowable.py | 5 ++--- trml2pdf/styles.py | 2 +- trml2pdf/utils.py | 3 +-- 7 files changed, 10 insertions(+), 14 deletions(-) diff --git a/setup.py b/setup.py index f32ab22..06bbfbf 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ maintainer='Roman Lyashov', maintainer_email='romitch@gmail.com', url='http://github.com/romanlv/trml2pdf/', - install_requires=['reportlab>=3.2.0', 'six>=1.9.0'], + install_requires=['reportlab>=3.2.0'], # dependency_links=[], include_package_data=True, packages=find_packages(exclude=['tests', 'tests.*']), diff --git a/tox.ini b/tox.ini index c44fb48..da98275 100644 --- a/tox.ini +++ b/tox.ini @@ -18,4 +18,3 @@ commands = pytest deps = pytest reportlab>=3.2.0 - six>=1.9.0 diff --git a/trml2pdf/canv.py b/trml2pdf/canv.py index 982e6e9..8c78e80 100644 --- a/trml2pdf/canv.py +++ b/trml2pdf/canv.py @@ -25,7 +25,7 @@ import io import sys # 2. 3rd parties -from six.moves import urllib +import urllib.request from reportlab.lib.utils import ImageReader from reportlab.graphics.barcode import code128, qr # 3. local @@ -34,7 +34,7 @@ encoding = 'UTF-8' -class RmlCanvas(object): +class RmlCanvas: def __init__(self, canvas, doc_tmpl=None, doc=None): self.canvas = canvas @@ -347,7 +347,7 @@ def render(self, node): break -class RmlDraw(object): +class RmlDraw: def __init__(self, node, styles): self.node = node diff --git a/trml2pdf/doc.py b/trml2pdf/doc.py index c28f1e8..f35f875 100644 --- a/trml2pdf/doc.py +++ b/trml2pdf/doc.py @@ -21,7 +21,6 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # 1. system -import io import xml.dom.minidom # 2. 3rd parties from reportlab import platypus @@ -55,7 +54,7 @@ def docinit(els): addMapping(normal, 1, 1, bold_italic) # italic and bold -class RmlDoc(object): +class RmlDoc: def __init__(self, data: str): self.dom = xml.dom.minidom.parseString(data) @@ -84,7 +83,7 @@ def render(self, out): self.canvas.save() -class RmlTemplate(object): +class RmlTemplate: def __init__(self, out, node, doc): if not node.hasAttribute('pageSize'): diff --git a/trml2pdf/flowable.py b/trml2pdf/flowable.py index b7de75e..60223e6 100644 --- a/trml2pdf/flowable.py +++ b/trml2pdf/flowable.py @@ -22,7 +22,6 @@ # 1. system import sys -from six import text_type # 2. 3rd parties from reportlab import platypus from reportlab.graphics.barcode import code39 @@ -39,7 +38,7 @@ def _child_get(node, childs): return clds -class RmlFlowable(object): +class RmlFlowable: def __init__(self, doc): self.doc = doc @@ -66,7 +65,7 @@ def _textual(self, node): rc += n.data elif n.nodeType == node.TEXT_NODE: rc += n.toxml() - return text_type(rc) + return str(rc) def _list(self, node): list_style = self.styles.list_styles[node.getAttribute('style')] if node.hasAttribute('style') else platypus.flowables.ListStyle('Default') diff --git a/trml2pdf/styles.py b/trml2pdf/styles.py index 6481c90..4aad41f 100644 --- a/trml2pdf/styles.py +++ b/trml2pdf/styles.py @@ -150,7 +150,7 @@ def _table_style_get(style_node): return platypus.tables.TableStyle(styles) -class RmlStyles(object): +class RmlStyles: def __init__(self, nodes): self.styles = {} diff --git a/trml2pdf/utils.py b/trml2pdf/utils.py index d96571c..7fdb6fd 100644 --- a/trml2pdf/utils.py +++ b/trml2pdf/utils.py @@ -18,7 +18,6 @@ import re import reportlab.lib.units -from six import text_type def text_get(node): @@ -65,7 +64,7 @@ def attr_get(node, attrs, attrs_dict={}): for key in attrs_dict: if node.hasAttribute(key): if attrs_dict[key] == 'str': - res[key] = text_type(node.getAttribute(key)) + res[key] = str(node.getAttribute(key)) elif attrs_dict[key] == 'bool': res[key] = bool_get(node.getAttribute(key)) elif attrs_dict[key] == 'int':