Code Duplication    Length = 11-11 lines in 6 locations

myems-api/core/space.py 3 locations

@@ 4476-4486 (lines=11) @@
4473
            cnx.close()
4474
            raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
4475
                                   description='API.TIMEZONE_NOT_FOUND')
4476
        if contact_id is not None:
4477
            cursor.execute(" SELECT name "
4478
                           " FROM tbl_contacts "
4479
                           " WHERE id = %s ",
4480
                           (new_values['contact']['id'],))
4481
            row = cursor.fetchone()
4482
            if row is None:
4483
                cursor.close()
4484
                cnx.close()
4485
                raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
4486
                                       description='API.CONTACT_NOT_FOUND')
4487
4488
        if cost_center_id is not None:
4489
            cursor.execute(" SELECT name "
@@ 676-686 (lines=11) @@
673
            cnx.close()
674
            raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
675
                                   description='API.TIMEZONE_NOT_FOUND')
676
        if contact_id is not None:
677
            cursor.execute(" SELECT name "
678
                           " FROM tbl_contacts "
679
                           " WHERE id = %s ",
680
                           (new_values['data']['contact_id'],))
681
            row = cursor.fetchone()
682
            if row is None:
683
                cursor.close()
684
                cnx.close()
685
                raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
686
                                       description='API.CONTACT_NOT_FOUND')
687
688
        if cost_center_id is not None:
689
            cursor.execute(" SELECT name "
@@ 271-281 (lines=11) @@
268
            cnx.close()
269
            raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
270
                                   description='API.TIMEZONE_NOT_FOUND')
271
        if contact_id is not None:
272
            cursor.execute(" SELECT name "
273
                           " FROM tbl_contacts "
274
                           " WHERE id = %s ",
275
                           (new_values['data']['contact_id'],))
276
            row = cursor.fetchone()
277
            if row is None:
278
                cursor.close()
279
                cnx.close()
280
                raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
281
                                       description='API.CONTACT_NOT_FOUND')
282
283
        if cost_center_id is not None:
284
            cursor.execute(" SELECT name "

myems-api/core/shopfloor.py 3 locations

@@ 2373-2383 (lines=11) @@
2370
            raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
2371
                                   description='API.SHOPFLOOR_NAME_IS_ALREADY_IN_USE')
2372
2373
        if contact_id is not None:
2374
            cursor.execute(" SELECT name "
2375
                           " FROM tbl_contacts "
2376
                           " WHERE id = %s ",
2377
                           (new_values['contact']['id'],))
2378
            row = cursor.fetchone()
2379
            if row is None:
2380
                cursor.close()
2381
                cnx.close()
2382
                raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
2383
                                       description='API.CONTACT_NOT_FOUND')
2384
2385
        if cost_center_id is not None:
2386
            cursor.execute(" SELECT name "
@@ 470-480 (lines=11) @@
467
            raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
468
                                   description='API.SHOPFLOOR_NAME_IS_ALREADY_IN_USE')
469
470
        if contact_id is not None:
471
            cursor.execute(" SELECT name "
472
                           " FROM tbl_contacts "
473
                           " WHERE id = %s ",
474
                           (new_values['data']['contact_id'],))
475
            row = cursor.fetchone()
476
            if row is None:
477
                cursor.close()
478
                cnx.close()
479
                raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
480
                                       description='API.CONTACT_NOT_FOUND')
481
482
        if cost_center_id is not None:
483
            cursor.execute(" SELECT name "
@@ 198-208 (lines=11) @@
195
            raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
196
                                   description='API.SHOPFLOOR_NAME_IS_ALREADY_IN_USE')
197
198
        if contact_id is not None:
199
            cursor.execute(" SELECT name "
200
                           " FROM tbl_contacts "
201
                           " WHERE id = %s ",
202
                           (new_values['data']['contact_id'],))
203
            row = cursor.fetchone()
204
            if row is None:
205
                cursor.close()
206
                cnx.close()
207
                raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
208
                                       description='API.CONTACT_NOT_FOUND')
209
210
        if cost_center_id is not None:
211
            cursor.execute(" SELECT name "