From 46d64db4120d12a96609afb0b85134a8a0b36406 Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Sun, 10 Nov 2024 12:50:24 +0100 Subject: [PATCH] finish six removal --- .pylintrc | 2 +- nixio/hdf5/h5dataset.py | 7 ++++++- nixio/property.py | 11 ++++++++--- scripts/dorelease.py | 6 +++--- setup.py | 7 ++++++- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/.pylintrc b/.pylintrc index b98d8be5..e1973931 100644 --- a/.pylintrc +++ b/.pylintrc @@ -517,7 +517,7 @@ init-import=no # List of qualified module names which can have objects that can redefine # builtins. -redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io +redefining-builtins-modules=builtins,io [CLASSES] diff --git a/nixio/hdf5/h5dataset.py b/nixio/hdf5/h5dataset.py index 9faa57fa..56eea1cb 100644 --- a/nixio/hdf5/h5dataset.py +++ b/nixio/hdf5/h5dataset.py @@ -6,11 +6,16 @@ # Redistribution and use in source and binary forms, with or without # modification, are permitted under the terms of the BSD License. See # LICENSE file in the root of the Project. -from six import ensure_str import numpy as np from ..datatype import DataType from .. import util +def ensure_str(s): + if isinstance(s, bytes): + return s.decode() + else: + return s + class H5DataSet: diff --git a/nixio/property.py b/nixio/property.py index 5d93238b..dcbc563e 100644 --- a/nixio/property.py +++ b/nixio/property.py @@ -13,13 +13,18 @@ from collections import Sequence, Iterable from enum import Enum from numbers import Number -from six import ensure_str, ensure_text import numpy as np from .datatype import DataType from .entity import Entity from . import util +def ensure_str(s): + if isinstance(s, bytes): + return s.decode() + else: + return s + class OdmlType(Enum): """ @@ -249,7 +254,7 @@ def values(self): def data_to_value(dat): if isinstance(dat, bytes): - dat = ensure_str(dat) # py2compat + dat = dat.decode() return dat values = tuple(map(data_to_value, data)) @@ -274,7 +279,7 @@ def values(self, vals): # Make sure all values are of the same data type vtype = self._check_new_value_types(vals) if vtype == DataType.String: - vals = [ensure_text(v) for v in vals] # py2compat + vals = [str(v) for v in vals] self._h5dataset.shape = np.shape(vals) data = np.array(vals, dtype=vtype) self._h5dataset.write_data(data) diff --git a/scripts/dorelease.py b/scripts/dorelease.py index 3980180c..3773f196 100644 --- a/scripts/dorelease.py +++ b/scripts/dorelease.py @@ -105,7 +105,7 @@ def update_info(newver): infodict = json.load(infofile) verstring = infodict["VERSION"] - newverstring = re.sub("[0-9\.a-z]+", newver, verstring) + newverstring = re.sub(r"[0-9\.a-z]+", newver, verstring) if newverstring == verstring: print("No changes required in info.json") @@ -140,7 +140,7 @@ def update_ci_confs(newver): newconf = [] for line in oldconf: if "NIX_BRANCH" in line: - line = re.sub("1\.[0-9\.]+[0-9\.a-z]+(dev){0,1}", nixbranch, line) + line = re.sub(r"1\.[0-9\.]+[0-9\.a-z]+(dev){0,1}", nixbranch, line) line = line.replace("master", nixbranch) newconf.append(line) @@ -168,7 +168,7 @@ def update_ci_confs(newver): # newconf = [] # for line in oldconf: # if "NIX_VERSION" in line: - # line = re.sub("'[1-9\.a-z]+'", "'" + newver + "'", line) + # line = re.sub(r"'[1-9\.a-z]+'", "'" + newver + "'", line) # newconf.append(line) # diff = diff_lines(oldconf, newconf) diff --git a/setup.py b/setup.py index 16379a5c..63c58640 100644 --- a/setup.py +++ b/setup.py @@ -53,6 +53,11 @@ def get_wheel_data(): 'Programming Language :: Python', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Topic :: Scientific/Engineering' ] @@ -78,7 +83,7 @@ def get_wheel_data(): tests_require=['pytest', 'scipy', 'pillow', 'matplotlib'], test_suite='pytest', setup_requires=['pytest-runner'], - install_requires=['numpy', 'h5py', 'six', 'enum34;python_version<"3.4"'], + install_requires=['numpy', 'h5py'], package_data={'nixio': [license_text, description_text]}, include_package_data=True, zip_safe=False,