krz/yoshi-cli

A password manager for the command line.

clone: git clone https://gitbay.org/krz/yoshi-cli.git

v0.2.2: yoshi/account.py · raw

 1"""
 2This script imports necessary modules for database interactions.
 3
 4Modules imported:
 5    - database: A custom module providing database functionality.
 6"""
 7
 8from yoshi import database
 9
10
11class Account:
12    """Represents a login account."""
13
14    def __init__(
15        self,
16        uuid: str,
17        application: str,  # pylint: disable=R0913,R0917
18        username: str,  # pylint: disable=R0913,R0917
19        password: str,
20        url: str,
21    ) -> None:  # pylint: disable=R0913,R0917
22        self.uuid = uuid
23        self.application = application
24        self.username = username
25        self.password = password
26        self.url = url
27
28    def display_account(self) -> None:
29        """Print the account details."""
30        print("ID:", self.uuid)
31        print("Application:", self.application)
32        print("Username:", self.username)
33        print("Password:", self.password)
34        print("URL:", self.url)
35
36    def save_account(self) -> None:
37        """Save the account details to the database."""
38        database.add_account(
39            self.uuid, self.application, self.username, self.password, self.url
40        )
41
42    def delete_account(self) -> bool:
43        """Delete the account from the database.
44
45        Returns:
46            bool: True if the deletion was successful.
47        """
48        database.delete_account(self.uuid)
49        return True