Renamed classes.py into decrypted_accounts.py. Removed unnessesary elements from that file

This commit is contained in:
StNicolay 2022-12-25 21:01:18 +03:00
parent 3f744723a9
commit 50eb3057d5
7 changed files with 14 additions and 27 deletions

View File

@ -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",

View File

@ -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)

View File

@ -3,7 +3,7 @@ from typing import Iterable, Self
import pydantic
from .classes import DecryptedAccount
from .decrypted_account import DecryptedAccount
class _Account(pydantic.BaseModel):

View File

@ -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

View File

@ -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)

8
src/decrypted_account.py Normal file
View File

@ -0,0 +1,8 @@
import pydantic
class DecryptedAccount(pydantic.BaseModel):
user_id: int
name: str
login: str
password: str

View File

@ -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