Code Duplication    Length = 17-18 lines in 2 locations

myems-api/core/store.py 1 location

@@ 369-385 (lines=17) @@
366
        cursor.close()
367
        cnx.close()
368
369
        if row is None:
370
            raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
371
                                   description='API.STORE_NOT_FOUND')
372
        else:
373
            meta_result = {"id": row[0],
374
                           "name": row[1],
375
                           "uuid": row[2],
376
                           "address": row[3],
377
                           "latitude": row[4],
378
                           "longitude": row[5],
379
                           "area": row[6],
380
                           "store_type": store_type_dict.get(row[7], None),
381
                           "is_input_counted": bool(row[8]),
382
                           "contact": contact_dict.get(row[9], None),
383
                           "cost_center": cost_center_dict.get(row[10], None),
384
                           "description": row[11],
385
                           "qrcode": 'store:' + row[2]}
386
387
        resp.text = json.dumps(meta_result)
388

myems-api/core/photovoltaicpowerstation.py 1 location

@@ 756-773 (lines=18) @@
753
        cursor.close()
754
        cnx.close()
755
756
        if row is None:
757
            raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
758
                                   description='API.PHOTOVOLTAIC_POWER_STATION_NOT_FOUND')
759
        else:
760
            meta_result = {"name": row[1],
761
                           "uuid": row[2],
762
                           "station_code": row[3],
763
                           "address": row[4],
764
                           "latitude": row[5],
765
                           "longitude": row[6],
766
                           "rated_capacity": row[7],
767
                           "rated_power": row[8],
768
                           "contact": contact_dict.get(row[9], None),
769
                           "cost_center": cost_center_dict.get(row[10], None),
770
                           "svg": svg_dict.get(row[11], None),
771
                           "is_cost_data_displayed": bool(row[12]),
772
                           "phase_of_lifecycle": row[13],
773
                           "description": row[14]}
774
775
        resp.text = json.dumps(meta_result)
776