Skip to content

Commit

Permalink
Merge pull request #116 from lowdef/add_pylama_backin_post_py36
Browse files Browse the repository at this point in the history
add pylama back in + fix uniform style issues reported by pylama
  • Loading branch information
ndokter authored Jan 1, 2023
2 parents 041ac75 + 5f58bc8 commit 3a30543
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
5 changes: 4 additions & 1 deletion dsmr_parser/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def to_json(self):
}
return json.dumps(output)


class MBusObjectPeak(DSMRObject):

@property
Expand All @@ -132,7 +133,9 @@ def unit(self):
return self.values[2]['unit']

def __str__(self):
output = "{}\t[{}] at {} occurred {}".format(str(self.value), str(self.unit), str(self.datetime.astimezone().isoformat()), str(self.occurred.astimezone().isoformat()))
output = "{}\t[{}] at {} occurred {}"\
.format(str(self.value), str(self.unit), str(self.datetime.astimezone().isoformat()),
str(self.occurred.astimezone().isoformat()))
return output

def to_json(self):
Expand Down
8 changes: 4 additions & 4 deletions dsmr_parser/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ def parse(self, line):
objects = []

count = int(values[0])
for i in range(1, count+1):
timestamp_month = ValueParser(timestamp).parse(values[i*3+1])
timestamp_occurred = ValueParser(timestamp).parse(values[i*3+1])
value = ValueParser(Decimal).parse(values[i*3+2])
for i in range(1, count + 1):
timestamp_month = ValueParser(timestamp).parse(values[i * 3 + 1])
timestamp_occurred = ValueParser(timestamp).parse(values[i * 3 + 1])
value = ValueParser(Decimal).parse(values[i * 3 + 2])
objects.append(MBusObjectPeak([timestamp_month, timestamp_occurred, value]))

return objects
Expand Down
1 change: 0 additions & 1 deletion test/test_parse_fluvius.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ def test_parse(self):
assert isinstance(result[obis.BELGIUM_MBUS2_METER_READING1].value, Decimal)
assert result[obis.BELGIUM_MBUS2_METER_READING1].value == Decimal('872.234')


def test_checksum_valid(self):
# No exception is raised.
TelegramParser.validate_checksum(TELEGRAM_FLUVIUS_V171)
Expand Down
17 changes: 17 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,25 @@
deps=
pytest
pytest-cov
pylama
pytest-asyncio
pytest-mock
dlms_cosem
commands=
py.test --cov=dsmr_parser test {posargs}
pylama dsmr_parser test

[pylama:dsmr_parser/clients/__init__.py]
ignore = W0611

[pylama:dsmr_parser/parsers.py]
ignore = W605

[pylama:test/example_telegrams.py]
ignore = E501

[pylama:pylint]
max_line_length = 120

[pylama:pycodestyle]
max_line_length = 120

0 comments on commit 3a30543

Please sign in to comment.