Merge pull request #25 from AlexMekkering/optional_telegram_lines

Support optional telegram signatures
This commit is contained in:
Nigel Dokter 2017-06-05 20:45:38 +02:00 committed by GitHub
commit 5f1afeb1f8

View File

@ -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