From 673df6f07c49b293b8d805b3a20cd2c11601f51c Mon Sep 17 00:00:00 2001 From: GabrielBarberini Date: Fri, 3 Nov 2023 23:38:47 -0300 Subject: [PATCH] removes dead code and reduces import line size --- lib/controllers/flight.py | 6 +++++- lib/repositories/repo_sync.py | 22 ---------------------- lib/secrets.py | 1 - 3 files changed, 5 insertions(+), 24 deletions(-) delete mode 100644 lib/repositories/repo_sync.py diff --git a/lib/controllers/flight.py b/lib/controllers/flight.py index e31c36b..5c83a5d 100644 --- a/lib/controllers/flight.py +++ b/lib/controllers/flight.py @@ -9,7 +9,11 @@ from lib.models.motor import Motor, MotorEngines, MotorKinds from lib.models.flight import Flight from lib.models.environment import Env -from lib.views.flight import FlightSummary, SurfaceWindConditions, OutOfRailConditions, BurnoutConditions, ApogeeConditions, MaximumValues, InitialConditions, NumericalIntegrationSettings, ImpactConditions, EventsRegistered, LaunchRailConditions, FlightData, FlightCreated, FlightUpdated, FlightDeleted, FlightPickle +from lib.views.flight import ( + FlightSummary, SurfaceWindConditions, OutOfRailConditions, BurnoutConditions, ApogeeConditions, MaximumValues, + InitialConditions, NumericalIntegrationSettings, ImpactConditions, EventsRegistered, LaunchRailConditions, FlightData, + FlightCreated, FlightUpdated, FlightDeleted, FlightPickle +) from lib.repositories.flight import FlightRepository from lib.controllers.environment import EnvController from lib.controllers.rocket import RocketController diff --git a/lib/repositories/repo_sync.py b/lib/repositories/repo_sync.py deleted file mode 100644 index 6117924..0000000 --- a/lib/repositories/repo_sync.py +++ /dev/null @@ -1,22 +0,0 @@ -from pymongo import MongoClient -from lib.secrets import secrets_instance - -class Repository: - """ - Base class for all repositories (singleton) - """ - _self = None - - def __new__(cls, *args, **kwargs): - if cls._self is None: - cls._self = super().__new__(cls) - return cls._self - - def __init__(self, collection: str): - self.connection_string = secrets_instance.get_secret("MONGODB_CONNECTION_STRING") - self.client = MongoClient(self.connection_string) - self.db = self.client.rocketpy - self.collection = self.db[collection] - - def __del__(self): - self.client.close() diff --git a/lib/secrets.py b/lib/secrets.py index 9565b7b..e719203 100644 --- a/lib/secrets.py +++ b/lib/secrets.py @@ -15,7 +15,6 @@ def get_os_secret(key): def get_secret(self, key): dotenv_secret = self.secrets.get(key) if not dotenv_secret: - print("cheguei") return self.get_os_secret(key) return dotenv_secret