From 50eb3057d5f9e85c9d9e0763d752d33ec56ac0c9 Mon Sep 17 00:00:00 2001 From: StNicolay Date: Sun, 25 Dec 2022 21:01:18 +0300 Subject: [PATCH] Renamed classes.py into decrypted_accounts.py. Removed unnessesary elements from that file --- src/__init__.py | 4 ++-- src/account_checks.py | 2 +- src/account_parsing.py | 2 +- src/bot/handlers.py | 2 +- src/classes.py | 21 --------------------- src/decrypted_account.py | 8 ++++++++ src/encryption/other_accounts.py | 2 +- 7 files changed, 14 insertions(+), 27 deletions(-) delete mode 100644 src/classes.py create mode 100644 src/decrypted_account.py diff --git a/src/__init__.py b/src/__init__.py index 7b33bca..372432d 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -6,8 +6,8 @@ from . import ( account_checks, account_parsing, bot, - classes, database, + decrypted_account, encryption, generate_password, ) @@ -16,7 +16,7 @@ __all__ = [ "account_checks", "account_parsing", "bot", - "classes", + "decrypted_account", "encryption", "database", "generate_password", diff --git a/src/account_checks.py b/src/account_checks.py index e967d4e..2023516 100644 --- a/src/account_checks.py +++ b/src/account_checks.py @@ -1,6 +1,6 @@ import string -from .classes import DecryptedAccount +from .decrypted_account import DecryptedAccount FORBIDDEN_CHARS = frozenset("`\n") PUNCTUATION = frozenset(string.punctuation).difference(FORBIDDEN_CHARS) diff --git a/src/account_parsing.py b/src/account_parsing.py index 06ae655..be3a38f 100644 --- a/src/account_parsing.py +++ b/src/account_parsing.py @@ -3,7 +3,7 @@ from typing import Iterable, Self import pydantic -from .classes import DecryptedAccount +from .decrypted_account import DecryptedAccount class _Account(pydantic.BaseModel): diff --git a/src/bot/handlers.py b/src/bot/handlers.py index c10e474..6657e52 100644 --- a/src/bot/handlers.py +++ b/src/bot/handlers.py @@ -13,7 +13,7 @@ from ..account_checks import ( check_password, ) from ..account_parsing import accounts_to_json, json_to_accounts -from ..classes import DecryptedAccount +from ..decrypted_account import DecryptedAccount Message = telebot.types.Message diff --git a/src/classes.py b/src/classes.py deleted file mode 100644 index 9efc42a..0000000 --- a/src/classes.py +++ /dev/null @@ -1,21 +0,0 @@ -from typing import Self, TypeAlias - -import pydantic - -from .database import models - -Account: TypeAlias = models.Account - - -class DecryptedAccount(pydantic.BaseModel): - user_id: int - name: str - login: str - password: str - - @classmethod - def from_tuple(cls, tuple_: tuple[str, str, str]) -> Self: - return cls(name=tuple_[0], login=tuple_[1], password=tuple_[2]) - - def as_tuple(self) -> tuple[str, str, str]: - return (self.name, self.login, self.password) diff --git a/src/decrypted_account.py b/src/decrypted_account.py new file mode 100644 index 0000000..c0c6644 --- /dev/null +++ b/src/decrypted_account.py @@ -0,0 +1,8 @@ +import pydantic + + +class DecryptedAccount(pydantic.BaseModel): + user_id: int + name: str + login: str + password: str diff --git a/src/encryption/other_accounts.py b/src/encryption/other_accounts.py index b2c1306..9e02449 100644 --- a/src/encryption/other_accounts.py +++ b/src/encryption/other_accounts.py @@ -7,7 +7,7 @@ from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC -from ..classes import DecryptedAccount +from ..decrypted_account import DecryptedAccount from ..database.models import Account