From b389887b5070e98fffb4f40edd4b43278c70cc5b Mon Sep 17 00:00:00 2001 From: "13621160019@163.com" <13621160019@163.com> Date: Wed, 25 Aug 2021 12:01:14 +0800 Subject: [PATCH] fixed PEP8 warnings in API --- .../space_energy_input_category.py | 6 ++++-- myems-aggregation/space_energy_input_item.py | 3 ++- .../space_energy_output_category.py | 7 ++++--- myems-api/app.py | 6 +++--- myems-api/core/combinedequipment.py | 16 +++++++-------- myems-api/core/distributioncircuit.py | 2 +- myems-api/core/equipment.py | 14 ++++++------- myems-api/core/meter.py | 10 +++++----- myems-api/core/offlinemeter.py | 8 ++++---- myems-api/core/sensor.py | 2 +- myems-api/core/shopfloor.py | 12 +++++------ myems-api/core/space.py | 20 +++++++++---------- myems-api/core/store.py | 18 ++++++++--------- myems-api/core/tenant.py | 18 ++++++++--------- myems-api/core/virtualmeter.py | 8 ++++---- myems-api/reports/metersubmetersbalance.py | 11 +++++----- myems-api/reports/tenantenergycategory.py | 7 +++---- 17 files changed, 86 insertions(+), 82 deletions(-) diff --git a/myems-aggregation/space_energy_input_category.py b/myems-aggregation/space_energy_input_category.py index ea05bcbe..dc145dbc 100644 --- a/myems-aggregation/space_energy_input_category.py +++ b/myems-aggregation/space_energy_input_category.py @@ -584,7 +584,8 @@ def worker(space): energy_combined_equipment_hourly[combined_equipment_id][current_datetime_utc] = dict() energy_category_id = row_value[1] actual_value = row_value[2] - energy_combined_equipment_hourly[combined_equipment_id][current_datetime_utc][energy_category_id] = actual_value + energy_combined_equipment_hourly[combined_equipment_id][current_datetime_utc][ + energy_category_id] = actual_value except Exception as e: error_string = "Error in step 14 of space_energy_input_category.worker " + str(e) if cursor_energy_db: @@ -769,7 +770,8 @@ def worker(space): energy_child_space_hourly[child_space_id][current_datetime_utc] = dict() energy_category_id = row_energy_value[1] actual_value = row_energy_value[2] - energy_child_space_hourly[child_space_id][current_datetime_utc][energy_category_id] = actual_value + energy_child_space_hourly[child_space_id][current_datetime_utc][energy_category_id] \ + = actual_value except Exception as e: error_string = "Error in step 19 of space_energy_input_category.worker " + str(e) if cursor_energy_db: diff --git a/myems-aggregation/space_energy_input_item.py b/myems-aggregation/space_energy_input_item.py index 4589897e..2ebf7a0b 100644 --- a/myems-aggregation/space_energy_input_item.py +++ b/myems-aggregation/space_energy_input_item.py @@ -587,7 +587,8 @@ def worker(space): energy_combined_equipment_hourly[combined_equipment_id][current_datetime_utc] = dict() energy_item_id = row_value[1] actual_value = row_value[2] - energy_combined_equipment_hourly[combined_equipment_id][current_datetime_utc][energy_item_id] = actual_value + energy_combined_equipment_hourly[combined_equipment_id][current_datetime_utc][energy_item_id] \ + = actual_value except Exception as e: error_string = "Error in step 14 of space_energy_input_item.worker " + str(e) if cursor_energy_db: diff --git a/myems-aggregation/space_energy_output_category.py b/myems-aggregation/space_energy_output_category.py index 24cec572..f8aa7c5a 100644 --- a/myems-aggregation/space_energy_output_category.py +++ b/myems-aggregation/space_energy_output_category.py @@ -286,8 +286,8 @@ def worker(space): energy_combined_equipment_hourly[combined_equipment_id][current_datetime_utc] = dict() energy_category_id = row_value[1] actual_value = row_value[2] - energy_combined_equipment_hourly[combined_equipment_id][current_datetime_utc][energy_category_id] = \ - actual_value + energy_combined_equipment_hourly[combined_equipment_id][current_datetime_utc][ + energy_category_id] = actual_value except Exception as e: error_string = "Error in step 5 of space_energy_output_category.worker " + str(e) if cursor_energy_db: @@ -361,7 +361,8 @@ def worker(space): energy_child_space_hourly[child_space_id][current_datetime_utc] = dict() energy_category_id = row_energy_value[1] actual_value = row_energy_value[2] - energy_child_space_hourly[child_space_id][current_datetime_utc][energy_category_id] = actual_value + energy_child_space_hourly[child_space_id][current_datetime_utc][energy_category_id] \ + = actual_value except Exception as e: error_string = "Error in step 7 of space_energy_output_category.worker " + str(e) if cursor_energy_db: diff --git a/myems-api/app.py b/myems-api/app.py index 5f90d078..458da0d1 100644 --- a/myems-api/app.py +++ b/myems-api/app.py @@ -3,9 +3,9 @@ from falcon_cors import CORS from falcon_multipart.middleware import MultipartMiddleware from core import energyflowdiagram, privilege, textmessage, distributioncircuit, virtualmeter, \ costcenter, point, knowledgefile, meter, gsmmodem, tariff, user, storetype, timezone, \ - costfile, offlinemeterfile, version, contact, emailserver, combinedequipment, datasource, equipment, tenant, shopfloor, \ - webmessage, distributionsystem, store, emailmessage, tenanttype, wechatmessage, space, gateway, offlinemeter, \ - rule, energycategory, sensor, energyitem, notification, menu + costfile, offlinemeterfile, version, contact, emailserver, combinedequipment, datasource, equipment, tenant, \ + shopfloor, webmessage, distributionsystem, store, emailmessage, tenanttype, wechatmessage, space, gateway, \ + offlinemeter, rule, energycategory, sensor, energyitem, notification, menu from reports import advancedreport from reports import distributionsystem as distributionsystemreport from reports import energyflowdiagram as energyflowdiagramreport diff --git a/myems-api/core/combinedequipment.py b/myems-api/core/combinedequipment.py index 97158f6a..b15d843a 100644 --- a/myems-api/core/combinedequipment.py +++ b/myems-api/core/combinedequipment.py @@ -89,8 +89,8 @@ class CombinedEquipmentCollection: if 'cost_center_id' not in new_values['data'].keys() or \ not isinstance(new_values['data']['cost_center_id'], int) or \ new_values['data']['cost_center_id'] <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', - description='API.INVALID_COST_CENTER_ID') + raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', + description='API.INVALID_COST_CENTER_ID') cost_center_id = new_values['data']['cost_center_id'] if 'description' in new_values['data'].keys() and \ @@ -307,8 +307,8 @@ class CombinedEquipmentItem: if 'cost_center_id' not in new_values['data'].keys() or \ not isinstance(new_values['data']['cost_center_id'], int) or \ new_values['data']['cost_center_id'] <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', - description='API.INVALID_COST_CENTER_ID') + raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', + description='API.INVALID_COST_CENTER_ID') cost_center_id = new_values['data']['cost_center_id'] if 'description' in new_values['data'].keys() and \ @@ -629,7 +629,7 @@ class CombinedEquipmentEquipmentItem: @staticmethod def on_options(req, resp, id_, eid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, eid): @@ -1503,7 +1503,7 @@ class CombinedEquipmentMeterItem: @staticmethod def on_options(req, resp, id_, mid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, mid): @@ -1692,7 +1692,7 @@ class CombinedEquipmentOfflineMeterItem: @staticmethod def on_options(req, resp, id_, mid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, mid): @@ -1881,7 +1881,7 @@ class CombinedEquipmentVirtualMeterItem: @staticmethod def on_options(req, resp, id_, mid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, mid): diff --git a/myems-api/core/distributioncircuit.py b/myems-api/core/distributioncircuit.py index 5bbb54fa..9d4c655d 100644 --- a/myems-api/core/distributioncircuit.py +++ b/myems-api/core/distributioncircuit.py @@ -497,7 +497,7 @@ class DistributionCircuitPointItem: @staticmethod def on_options(req, resp, id_, pid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, pid): diff --git a/myems-api/core/equipment.py b/myems-api/core/equipment.py index 086ddaf9..ee9f59aa 100644 --- a/myems-api/core/equipment.py +++ b/myems-api/core/equipment.py @@ -89,8 +89,8 @@ class EquipmentCollection: if 'cost_center_id' not in new_values['data'].keys() or \ not isinstance(new_values['data']['cost_center_id'], int) or \ new_values['data']['cost_center_id'] <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', - description='API.INVALID_COST_CENTER_ID') + raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', + description='API.INVALID_COST_CENTER_ID') cost_center_id = new_values['data']['cost_center_id'] if 'description' in new_values['data'].keys() and \ @@ -320,8 +320,8 @@ class EquipmentItem: if 'cost_center_id' not in new_values['data'].keys() or \ not isinstance(new_values['data']['cost_center_id'], int) or \ new_values['data']['cost_center_id'] <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', - description='API.INVALID_COST_CENTER_ID') + raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', + description='API.INVALID_COST_CENTER_ID') cost_center_id = new_values['data']['cost_center_id'] if 'description' in new_values['data'].keys() and \ @@ -1347,7 +1347,7 @@ class EquipmentMeterItem: @staticmethod def on_options(req, resp, id_, mid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, mid): @@ -1534,7 +1534,7 @@ class EquipmentOfflineMeterItem: @staticmethod def on_options(req, resp, id_, mid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, mid): @@ -1722,7 +1722,7 @@ class EquipmentVirtualMeterItem: @staticmethod def on_options(req, resp, id_, mid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, mid): diff --git a/myems-api/core/meter.py b/myems-api/core/meter.py index f5edff57..19ff22d1 100644 --- a/myems-api/core/meter.py +++ b/myems-api/core/meter.py @@ -147,8 +147,8 @@ class MeterCollection: if 'cost_center_id' not in new_values['data'].keys() or \ not isinstance(new_values['data']['cost_center_id'], int) or \ new_values['data']['cost_center_id'] <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', - description='API.INVALID_COST_CENTER_ID') + raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', + description='API.INVALID_COST_CENTER_ID') cost_center_id = new_values['data']['cost_center_id'] if 'energy_item_id' in new_values['data'].keys() and \ @@ -595,8 +595,8 @@ class MeterItem: if 'cost_center_id' not in new_values['data'].keys() or \ not isinstance(new_values['data']['cost_center_id'], int) or \ new_values['data']['cost_center_id'] <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', - description='API.INVALID_COST_CENTER_ID') + raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', + description='API.INVALID_COST_CENTER_ID') cost_center_id = new_values['data']['cost_center_id'] @@ -955,7 +955,7 @@ class MeterPointItem: @staticmethod def on_options(req, resp, id_, pid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, pid): diff --git a/myems-api/core/offlinemeter.py b/myems-api/core/offlinemeter.py index 0892cf86..bd5806d1 100644 --- a/myems-api/core/offlinemeter.py +++ b/myems-api/core/offlinemeter.py @@ -133,8 +133,8 @@ class OfflineMeterCollection: if 'cost_center_id' not in new_values['data'].keys() or \ not isinstance(new_values['data']['cost_center_id'], int) or \ new_values['data']['cost_center_id'] <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', - description='API.INVALID_COST_CENTER_ID') + raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', + description='API.INVALID_COST_CENTER_ID') cost_center_id = new_values['data']['cost_center_id'] @@ -518,8 +518,8 @@ class OfflineMeterItem: if 'cost_center_id' not in new_values['data'].keys() or \ not isinstance(new_values['data']['cost_center_id'], int) or \ new_values['data']['cost_center_id'] <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', - description='API.INVALID_COST_CENTER_ID') + raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', + description='API.INVALID_COST_CENTER_ID') cost_center_id = new_values['data']['cost_center_id'] diff --git a/myems-api/core/sensor.py b/myems-api/core/sensor.py index 46a8a58f..068d63f7 100644 --- a/myems-api/core/sensor.py +++ b/myems-api/core/sensor.py @@ -377,7 +377,7 @@ class SensorPointItem: @staticmethod def on_options(req, resp, id_, pid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, pid): diff --git a/myems-api/core/shopfloor.py b/myems-api/core/shopfloor.py index 11bc1e31..ac4ca2b6 100644 --- a/myems-api/core/shopfloor.py +++ b/myems-api/core/shopfloor.py @@ -628,7 +628,7 @@ class ShopfloorEquipmentItem: @staticmethod def on_options(req, resp, id_, eid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, eid): @@ -809,7 +809,7 @@ class ShopfloorMeterItem: @staticmethod def on_options(req, resp, id_, mid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, mid): @@ -989,7 +989,7 @@ class ShopfloorOfflineMeterItem: @staticmethod def on_options(req, resp, id_, mid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, mid): @@ -1169,7 +1169,7 @@ class ShopfloorPointItem: @staticmethod def on_options(req, resp, id_, pid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, pid): @@ -1336,7 +1336,7 @@ class ShopfloorSensorItem: @staticmethod def on_options(req, resp, id_, sid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, sid): @@ -1516,7 +1516,7 @@ class ShopfloorVirtualMeterItem: @staticmethod def on_options(req, resp, id_, mid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, mid): diff --git a/myems-api/core/space.py b/myems-api/core/space.py index f8974679..e2253e33 100644 --- a/myems-api/core/space.py +++ b/myems-api/core/space.py @@ -925,7 +925,7 @@ class SpaceCombinedEquipmentItem: @staticmethod def on_options(req, resp, id_, eid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, eid): @@ -1092,7 +1092,7 @@ class SpaceEquipmentItem: @staticmethod def on_options(req, resp, id_, eid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, eid): @@ -1272,7 +1272,7 @@ class SpaceMeterItem: @staticmethod def on_options(req, resp, id_, mid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, mid): @@ -1454,7 +1454,7 @@ class SpaceOfflineMeterItem: @staticmethod def on_options(req, resp, id_, mid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, mid): @@ -1634,7 +1634,7 @@ class SpacePointItem: @staticmethod def on_options(req, resp, id_, pid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, pid): @@ -1801,7 +1801,7 @@ class SpaceSensorItem: @staticmethod def on_options(req, resp, id_, sid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, sid): @@ -1967,7 +1967,7 @@ class SpaceShopfloorItem: @staticmethod def on_options(req, resp, id_, sid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, sid): @@ -2133,7 +2133,7 @@ class SpaceStoreItem: @staticmethod def on_options(req, resp, id_, tid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, tid): @@ -2299,7 +2299,7 @@ class SpaceTenantItem: @staticmethod def on_options(req, resp, id_, tid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, tid): @@ -2479,7 +2479,7 @@ class SpaceVirtualMeterItem: @staticmethod def on_options(req, resp, id_, mid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, mid): diff --git a/myems-api/core/store.py b/myems-api/core/store.py index cc24dda3..91d58a27 100644 --- a/myems-api/core/store.py +++ b/myems-api/core/store.py @@ -150,15 +150,15 @@ class StoreCollection: if 'contact_id' not in new_values['data'].keys() or \ not isinstance(new_values['data']['contact_id'], int) or \ new_values['data']['contact_id'] <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', - description='API.INVALID_CONTACT_ID') + raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', + description='API.INVALID_CONTACT_ID') contact_id = new_values['data']['contact_id'] if 'cost_center_id' not in new_values['data'].keys() or \ not isinstance(new_values['data']['cost_center_id'], int) or \ new_values['data']['cost_center_id'] <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', - description='API.INVALID_COST_CENTER_ID') + raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', + description='API.INVALID_COST_CENTER_ID') cost_center_id = new_values['data']['cost_center_id'] if 'description' in new_values['data'].keys() and \ @@ -718,7 +718,7 @@ class StoreMeterItem: @staticmethod def on_options(req, resp, id_, mid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, mid): @@ -898,7 +898,7 @@ class StoreOfflineMeterItem: @staticmethod def on_options(req, resp, id_, mid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, mid): @@ -1078,7 +1078,7 @@ class StorePointItem: @staticmethod def on_options(req, resp, id_, pid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, pid): @@ -1245,7 +1245,7 @@ class StoreSensorItem: @staticmethod def on_options(req, resp, id_, sid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, sid): @@ -1425,7 +1425,7 @@ class StoreVirtualMeterItem: @staticmethod def on_options(req, resp, id_, mid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, mid): diff --git a/myems-api/core/tenant.py b/myems-api/core/tenant.py index 41a333bb..6878e3c9 100644 --- a/myems-api/core/tenant.py +++ b/myems-api/core/tenant.py @@ -195,15 +195,15 @@ class TenantCollection: if 'contact_id' not in new_values['data'].keys() or \ not isinstance(new_values['data']['contact_id'], int) or \ new_values['data']['contact_id'] <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', - description='API.INVALID_CONTACT_ID') + raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', + description='API.INVALID_CONTACT_ID') contact_id = new_values['data']['contact_id'] if 'cost_center_id' not in new_values['data'].keys() or \ not isinstance(new_values['data']['cost_center_id'], int) or \ new_values['data']['cost_center_id'] <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', - description='API.INVALID_COST_CENTER_ID') + raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', + description='API.INVALID_COST_CENTER_ID') cost_center_id = new_values['data']['cost_center_id'] if 'description' in new_values['data'].keys() and \ @@ -815,7 +815,7 @@ class TenantMeterItem: @staticmethod def on_options(req, resp, id_, mid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, mid): @@ -995,7 +995,7 @@ class TenantOfflineMeterItem: @staticmethod def on_options(req, resp, id_, mid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, mid): @@ -1175,7 +1175,7 @@ class TenantPointItem: @staticmethod def on_options(req, resp, id_, pid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, pid): @@ -1342,7 +1342,7 @@ class TenantSensorItem: @staticmethod def on_options(req, resp, id_, sid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, sid): @@ -1522,7 +1522,7 @@ class TenantVirtualMeterItem: @staticmethod def on_options(req, resp, id_, mid): - resp.status = falcon.HTTP_200 + resp.status = falcon.HTTP_200 @staticmethod def on_delete(req, resp, id_, mid): diff --git a/myems-api/core/virtualmeter.py b/myems-api/core/virtualmeter.py index e49d2475..e7f55020 100644 --- a/myems-api/core/virtualmeter.py +++ b/myems-api/core/virtualmeter.py @@ -174,8 +174,8 @@ class VirtualMeterCollection: if 'cost_center_id' not in new_values['data'].keys() or \ not isinstance(new_values['data']['cost_center_id'], int) or \ new_values['data']['cost_center_id'] <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', - description='API.INVALID_COST_CENTER_ID') + raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', + description='API.INVALID_COST_CENTER_ID') cost_center_id = new_values['data']['cost_center_id'] @@ -701,8 +701,8 @@ class VirtualMeterItem: if 'cost_center_id' not in new_values['data'].keys() or \ not isinstance(new_values['data']['cost_center_id'], int) or \ new_values['data']['cost_center_id'] <= 0: - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', - description='API.INVALID_COST_CENTER_ID') + raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', + description='API.INVALID_COST_CENTER_ID') cost_center_id = new_values['data']['cost_center_id'] diff --git a/myems-api/reports/metersubmetersbalance.py b/myems-api/reports/metersubmetersbalance.py index 04477afb..e575cfe8 100644 --- a/myems-api/reports/metersubmetersbalance.py +++ b/myems-api/reports/metersubmetersbalance.py @@ -334,10 +334,11 @@ class Reporting: } # export result to Excel file and then encode the file to base64 string - result['excel_bytes_base64'] = excelexporters.metersubmetersbalance.export(result, - master_meter['name'], - reporting_period_start_datetime_local, - reporting_period_end_datetime_local, - period_type) + result['excel_bytes_base64'] = \ + excelexporters.metersubmetersbalance.export(result, + master_meter['name'], + reporting_period_start_datetime_local, + reporting_period_end_datetime_local, + period_type) resp.body = json.dumps(result) diff --git a/myems-api/reports/tenantenergycategory.py b/myems-api/reports/tenantenergycategory.py index 6e9714e1..3d268806 100644 --- a/myems-api/reports/tenantenergycategory.py +++ b/myems-api/reports/tenantenergycategory.py @@ -554,16 +554,15 @@ class Reporting: result['reporting_period']['increment_rate_in_kgce'] = \ (result['reporting_period']['total_in_kgce'] - result['base_period']['total_in_kgce']) / \ - result['base_period']['total_in_kgce'] \ - if result['base_period']['total_in_kgce'] > Decimal(0.0) else None + result['base_period']['total_in_kgce'] if result['base_period']['total_in_kgce'] > Decimal(0.0) else None result['reporting_period']['total_in_kgce_per_unit_area'] = \ result['reporting_period']['total_in_kgco2e'] / tenant['area'] if tenant['area'] > 0.0 else None result['reporting_period']['increment_rate_in_kgco2e'] = \ (result['reporting_period']['total_in_kgco2e'] - result['base_period']['total_in_kgco2e']) / \ - result['base_period']['total_in_kgco2e'] \ - if result['base_period']['total_in_kgco2e'] > Decimal(0.0) else None + result['base_period']['total_in_kgco2e'] if result['base_period']['total_in_kgco2e'] > Decimal(0.0)\ + else None result['parameters'] = { "names": parameters_data['names'],