Merge pull request #57 from avandermeer/master

fix for empty parentheses in ProfileGenericParser
This commit is contained in:
Nigel Dokter 2020-12-14 16:55:38 +01:00 committed by GitHub
commit 2391f38c4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -225,6 +225,11 @@ class ProfileGenericParser(DSMRObjectParser):
self.parsers_for_unidentified = parsers_for_unidentified self.parsers_for_unidentified = parsers_for_unidentified
def _is_line_wellformed(self, line, values): def _is_line_wellformed(self, line, values):
# allow empty parentheses (indicated by empty string)
if values and (len(values) == 1) and (values[0] == ''):
return True
if values and (len(values) >= 2) and (values[0].isdigit()): if values and (len(values) >= 2) and (values[0].isdigit()):
buffer_length = int(values[0]) buffer_length = int(values[0])
return (buffer_length <= 10) and (len(values) == (buffer_length * 2 + 2)) return (buffer_length <= 10) and (len(values) == (buffer_length * 2 + 2))
@ -232,6 +237,10 @@ class ProfileGenericParser(DSMRObjectParser):
return False return False
def _parse_values(self, values): def _parse_values(self, values):
# in case of empty parentheses return
if values and (len(values) == 1) and (values[0] == None):
return super()._parse_values(values) #calling parent
buffer_length = int(values[0]) buffer_length = int(values[0])
buffer_value_obis_ID = values[1] buffer_value_obis_ID = values[1]
if (buffer_length > 0): if (buffer_length > 0):