Code Duplication    Length = 17-18 lines in 2 locations

myems-api/core/store.py 1 location

@@ 329-345 (lines=17) @@
326
        cursor.close()
327
        cnx.close()
328
329
        if row is None:
330
            raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
331
                                   description='API.STORE_NOT_FOUND')
332
        else:
333
            meta_result = {"id": row[0],
334
                           "name": row[1],
335
                           "uuid": row[2],
336
                           "address": row[3],
337
                           "latitude": row[4],
338
                           "longitude": row[5],
339
                           "area": row[6],
340
                           "store_type": store_type_dict.get(row[7], None),
341
                           "is_input_counted": bool(row[8]),
342
                           "contact": contact_dict.get(row[9], None),
343
                           "cost_center": cost_center_dict.get(row[10], None),
344
                           "description": row[11],
345
                           "qrcode": 'store:' + row[2]}
346
347
        resp.text = json.dumps(meta_result)
348

myems-api/core/photovoltaicpowerstation.py 1 location

@@ 721-738 (lines=18) @@
718
        cursor.close()
719
        cnx.close()
720
721
        if row is None:
722
            raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
723
                                   description='API.PHOTOVOLTAIC_POWER_STATION_NOT_FOUND')
724
        else:
725
            meta_result = {"name": row[1],
726
                           "uuid": row[2],
727
                           "station_code": row[3],
728
                           "address": row[4],
729
                           "latitude": row[5],
730
                           "longitude": row[6],
731
                           "rated_capacity": row[7],
732
                           "rated_power": row[8],
733
                           "contact": contact_dict.get(row[9], None),
734
                           "cost_center": cost_center_dict.get(row[10], None),
735
                           "svg": svg_dict.get(row[11], None),
736
                           "is_cost_data_displayed": bool(row[12]),
737
                           "phase_of_lifecycle": row[13],
738
                           "description": row[14]}
739
740
        resp.text = json.dumps(meta_result)
741