Code Duplication    Length = 11-11 lines in 6 locations

myems-api/core/shopfloor.py 3 locations

@@ 2239-2249 (lines=11) @@
2236
            raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
2237
                                   description='API.SHOPFLOOR_NAME_IS_ALREADY_IN_USE')
2238
2239
        if contact_id is not None:
2240
            cursor.execute(" SELECT name "
2241
                           " FROM tbl_contacts "
2242
                           " WHERE id = %s ",
2243
                           (new_values['contact']['id'],))
2244
            row = cursor.fetchone()
2245
            if row is None:
2246
                cursor.close()
2247
                cnx.close()
2248
                raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
2249
                                       description='API.CONTACT_NOT_FOUND')
2250
2251
        if cost_center_id is not None:
2252
            cursor.execute(" SELECT name "
@@ 415-425 (lines=11) @@
412
            raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
413
                                   description='API.SHOPFLOOR_NAME_IS_ALREADY_IN_USE')
414
415
        if contact_id is not None:
416
            cursor.execute(" SELECT name "
417
                           " FROM tbl_contacts "
418
                           " WHERE id = %s ",
419
                           (new_values['data']['contact_id'],))
420
            row = cursor.fetchone()
421
            if row is None:
422
                cursor.close()
423
                cnx.close()
424
                raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
425
                                       description='API.CONTACT_NOT_FOUND')
426
427
        if cost_center_id is not None:
428
            cursor.execute(" SELECT name "
@@ 150-160 (lines=11) @@
147
            raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
148
                                   description='API.SHOPFLOOR_NAME_IS_ALREADY_IN_USE')
149
150
        if contact_id is not None:
151
            cursor.execute(" SELECT name "
152
                           " FROM tbl_contacts "
153
                           " WHERE id = %s ",
154
                           (new_values['data']['contact_id'],))
155
            row = cursor.fetchone()
156
            if row is None:
157
                cursor.close()
158
                cnx.close()
159
                raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
160
                                       description='API.CONTACT_NOT_FOUND')
161
162
        if cost_center_id is not None:
163
            cursor.execute(" SELECT name "

myems-api/core/space.py 3 locations

@@ 651-661 (lines=11) @@
648
            cnx.close()
649
            raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
650
                                   description='API.TIMEZONE_NOT_FOUND')
651
        if contact_id is not None:
652
            cursor.execute(" SELECT name "
653
                           " FROM tbl_contacts "
654
                           " WHERE id = %s ",
655
                           (new_values['data']['contact_id'],))
656
            row = cursor.fetchone()
657
            if row is None:
658
                cursor.close()
659
                cnx.close()
660
                raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
661
                                       description='API.CONTACT_NOT_FOUND')
662
663
        if cost_center_id is not None:
664
            cursor.execute(" SELECT name "
@@ 253-263 (lines=11) @@
250
            cnx.close()
251
            raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
252
                                   description='API.TIMEZONE_NOT_FOUND')
253
        if contact_id is not None:
254
            cursor.execute(" SELECT name "
255
                           " FROM tbl_contacts "
256
                           " WHERE id = %s ",
257
                           (new_values['data']['contact_id'],))
258
            row = cursor.fetchone()
259
            if row is None:
260
                cursor.close()
261
                cnx.close()
262
                raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
263
                                       description='API.CONTACT_NOT_FOUND')
264
265
        if cost_center_id is not None:
266
            cursor.execute(" SELECT name "
@@ 4320-4330 (lines=11) @@
4317
            cnx.close()
4318
            raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
4319
                                   description='API.TIMEZONE_NOT_FOUND')
4320
        if contact_id is not None:
4321
            cursor.execute(" SELECT name "
4322
                           " FROM tbl_contacts "
4323
                           " WHERE id = %s ",
4324
                           (new_values['contact']['id'],))
4325
            row = cursor.fetchone()
4326
            if row is None:
4327
                cursor.close()
4328
                cnx.close()
4329
                raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
4330
                                       description='API.CONTACT_NOT_FOUND')
4331
4332
        if cost_center_id is not None:
4333
            cursor.execute(" SELECT name "