Skip to content

Commit

Permalink
Black reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
dennissiemensma committed Jan 29, 2024
1 parent 6302616 commit eb511b2
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 42 deletions.
6 changes: 3 additions & 3 deletions dsmr_backend/models/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ def reschedule(self, planned_at):
'SP: Rescheduled "%s" to %s (ETA %s)',
self.name,
timezone.localtime(self.planned),
self.planned - now
if self.planned > now
else "-", # Negative timedelta formats weird for some reason
(
self.planned - now if self.planned > now else "-"
), # Negative timedelta formats weird for some reason
)

def reschedule_asap(self):
Expand Down
30 changes: 15 additions & 15 deletions dsmr_consumption/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,22 +485,22 @@ def day_consumption(day: datetime.date) -> Dict:
consumption["total_cost"] = round_decimal(consumption["total_cost"])

# Current prices as well.
consumption[
"energy_supplier_price_electricity_delivered_1"
] = daily_energy_price.electricity_delivered_1_price
consumption[
"energy_supplier_price_electricity_delivered_2"
] = daily_energy_price.electricity_delivered_2_price
consumption[
"energy_supplier_price_electricity_returned_1"
] = daily_energy_price.electricity_returned_1_price
consumption[
"energy_supplier_price_electricity_returned_2"
] = daily_energy_price.electricity_returned_2_price
consumption["energy_supplier_price_electricity_delivered_1"] = (
daily_energy_price.electricity_delivered_1_price
)
consumption["energy_supplier_price_electricity_delivered_2"] = (
daily_energy_price.electricity_delivered_2_price
)
consumption["energy_supplier_price_electricity_returned_1"] = (
daily_energy_price.electricity_returned_1_price
)
consumption["energy_supplier_price_electricity_returned_2"] = (
daily_energy_price.electricity_returned_2_price
)
consumption["energy_supplier_price_gas"] = daily_energy_price.gas_price
consumption[
"energy_supplier_price_fixed_daily_cost"
] = daily_energy_price.fixed_daily_cost
consumption["energy_supplier_price_fixed_daily_cost"] = (
daily_energy_price.fixed_daily_cost
)

# Any notes of that day.
consumption["notes"] = Note.objects.filter(day=day).values_list(
Expand Down
12 changes: 6 additions & 6 deletions dsmr_datalogger/services/datalogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def get_dsmr_connection_parameters() -> Dict:
url_or_port=datalogger_settings.serial_port,
baudrate=115200 if is_default_dsmr_protocol else 9600,
bytesize=serial.EIGHTBITS if is_default_dsmr_protocol else serial.SEVENBITS,
parity=serial.PARITY_NONE
if is_default_dsmr_protocol
else serial.PARITY_EVEN,
parity=(
serial.PARITY_NONE if is_default_dsmr_protocol else serial.PARITY_EVEN
),
stopbits=serial.STOPBITS_ONE,
xonxoff=1,
rtscts=0,
Expand Down Expand Up @@ -149,9 +149,9 @@ def _map_telegram_to_model(parsed_telegram: Dict, data: str):
"dsmr_version"
].startswith("5")

model_fields[
"extra_device_timestamp"
] = calculate_fake_gas_reading_timestamp(now=now, is_dsmr_v5=is_v5)
model_fields["extra_device_timestamp"] = (
calculate_fake_gas_reading_timestamp(now=now, is_dsmr_v5=is_v5)
)

