From bae760a62fc6a480fbe615dff6a7de03c7fd6d1d Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Wed, 24 Jun 2020 09:13:09 +0200 Subject: Add formatter --- opendc/api/v2/rooms/roomId/endpoint.py | 52 +++++++--------------------- opendc/api/v2/rooms/roomId/tiles/endpoint.py | 40 ++++++--------------- 2 files changed, 24 insertions(+), 68 deletions(-) (limited to 'opendc/api/v2/rooms') diff --git a/opendc/api/v2/rooms/roomId/endpoint.py b/opendc/api/v2/rooms/roomId/endpoint.py index 1dfc32cc..a43a82e7 100644 --- a/opendc/api/v2/rooms/roomId/endpoint.py +++ b/opendc/api/v2/rooms/roomId/endpoint.py @@ -9,18 +9,14 @@ def GET(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'roomId': 'int' - } - ) + request.check_required_parameters(path={'roomId': 'int'}) except exceptions.ParameterError as e: return Response(400, e.message) # Instantiate a Room from the database - room = Room.from_primary_key((request.params_path['roomId'],)) + room = Room.from_primary_key((request.params_path['roomId'], )) # Make sure this Room exists @@ -36,11 +32,7 @@ def GET(request): room.read() - return Response( - 200, - 'Successfully retrieved {}.'.format(room), - room.to_JSON() - ) + return Response(200, 'Successfully retrieved {}.'.format(room), room.to_JSON()) def PUT(request): @@ -49,24 +41,18 @@ def PUT(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'roomId': 'int' - }, - body={ - 'room': { - 'name': 'string', - 'roomType': 'string' - } - } - ) + request.check_required_parameters(path={'roomId': 'int'}, + body={'room': { + 'name': 'string', + 'roomType': 'string' + }}) except exceptions.ParameterError as e: return Response(400, e.message) # Instantiate a Room from the database - room = Room.from_primary_key((request.params_path['roomId'],)) + room = Room.from_primary_key((request.params_path['roomId'], )) # Make sure this Room exists @@ -90,11 +76,7 @@ def PUT(request): # Return this Room - return Response( - 200, - 'Successfully updated {}.'.format(room), - room.to_JSON() - ) + return Response(200, 'Successfully updated {}.'.format(room), room.to_JSON()) def DELETE(request): @@ -103,18 +85,14 @@ def DELETE(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'roomId': 'int' - } - ) + request.check_required_parameters(path={'roomId': 'int'}) except exceptions.ParameterError as e: return Response(400, e.message) # Instantiate a Room and make sure it exists - room = Room.from_primary_key((request.params_path['roomId'],)) + room = Room.from_primary_key((request.params_path['roomId'], )) if not room.exists(): return Response(404, '{} not found.'.format(room)) @@ -130,8 +108,4 @@ def DELETE(request): # Return this Room - return Response( - 200, - 'Successfully deleted {}.'.format(room), - room.to_JSON() - ) + return Response(200, 'Successfully deleted {}.'.format(room), room.to_JSON()) diff --git a/opendc/api/v2/rooms/roomId/tiles/endpoint.py b/opendc/api/v2/rooms/roomId/tiles/endpoint.py index a4ef51e7..6e498a48 100644 --- a/opendc/api/v2/rooms/roomId/tiles/endpoint.py +++ b/opendc/api/v2/rooms/roomId/tiles/endpoint.py @@ -10,18 +10,14 @@ def GET(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'roomId': 'int' - } - ) + request.check_required_parameters(path={'roomId': 'int'}) except exceptions.ParameterError as e: return Response(400, e.message) # Instantiate a Room from the database - room = Room.from_primary_key((request.params_path['roomId'],)) + room = Room.from_primary_key((request.params_path['roomId'], )) # Make sure this Room exists @@ -40,11 +36,7 @@ def GET(request): for tile in tiles: tile.read() - return Response( - 200, - 'Successfully retrieved Tiles for {}.'.format(room), - [x.to_JSON() for x in tiles] - ) + return Response(200, 'Successfully retrieved Tiles for {}.'.format(room), [x.to_JSON() for x in tiles]) def POST(request): @@ -53,18 +45,12 @@ def POST(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'roomId': 'int' - }, - body={ - 'tile': { - 'roomId': 'int', - 'positionX': 'int', - 'positionY': 'int' - } - } - ) + request.check_required_parameters(path={'roomId': 'int'}, + body={'tile': { + 'roomId': 'int', + 'positionX': 'int', + 'positionY': 'int' + }}) except exceptions.ParameterError as e: return Response(400, e.message) @@ -74,7 +60,7 @@ def POST(request): # Instantiate a Room from the database - room = Room.from_primary_key((request.params_path['roomId'],)) + room = Room.from_primary_key((request.params_path['roomId'], )) # Make sure this Room exists @@ -114,8 +100,4 @@ def POST(request): tile.read() - return Response( - 200, - 'Successfully added {}.'.format(tile), - tile.to_JSON() - ) + return Response(200, 'Successfully added {}.'.format(tile), tile.to_JSON()) -- cgit v1.2.3