Support optional telegram signatures

This commit is contained in:
Alex Mekkering 2017-06-05 09:07:47 +02:00
parent 9b0a85e84b
commit dcb59fddb1

View File

@ -51,11 +51,9 @@ 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')
# 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