| @@ -23,12 +23,12 @@ Usage: |
| 23 | 23 | Run this script in your terminal to access these functions. |
| 24 | 24 | """ |
| 25 | 25 | |
| 26 | | from account import Account |
| 27 | | import database |
| 28 | 26 | from string import ascii_letters, punctuation, digits |
| 29 | 27 | import random |
| 30 | 28 | import uuid |
| 31 | 29 | from prettytable import PrettyTable |
| 30 | from account import Account |
| 31 | import database |
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | def generate_characters(n: int) -> list: |
| @@ -78,7 +78,8 @@ def generate_passphrase(n: int, sep: str) -> str: |
| 78 | 78 | phrases = [] |
| 79 | 79 | lucky_number = random.choice(range(0, n)) |
| 80 | 80 | for _ in range(n): |
| 81 | | line = random.choice(open('wordlist.txt').readlines()) |
| 81 | with open('wordlist.txt', 'r', encoding='utf-8') as file: |
| 82 | line = random.choice(file.readlines()) |
| 82 | 83 | line = line.replace('\n', '') |
| 83 | 84 | if _ == lucky_number: |
| 84 | 85 | phrases.append(line.strip().capitalize() + str(_)) |
| @@ -102,17 +103,17 @@ def list_accounts() -> None: |
| 102 | 103 | print(t) |
| 103 | 104 | |
| 104 | 105 | |
| 105 | | def delete_account(uuid: str) -> None: |
| 106 | def delete_account(account_uuid: str) -> None: |
| 106 | 107 | """ |
| 107 | 108 | Deletes an account by its UUID. |
| 108 | 109 | |
| 109 | 110 | Args: |
| 110 | | uuid (str): The UUID of the account to delete |
| 111 | account_uuid (str): The UUID of the account to delete |
| 111 | 112 | |
| 112 | 113 | Returns: |
| 113 | 114 | None |
| 114 | 115 | """ |
| 115 | | account_record = database.find_account(uuid) |
| 116 | account_record = database.find_account(account_uuid) |
| 116 | 117 | account = Account(account_record[0][0], |
| 117 | 118 | account_record[0][1], |
| 118 | 119 | account_record[0][2], |
| @@ -130,7 +131,8 @@ def purge_accounts() -> None: |
| 130 | 131 | None |
| 131 | 132 | """ |
| 132 | 133 | check = input( |
| 133 | | 'Are you absolutely sure you want to delete your password vault? This action is irreversible. (y/n): ') |
| 134 | '''Are you absolutely sure you want to delete your password vault? |
| 135 | This action is irreversible. (y/n): ''') |
| 134 | 136 | if check.lower() == 'y': |
| 135 | 137 | database.purge_table() |
| 136 | 138 | database.purge_database() |
| @@ -174,7 +176,7 @@ def create_account() -> None: |
| 174 | 176 | if password_length < 8: |
| 175 | 177 | print('Error: Your password length must be at least 8 characters.') |
| 176 | 178 | return |
| 177 | | password_string = generate_password(password_length) |
| 179 | password_string = generate_password(password_length) # pylint: disable=undefined-variable |
| 178 | 180 | else: |
| 179 | 181 | password_string = input('Please enter your desired password: ') |
| 180 | 182 | |
| @@ -185,16 +187,17 @@ def create_account() -> None: |
| 185 | 187 | |
| 186 | 188 | |
| 187 | 189 | |
| 188 | | def edit_account(uuid: str, edit_parameter: int) -> None: |
| 190 | def edit_account(account_uuid: str, edit_parameter: int) -> None: |
| 189 | 191 | """ |
| 190 | 192 | Allow users to edit any account information except the UUID. |
| 191 | 193 | |
| 192 | 194 | Args: |
| 193 | | uuid (str): Unique identifier of the account. |
| 195 | account_uuid (str): Unique identifier of the account. |
| 194 | 196 | edit_parameter (int): Parameter indicating which field to edit. |
| 195 | 197 | Valid values are 1 for application name, 2 for username, |
| 196 | 198 | 3 for password, and 4 for URL. |
| 197 | 199 | """ |
| 200 | field_name, new_value = '' |
| 198 | 201 | if edit_parameter == 1: |
| 199 | 202 | field_name = 'application' |
| 200 | 203 | new_value = input('Please enter your desired Application name: ') |
| @@ -218,5 +221,5 @@ def edit_account(uuid: str, edit_parameter: int) -> None: |
| 218 | 221 | elif edit_parameter == 4: |
| 219 | 222 | field_name = 'url' |
| 220 | 223 | new_value = input('Please enter your desired URL: ') |
| 221 | | database.update_account(field_name, new_value, uuid) |
| 224 | database.update_account(field_name, new_value, account_uuid) |
| 222 | 225 | print('Account successfully updated.') |