From dcb59fddb1a6f5efe791ff94cd0d6d9de12621d2 Mon Sep 17 00:00:00 2001 From: Alex Mekkering Date: Mon, 5 Jun 2017 09:07:47 +0200 Subject: [PATCH] Support optional telegram signatures --- dsmr_parser/parsers.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/dsmr_parser/parsers.py b/dsmr_parser/parsers.py index 6a9f465..c38dcf0 100644 --- a/dsmr_parser/parsers.py +++ b/dsmr_parser/parsers.py @@ -51,12 +51,10 @@ class TelegramParser(object): for signature, parser in self.telegram_specification['objects'].items(): match = re.search(signature, telegram_data, re.DOTALL) - # All telegram specification lines/signatures are expected to be - # present. - if not match: - raise ParseError('Telegram specification does not match ' - 'telegram data') - telegram[signature] = parser.parse(match.group(0)) + # Some signatures are optional and may not be present, + # so only parse lines that match + if match: + telegram[signature] = parser.parse(match.group(0)) return telegram