from .database_model import database_model from .secret import secret class user(database_model): def __init__(self, id: int | None = None): super(id) self.__nick = None self.__password = None @property def nick(self) -> str: if self.__nick is None: raise Exception("Nick must be set, before access.") return self.__nick @nick.setter def nick(self, target: str) -> None: if type(target) != str: raise Exception("Nick of the user must be string.") self.__nick = target @property def password(self) -> secret: if self.__password is None: raise Exception("Password secret must be set, before access.") return self.__password @password.setter def password(self, target: secret): if type(target) != secret: raise Exception("Password of the user must be secret instance.") self.__password = target def clone(self) -> super: target = user(self.id) target.nick = self.nick target.secret = self.secret.clone() return target