krz/yoshi-cli

Archived

A password manager for the command line. cli password-manager terminal

Commit 5887e1eddd

5887e1eddd0eb3eb7fed517c72bb6671847c655c

parent: 598e71b5ea

Verified · cmc

cmc <hello@cleberg.net> · 2024-11-02 22:26 UTC

fix pylint errors

Layout: unified · split

Account.py +2 −1
@@ -13,6 +13,7 @@ class Account:
13 13
14 def __init__(self, uuid: str, application: str, username: str, 14 def __init__(self, uuid: str, application: str, username: str,
15 password: str, url: str) -> None: 15 password: str, url: str) -> None:
16 self.self = self
16 self.uuid = uuid 17 self.uuid = uuid
17 self.application = application 18 self.application = application
18 self.username = username 19 self.username = username
@@ -29,7 +30,7 @@ class Account:
29 30
30 def save_account(self) -> None: 31 def save_account(self) -> None:
31 """Save the account details to the database.""" 32 """Save the account details to the database."""
32 database.create_account( 33 database.add_account(
33 self.uuid, self.application, self.username, self.password, self.url) 34 self.uuid, self.application, self.username, self.password, self.url)
34 35
35 def delete_account(self) -> bool: 36 def delete_account(self) -> bool:
main.py +1 −1
@@ -116,7 +116,7 @@ if __name__ == '__main__':
116 else: 116 else:
117 key = input('Please enter your encryption key: ') 117 key = input('Please enter your encryption key: ')
118 crypto.encrypt(key) 118 crypto.encrypt(key)
119 elif database.table_check(): 119 elif database.check_table():
120 if args.new: 120 if args.new:
121 process.create_account() 121 process.create_account()
122 elif args.list: 122 elif args.list:
process.py +14 −11
@@ -23,12 +23,12 @@ Usage:
23 Run this script in your terminal to access these functions. 23 Run this script in your terminal to access these functions.
24""" 24"""
25 25
26from account import Account
27import database
28from string import ascii_letters, punctuation, digits 26from string import ascii_letters, punctuation, digits
29import random 27import random
30import uuid 28import uuid
31from prettytable import PrettyTable 29from prettytable import PrettyTable
30from account import Account
31import database
32 32
33 33
34def generate_characters(n: int) -> list: 34def generate_characters(n: int) -> list:
@@ -78,7 +78,8 @@ def generate_passphrase(n: int, sep: str) -> str:
78 phrases = [] 78 phrases = []
79 lucky_number = random.choice(range(0, n)) 79 lucky_number = random.choice(range(0, n))
80 for _ in range(n): 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 line = line.replace('\n', '') 83 line = line.replace('\n', '')
83 if _ == lucky_number: 84 if _ == lucky_number:
84 phrases.append(line.strip().capitalize() + str(_)) 85 phrases.append(line.strip().capitalize() + str(_))
@@ -102,17 +103,17 @@ def list_accounts() -> None:
102 print(t) 103 print(t)
103 104
104 105
105def delete_account(uuid: str) -> None: 106def delete_account(account_uuid: str) -> None:
106 """ 107 """
107 Deletes an account by its UUID. 108 Deletes an account by its UUID.
108 109
109 Args: 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 Returns: 113 Returns:
113 None 114 None
114 """ 115 """
115 account_record = database.find_account(uuid) 116 account_record = database.find_account(account_uuid)
116 account = Account(account_record[0][0], 117 account = Account(account_record[0][0],
117 account_record[0][1], 118 account_record[0][1],
118 account_record[0][2], 119 account_record[0][2],
@@ -130,7 +131,8 @@ def purge_accounts() -> None:
130 None 131 None
131 """ 132 """
132 check = input( 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 if check.lower() == 'y': 136 if check.lower() == 'y':
135 database.purge_table() 137 database.purge_table()
136 database.purge_database() 138 database.purge_database()
@@ -174,7 +176,7 @@ def create_account() -> None:
174 if password_length < 8: 176 if password_length < 8:
175 print('Error: Your password length must be at least 8 characters.') 177 print('Error: Your password length must be at least 8 characters.')
176 return 178 return
177 password_string = generate_password(password_length) 179 password_string = generate_password(password_length) # pylint: disable=undefined-variable
178 else: 180 else:
179 password_string = input('Please enter your desired password: ') 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
188def edit_account(uuid: str, edit_parameter: int) -> None: 190def edit_account(account_uuid: str, edit_parameter: int) -> None:
189 """ 191 """
190 Allow users to edit any account information except the UUID. 192 Allow users to edit any account information except the UUID.
191 193
192 Args: 194 Args:
193 uuid (str): Unique identifier of the account. 195 account_uuid (str): Unique identifier of the account.
194 edit_parameter (int): Parameter indicating which field to edit. 196 edit_parameter (int): Parameter indicating which field to edit.
195 Valid values are 1 for application name, 2 for username, 197 Valid values are 1 for application name, 2 for username,
196 3 for password, and 4 for URL. 198 3 for password, and 4 for URL.
197 """ 199 """
200 field_name, new_value = ''
198 if edit_parameter == 1: 201 if edit_parameter == 1:
199 field_name = 'application' 202 field_name = 'application'
200 new_value = input('Please enter your desired Application name: ') 203 new_value = input('Please enter your desired Application name: ')
@@ -218,5 +221,5 @@ def edit_account(uuid: str, edit_parameter: int) -> None:
218 elif edit_parameter == 4: 221 elif edit_parameter == 4:
219 field_name = 'url' 222 field_name = 'url'
220 new_value = input('Please enter your desired URL: ') 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 print('Account successfully updated.') 225 print('Account successfully updated.')