From ffc385ef83a793dd910d2d5d849747723cbcf3c2 Mon Sep 17 00:00:00 2001 From: Gerrit Holl Date: Fri, 23 Dec 2022 10:16:29 +0100 Subject: [PATCH] Fix iterating a queryresult Fix iterating a queryresult, which was using a Python-2 only calling API. I've also plunged ahead and dropped support for end-of-life Python versions while adding newer Python versions 3.10 and 3.11. --- .travis.yml | 6 ++---- README.rst | 2 +- pybufrkit/dataquery.py | 2 +- setup.py | 7 ++++--- tests/test_dataquery.py | 10 ++++++++++ 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index e8cea1d..7e0de15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,10 @@ language: python python: - - "2.7" - - "3.5" - - "3.6" - "3.7" - "3.8" - "3.9" - - "3.9-dev" + - "3.10" + - "3.11" - "pypy3" # command to install dependencies install: diff --git a/README.rst b/README.rst index 1aec625..155313b 100644 --- a/README.rst +++ b/README.rst @@ -29,7 +29,7 @@ An `online BUFR decoder `_. +PyBufrKit is compatible with Python 3.7+ and `PyPy `_. To install from PyPi:: pip install pybufrkit diff --git a/pybufrkit/dataquery.py b/pybufrkit/dataquery.py index 212bce1..36b804c 100644 --- a/pybufrkit/dataquery.py +++ b/pybufrkit/dataquery.py @@ -310,7 +310,7 @@ def all_values(self, flat=False): return list(self.results.values()) def __iter__(self): - return iter(self.results.viewitems()) + return iter(self.results.items()) NODE_NOT_MATCH = 0 diff --git a/setup.py b/setup.py index 8811397..6d45248 100644 --- a/setup.py +++ b/setup.py @@ -44,10 +44,11 @@ def get_requirements(): "Intended Audience :: Science/Research", "Operating System :: OS Independent", "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3.5", - "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", "Topic :: Utilities", ], keywords=['BUFR', 'WMO'], diff --git a/tests/test_dataquery.py b/tests/test_dataquery.py index e1cb54d..44a34c8 100644 --- a/tests/test_dataquery.py +++ b/tests/test_dataquery.py @@ -553,3 +553,13 @@ def test_contrived(self): [[[[12], [10], [8]]], [[[6], [4]]]] ] ] + + def test_iterate_query_result(self): + s = read_bufr_file('jaso_214.bufr') + bufr_message = self.decoder.process(s) + + r1 = self.querent.query(bufr_message, '/301011/004001') + it = iter(r1) + next(it) + next(it) + next(it)