Aravinth Manivannan
73430848e8
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
26 lines
675 B
Python
26 lines
675 B
Python
from ftest_common.logger import logger
|
|
|
|
|
|
class Database(object):
|
|
_instance = None
|
|
db = {}
|
|
# { "user": [{name: foo..}{..}{..}] }
|
|
|
|
def __new__(cls):
|
|
if cls._instance is None:
|
|
logger.info("Creating the store")
|
|
cls._instance = super(Database, cls).__new__(cls)
|
|
return cls._instance
|
|
|
|
def get_user(self, username):
|
|
for u in self.db["users"]:
|
|
print(u)
|
|
if u["username"] == username:
|
|
return u
|
|
return None
|
|
|
|
def add_user(self, username):
|
|
if "users" not in self.db:
|
|
self.db["users"] = []
|
|
|
|
self.db["users"].append({"username": username})
|