From a97dc4914d5bc4504677e49cb6d8c4d4e7b30eb2 Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Wed, 26 Jun 2024 22:30:19 +0200 Subject: [PATCH] remove six dependency --- docxcompose/properties.py | 16 +++++++--------- setup.py | 2 -- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/docxcompose/properties.py b/docxcompose/properties.py index aa8cd2d..3de5edf 100644 --- a/docxcompose/properties.py +++ b/docxcompose/properties.py @@ -13,8 +13,6 @@ from docxcompose.utils import xpath from lxml.etree import FunctionNamespace from lxml.etree import QName -from six import binary_type -from six import text_type import pkg_resources import re @@ -36,17 +34,17 @@ def value2vt(value): el.text = 'true' if value else 'false' elif isinstance(value, int): el = parse_xml(CUSTOM_PROPERTY_TYPES['int']) - el.text = text_type(value) + el.text = str(value) elif isinstance(value, float): el = parse_xml(CUSTOM_PROPERTY_TYPES['float']) - el.text = text_type(value) + el.text = str(value) elif isinstance(value, datetime): el = parse_xml(CUSTOM_PROPERTY_TYPES['datetime']) el.text = value.strftime('%Y-%m-%dT%H:%M:%SZ') - elif isinstance(value, text_type): + elif isinstance(value, str): el = parse_xml(CUSTOM_PROPERTY_TYPES['text']) el.text = value - elif isinstance(value, binary_type): + elif isinstance(value, bytes): value = value.decode('utf-8') el = parse_xml(CUSTOM_PROPERTY_TYPES['text']) el.text = value @@ -162,7 +160,7 @@ def __delitem__(self, key): # Renumber pids pid = MIN_PID for prop in self._element: - prop.set('pid', text_type(pid)) + prop.set('pid', str(pid)) pid += 1 self._update_part() @@ -226,7 +224,7 @@ def add(self, name, value): prop = parse_xml(''.format(NS['cp'])) prop.set('fmtid', CUSTOM_PROPERTY_FMTID) prop.set('name', name) - prop.set('pid', text_type(pid)) + prop.set('pid', str(pid)) value_el = value2vt(value) prop.append(value_el) self._element.append(prop) @@ -356,7 +354,7 @@ def _format_value(self, value, language=None): return format_datetime(value, self.date_format, locale=language) return format_datetime(value, self.date_format) else: - return text_type(value) + return str(value) def update(self, value, language=None): """ Sets the value of the docproperty in the document diff --git a/setup.py b/setup.py index 1d7d53c..92dd6da 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,6 @@ # Get more from https://pypi.python.org/pypi?%3Aaction=list_classifiers classifiers=[ "Programming Language :: Python", - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Operating System :: OS Independent", "License :: OSI Approved :: MIT License", @@ -35,7 +34,6 @@ 'lxml', 'python-docx >= 0.8.8', 'setuptools', - 'six', 'babel', ], extras_require={