From adaa2dcad54fa3bfdcf679f6cc793675c9ed807d Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Wed, 3 Mar 2021 11:48:49 +0100 Subject: [PATCH 1/2] Remove deprecated asyncio coroutine decorator --- README.rst | 2 +- dsmr_parser/clients/protocol.py | 5 ++--- dsmr_parser/clients/serial_.py | 7 +++---- tox.ini | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/README.rst b/README.rst index 03de485..a8d405c 100644 --- a/README.rst +++ b/README.rst @@ -14,7 +14,7 @@ also includes client implementation to directly read and parse smart meter data. Features -------- -DSMR Parser supports DSMR versions 2, 3, 4 and 5. It has been tested with Python 3.4, 3.5 and 3.6. +DSMR Parser supports DSMR versions 2, 3, 4 and 5. It has been tested with Python 3.5, 3.6, 3.7. 3.8 and 3.9. Client module usage diff --git a/dsmr_parser/clients/protocol.py b/dsmr_parser/clients/protocol.py index 9b4536e..34a405e 100644 --- a/dsmr_parser/clients/protocol.py +++ b/dsmr_parser/clients/protocol.py @@ -136,7 +136,6 @@ class DSMRProtocol(asyncio.Protocol): else: self.telegram_callback(parsed_telegram) - @asyncio.coroutine - def wait_closed(self): + async def wait_closed(self): """Wait until connection is closed.""" - yield from self._closed.wait() + await self._closed.wait() diff --git a/dsmr_parser/clients/serial_.py b/dsmr_parser/clients/serial_.py index 94e3b6f..f63ff07 100644 --- a/dsmr_parser/clients/serial_.py +++ b/dsmr_parser/clients/serial_.py @@ -68,8 +68,7 @@ class AsyncSerialReader(SerialReader): PORT_KEY = 'url' - @asyncio.coroutine - def read(self, queue): + async def read(self, queue): """ Read complete DSMR telegram's from the serial interface and parse it into CosemObject's and MbusObject's. @@ -81,12 +80,12 @@ class AsyncSerialReader(SerialReader): """ # create Serial StreamReader conn = serial_asyncio.open_serial_connection(**self.serial_settings) - reader, _ = yield from conn + reader, _ = await conn while True: # Read line if available or give control back to loop until new # data has arrived. - data = yield from reader.readline() + data = await reader.readline() self.telegram_buffer.append(data.decode('ascii')) for telegram in self.telegram_buffer.get_all(): diff --git a/tox.ini b/tox.ini index f2e6de4..a9a403d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py35,py36,py37,py38 +envlist = py35,py36,py37,py38,py39 [testenv] deps= From c590109a1d3e787bfd0ac64d008bddb5fd614cf8 Mon Sep 17 00:00:00 2001 From: Nigel Dokter Date: Thu, 4 Mar 2021 21:47:12 +0100 Subject: [PATCH 2/2] Update README.rst Fixed small typo --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index a8d405c..403a723 100644 --- a/README.rst +++ b/README.rst @@ -14,7 +14,7 @@ also includes client implementation to directly read and parse smart meter data. Features -------- -DSMR Parser supports DSMR versions 2, 3, 4 and 5. It has been tested with Python 3.5, 3.6, 3.7. 3.8 and 3.9. +DSMR Parser supports DSMR versions 2, 3, 4 and 5. It has been tested with Python 3.5, 3.6, 3.7, 3.8 and 3.9. Client module usage