cleaned up based on pylama complaints / pinpointed to coverage version 4.5.4 as next version is incompatible
This commit is contained in:
@@ -9,6 +9,7 @@ from dsmr_parser.parsers import TelegramParser
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class FileReader(object):
|
||||
"""
|
||||
Filereader to read and parse raw telegram strings from a file and instantiate Telegram objects
|
||||
@@ -60,7 +61,7 @@ class FileReader(object):
|
||||
Read complete DSMR telegram's from a file and return a Telegram object.
|
||||
:rtype: generator
|
||||
"""
|
||||
with open(self._file,"rb") as file_handle:
|
||||
with open(self._file, "rb") as file_handle:
|
||||
while True:
|
||||
data = file_handle.readline()
|
||||
str = data.decode()
|
||||
@@ -74,6 +75,7 @@ class FileReader(object):
|
||||
except ParseError as e:
|
||||
logger.error('Failed to parse telegram: %s', e)
|
||||
|
||||
|
||||
class FileInputReader(object):
|
||||
"""
|
||||
Filereader to read and parse raw telegram strings from stdin or files specified at the commandline
|
||||
@@ -155,7 +157,7 @@ class FileTailReader(object):
|
||||
Read complete DSMR telegram's from a files tail and return a Telegram object.
|
||||
:rtype: generator
|
||||
"""
|
||||
with open(self._file,"rb") as file_handle:
|
||||
with open(self._file, "rb") as file_handle:
|
||||
for data in tailer.follow(file_handle):
|
||||
str = data.decode()
|
||||
self.telegram_buffer.append(str)
|
||||
@@ -163,8 +165,7 @@ class FileTailReader(object):
|
||||
for telegram in self.telegram_buffer.get_all():
|
||||
try:
|
||||
yield Telegram(telegram, self.telegram_parser, self.telegram_specification)
|
||||
except dsmr_parser.exceptions.InvalidChecksumError as e:
|
||||
except InvalidChecksumError as e:
|
||||
logger.warning(str(e))
|
||||
except dsmr_parser.exceptions.ParseError as e:
|
||||
except ParseError as e:
|
||||
logger.error('Failed to parse telegram: %s', e)
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ def create_tcp_dsmr_reader(host, port, dsmr_version,
|
||||
conn = loop.create_connection(protocol, host, port)
|
||||
return conn
|
||||
|
||||
|
||||
class DSMRProtocol(asyncio.Protocol):
|
||||
"""Assemble and handle incoming data into complete DSM telegrams."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user