From be4386bc595d2cb9007c9c79152a104c821e93b3 Mon Sep 17 00:00:00 2001 From: albert Date: Mon, 7 Sep 2020 18:15:49 +0200 Subject: [PATCH 1/2] tempfix for empty profileGenericParser --- dsmr_parser/parsers.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dsmr_parser/parsers.py b/dsmr_parser/parsers.py index 8528ec8..5dedd09 100644 --- a/dsmr_parser/parsers.py +++ b/dsmr_parser/parsers.py @@ -225,6 +225,8 @@ class ProfileGenericParser(DSMRObjectParser): self.parsers_for_unidentified = parsers_for_unidentified def _is_line_wellformed(self, line, values): + if values and (len(values) == 1) and (values[0] == ''): + return True if values and (len(values) >= 2) and (values[0].isdigit()): buffer_length = int(values[0]) return (buffer_length <= 10) and (len(values) == (buffer_length * 2 + 2)) @@ -232,6 +234,9 @@ class ProfileGenericParser(DSMRObjectParser): return False def _parse_values(self, values): + if values and (len(values) == 1) and (values[0] == None): + return [self.value_formats[i].parse(value) + for i, value in enumerate(values)] buffer_length = int(values[0]) buffer_value_obis_ID = values[1] if (buffer_length > 0): From dc902a83e9fa683bac50e40251c175c79974d734 Mon Sep 17 00:00:00 2001 From: albert Date: Tue, 8 Sep 2020 12:30:51 +0200 Subject: [PATCH 2/2] referring to parent method from _parse_values in ProfileGenericParser --- dsmr_parser/parsers.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dsmr_parser/parsers.py b/dsmr_parser/parsers.py index 5dedd09..e8cc704 100644 --- a/dsmr_parser/parsers.py +++ b/dsmr_parser/parsers.py @@ -225,8 +225,11 @@ class ProfileGenericParser(DSMRObjectParser): self.parsers_for_unidentified = parsers_for_unidentified 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()): buffer_length = int(values[0]) return (buffer_length <= 10) and (len(values) == (buffer_length * 2 + 2)) @@ -234,9 +237,10 @@ class ProfileGenericParser(DSMRObjectParser): return False def _parse_values(self, values): + # in case of empty parentheses return if values and (len(values) == 1) and (values[0] == None): - return [self.value_formats[i].parse(value) - for i, value in enumerate(values)] + return super()._parse_values(values) #calling parent + buffer_length = int(values[0]) buffer_value_obis_ID = values[1] if (buffer_length > 0):