fixed PEP8 warnings in API

pull/63/head
13621160019@163.com 2021-08-25 12:01:14 +08:00
parent f39ad7f039
commit b389887b50
17 changed files with 86 additions and 82 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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']

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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']

View File

@ -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)

View File

@ -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'],