# Fix for rare smart meters with a timestamp in the far future. We should disallow that.
discard_after = timezone.now() + timezone.timedelta(hours=24)
Expand Down
16 changes: 10 additions & 6 deletions dsmr_datalogger/services/readings.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,14 @@ def first_meter_positions_of_day(day: datetime.date) -> MeterPositionsDTO:
electricity_returned_1=first_electricity_reading_of_day.electricity_returned_1,
electricity_delivered_2=first_electricity_reading_of_day.electricity_delivered_2,
electricity_returned_2=first_electricity_reading_of_day.electricity_returned_2,
extra_device_timestamp=first_gas_reading_of_day.extra_device_timestamp
if first_gas_reading_of_day
else None,
extra_device_delivered=first_gas_reading_of_day.extra_device_delivered
if first_gas_reading_of_day
else None,
extra_device_timestamp=(
first_gas_reading_of_day.extra_device_timestamp
if first_gas_reading_of_day
else None
),
extra_device_delivered=(
first_gas_reading_of_day.extra_device_delivered
if first_gas_reading_of_day
else None
),
)
1 change: 1 addition & 0 deletions dsmr_datalogger/tests/script/test_datalogger_api_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This only tests the __main__ route and methods not covered by other tests.
"""

from unittest import mock
import logging

Expand Down
1 change: 1 addition & 0 deletions dsmr_dropbox/dropboxinc/dropbox_content_hasher.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

from __future__ import absolute_import, division, print_function, unicode_literals

import hashlib
Expand Down
6 changes: 3 additions & 3 deletions dsmr_frontend/views/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class About(ConfigurableLoginRequiredMixin, TemplateView):

def get_context_data(self, **kwargs):
context_data = super(About, self).get_context_data(**kwargs)
context_data[
"monitoring_issues"
] = dsmr_backend.services.backend.request_monitoring_status()
context_data["monitoring_issues"] = (
dsmr_backend.services.backend.request_monitoring_status()
)
context_data["frontend_settings"] = FrontendSettings.get_solo()
return context_data

Expand Down
6 changes: 3 additions & 3 deletions dsmr_frontend/views/energy_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def get_context_data(self, **kwargs):

context_data["capabilities"] = dsmr_backend.services.backend.get_capabilities()
context_data["frontend_settings"] = FrontendSettings.get_solo()
context_data[
"energy_contracts"
] = dsmr_consumption.services.summarize_energy_contracts()
context_data["energy_contracts"] = (
dsmr_consumption.services.summarize_energy_contracts()
)

return context_data
6 changes: 3 additions & 3 deletions dsmr_frontend/views/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class Statistics(ConfigurableLoginRequiredMixin, TemplateView):
def get_context_data(self, **kwargs):
context_data = super(Statistics, self).get_context_data(**kwargs)
context_data["capabilities"] = dsmr_backend.services.backend.get_capabilities()
context_data[
"electricity_statistics"
] = ElectricityStatistics.get_solo().export()
context_data["electricity_statistics"] = (
ElectricityStatistics.get_solo().export()
)
context_data["frontend_settings"] = FrontendSettings.get_solo()

try:
Expand Down
6 changes: 3 additions & 3 deletions dsmr_frontend/views/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class Support(LoginRequiredMixin, TemplateView):

def get_context_data(self, **kwargs):
context_data = super(Support, self).get_context_data(**kwargs)
context_data[
"monitoring_issues"
] = dsmr_backend.services.backend.request_monitoring_status()
context_data["monitoring_issues"] = (
dsmr_backend.services.backend.request_monitoring_status()
)
context_data["frontend_settings"] = FrontendSettings.get_solo()
return context_data

Expand Down
1 change: 1 addition & 0 deletions dsmr_parser/obis_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Might be refactored in a backwards incompatible way as soon as proper telegram
objects are introduced.
"""

P1_MESSAGE_HEADER = r"\d-\d:0\.2\.8.+?\r\n"
P1_MESSAGE_TIMESTAMP = r"\d-\d:1\.0\.0.+?\r\n"
ELECTRICITY_USED_TARIFF_1 = r"\d-\d:1\.8\.1.+?\r\n"
Expand Down
1 change: 1 addition & 0 deletions dsmrreader/config/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Default settings as defined in the base.py config.
Some settings can be overridden by system env vars or the .env.
"""

from decouple import Csv, Choices

from dsmrreader.config.base import *
Expand Down
1 change: 1 addition & 0 deletions dsmrreader/config/django_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Django settings overwritten from env.
Mostly try-except because we don't want to pin any defaults to fall back to, just let Django set them.
"""

from decouple import config, UndefinedValueError


Expand Down
1 change: 1 addition & 0 deletions dsmrreader/config/test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Tests. """

import secrets

from dsmrreader.config.development import *
Expand Down

0 comments on commit eb511b2

Please sign in to comment.