Skip to content

Commit

Permalink
naming
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasByr committed Oct 17, 2023
1 parent 96f7f94 commit 8138bf6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/db/users_db.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import hashlib

import yaml
import yaml as yml


__all__ = ["UsersDB"]
Expand All @@ -17,11 +17,11 @@ def read_db(self, user_name: str, password: str, test: bool = False) -> bool:
users: dict[str, str] = {}
filename = "test_users.yml" if test else "users.yml"
with open(os.path.join(self.CACHE_FOLDER, "default_users.yml"), "r") as f:
for user in yaml.safe_load(f)["users"]:
for user in yml.safe_load(f)["users"]:
users[user["username"]] = user["password"]
try:
with open(os.path.join(self.CACHE_FOLDER, filename), "r") as f:
for user in yaml.safe_load(f)["users"]:
for user in yml.safe_load(f)["users"]:
users[user["username"]] = user["password"]
except FileNotFoundError:
pass
Expand All @@ -41,14 +41,14 @@ def write_db(self, user_name: str, password: str, test: bool = False):
users = []
try:
with open(os.path.join(self.CACHE_FOLDER, filename), "r") as f:
users = yaml.safe_load(f)["users"]
users = yml.safe_load(f)["users"]
except FileNotFoundError:
pass
except TypeError:
pass
users.append({"username": user_name, "password": password})
with open(os.path.join(self.CACHE_FOLDER, filename), "w") as f:
yaml.dump({"users": users}, f)
yml.dump({"users": users}, f)

def reset_test_db(self):
if os.path.exists(self.CACHE_FOLDER):
Expand Down

0 comments on commit 8138bf6

Please sign in to comment.