Skip to content

Commit

Permalink
removes trailing-whitespace from controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielBarberini committed Sep 16, 2023
1 parent feec75b commit 785fb6d
Show file tree
Hide file tree
Showing 4 changed files with 207 additions and 189 deletions.
19 changes: 11 additions & 8 deletions lib/controllers/environment.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from rocketpy import Environment
from fastapi import Response, status
from typing import Dict, Any, Union

from lib.models.environment import Env
from lib.repositories.environment import EnvRepository
from lib.views.environment import EnvSummary, EnvData, EnvPlots

from fastapi import Response, status
from typing import Dict, Any, Union

import jsonpickle

class EnvController():
class EnvController():
"""
Controller for the Environment model.
Expand All @@ -27,10 +26,10 @@ def __init__(self, env: Env):
date=env.date
)
rocketpy_env.set_atmospheric_model(
type=env.atmospheric_model_type,
type=env.atmospheric_model_type,
file=env.atmospheric_model_file
)
self.rocketpy_env = rocketpy_env
self.rocketpy_env = rocketpy_env
self.env = env

def create_env(self) -> "Dict[str, str]":
Expand All @@ -47,6 +46,7 @@ def create_env(self) -> "Dict[str, str]":
else:
return Response(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)

@staticmethod
def get_env(env_id: int) -> "Union[Env, Response]":
"""
Get a env from the database.
Expand All @@ -58,14 +58,15 @@ def get_env(env_id: int) -> "Union[Env, Response]":
env model object
Raises:
HTTP 404 Not Found: If the env is not found in the database.
HTTP 404 Not Found: If the env is not found in the database.
"""
successfully_read_env = \
EnvRepository(env_id=env_id).get_env()
if not successfully_read_env:
return Response(status_code=status.HTTP_404_NOT_FOUND)
return successfully_read_env

@staticmethod
def get_rocketpy_env(env_id: int) -> "Union[Dict[str, Any], Response]":
"""
Get a rocketpy env object encoded as jsonpickle string from the database.
Expand Down Expand Up @@ -113,12 +114,13 @@ def update_env(self, env_id: int) -> "Union[Dict[str, Any], Response]":

if successfully_updated_env:
return {
"message": "Environment successfully updated",
"message": "Environment successfully updated",
"new_env_id": str(successfully_updated_env)
}
else:
return Response(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)

@staticmethod
def delete_env(env_id: int) -> "Union[Dict[str, str], Response]":
"""
Delete a env from the database.
Expand All @@ -144,6 +146,7 @@ def delete_env(env_id: int) -> "Union[Dict[str, str], Response]":
else:
return Response(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)

@staticmethod
def simulate(env_id: int) -> "Union[EnvSummary, Response]":
"""
Simulate a rocket environment.
Expand Down
Loading

0 comments on commit 785fb6d

Please sign in to comment.