Code Duplication    Length = 11-11 lines in 8 locations

myems-api/core/space.py 1 location

@@ 4331-4341 (lines=11) @@
4328
                                   description='API.INVALID_IS_OUTPUT_COUNTED_VALUE')
4329
        is_output_counted = new_values['is_output_counted']
4330
4331
        if 'contact' in new_values.keys() and \
4332
            new_values['contact'] is not None and \
4333
                'id' in new_values['contact'].keys() and \
4334
                new_values['contact']['id'] is not None:
4335
            if not isinstance(new_values['contact']['id'], int) or \
4336
                    new_values['contact']['id'] <= 0:
4337
                raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
4338
                                       description='API.INVALID_CONTACT_ID')
4339
            contact_id = new_values['contact']['id']
4340
        else:
4341
            contact_id = None
4342
4343
        if 'id' in new_values['cost_center'].keys():
4344
            if new_values['cost_center']['id'] <= 0:

myems-api/core/virtualmeter.py 1 location

@@ 1076-1086 (lines=11) @@
1073
1074
        cost_center_id = new_values['cost_center']['id']
1075
1076
        if 'energy_item' in new_values.keys() and \
1077
            new_values['energy_item'] is not None and \
1078
                'id' in new_values['energy_item'].keys() and \
1079
                new_values['energy_item']['id'] is not None:
1080
            if not isinstance(new_values['energy_item']['id'], int) or \
1081
                    new_values['energy_item']['id'] <= 0:
1082
                raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
1083
                                       description='API.INVALID_ENERGY_ITEM_ID')
1084
            energy_item_id = new_values['energy_item']['id']
1085
        else:
1086
            energy_item_id = None
1087
1088
        if 'description' in new_values.keys() and \
1089
                new_values['description'] is not None and \

myems-api/core/offlinemeter.py 1 location

@@ 805-815 (lines=11) @@
802
803
        cost_center_id = new_values['cost_center']['id']
804
805
        if 'energy_item' in new_values.keys() and \
806
            new_values['energy_item'] is not None and \
807
                'id' in new_values['energy_item'].keys() and \
808
                new_values['energy_item']['id'] is not None:
809
            if not isinstance(new_values['energy_item']['id'], int) or \
810
                    new_values['energy_item']['id'] <= 0:
811
                raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
812
                                       description='API.INVALID_ENERGY_ITEM_ID')
813
            energy_item_id = new_values['energy_item']['id']
814
        else:
815
            energy_item_id = None
816
817
        if 'description' in new_values.keys() and \
818
                new_values['description'] is not None and \

myems-api/core/meter.py 1 location

@@ 1624-1634 (lines=11) @@
1621
                                   description='API.INVALID_COST_CENTER_ID')
1622
        cost_center_id = new_values['cost_center']['id']
1623
1624
        if 'energy_item' in new_values.keys() and \
1625
            new_values['energy_item'] is not None and \
1626
                'id' in new_values['energy_item'].keys() and \
1627
                new_values['energy_item']['id'] is not None:
1628
            if not isinstance(new_values['energy_item']['id'], int) or \
1629
                    new_values['energy_item']['id'] <= 0:
1630
                raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
1631
                                       description='API.INVALID_ENERGY_ITEM_ID')
1632
            energy_item_id = new_values['energy_item']['id']
1633
        else:
1634
            energy_item_id = None
1635
1636
        if 'master_meter' in new_values.keys() and \
1637
            new_values['master_meter'] is not None and \

myems-api/core/energystoragepowerstation.py 4 locations

@@ 1386-1396 (lines=11) @@
1383
        else:
1384
            svg4_id = None
1385
1386
        if 'svg5' in new_values.keys() and \
1387
                new_values['svg5'] is not None and \
1388
                'id' in new_values['svg5'].keys() and \
1389
                new_values['svg5']['id'] is not None:
1390
            if not isinstance(new_values['svg5']['id'], int) or \
1391
                    new_values['svg5']['id'] <= 0:
1392
                raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
1393
                                       description='API.INVALID_SVG5_ID')
1394
            svg5_id = new_values['svg5']['id']
1395
        else:
1396
            svg5_id = None
1397
1398
        if 'is_cost_data_displayed' not in new_values.keys() or \
1399
                not isinstance(new_values['is_cost_data_displayed'], bool):
@@ 1374-1384 (lines=11) @@
1371
        else:
1372
            svg3_id = None
1373
1374
        if 'svg4' in new_values.keys() and \
1375
                new_values['svg4'] is not None and \
1376
                'id' in new_values['svg4'].keys() and \
1377
                new_values['svg4']['id'] is not None:
1378
            if not isinstance(new_values['svg4']['id'], int) or \
1379
                    new_values['svg4']['id'] <= 0:
1380
                raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
1381
                                       description='API.INVALID_SVG4_ID')
1382
            svg4_id = new_values['svg4']['id']
1383
        else:
1384
            svg4_id = None
1385
1386
        if 'svg5' in new_values.keys() and \
1387
                new_values['svg5'] is not None and \
@@ 1362-1372 (lines=11) @@
1359
        else:
1360
            svg2_id = None
1361
1362
        if 'svg3' in new_values.keys() and \
1363
                new_values['svg3'] is not None and \
1364
                'id' in new_values['svg3'].keys() and \
1365
                new_values['svg3']['id'] is not None:
1366
            if not isinstance(new_values['svg3']['id'], int) or \
1367
                    new_values['svg3']['id'] <= 0:
1368
                raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
1369
                                       description='API.INVALID_SVG3_ID')
1370
            svg3_id = new_values['svg3']['id']
1371
        else:
1372
            svg3_id = None
1373
1374
        if 'svg4' in new_values.keys() and \
1375
                new_values['svg4'] is not None and \
@@ 1350-1360 (lines=11) @@
1347
                                   description='API.INVALID_SVG_ID')
1348
        svg_id = new_values['svg']['id']
1349
1350
        if 'svg2' in new_values.keys() and \
1351
            new_values['svg2'] is not None and \
1352
                'id' in new_values['svg2'].keys() and \
1353
                new_values['svg2']['id'] is not None:
1354
            if not isinstance(new_values['svg2']['id'], int) or \
1355
                    new_values['svg2']['id'] <= 0:
1356
                raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
1357
                                       description='API.INVALID_SVG2_ID')
1358
            svg2_id = new_values['svg2']['id']
1359
        else:
1360
            svg2_id = None
1361
1362
        if 'svg3' in new_values.keys() and \
1363
                new_values['svg3'] is not None and \