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:
1313
1414 def __init__(self, uuid: str, application: str, username: str,
1515 password: str, url: str) -> None:
16 self.self = self
1617 self.uuid = uuid
1718 self.application = application
1819 self.username = username
@@ -29,7 +30,7 @@ class Account:
2930
3031 def save_account(self) -> None:
3132 """Save the account details to the database."""
32 database.create_account(
33 database.add_account(
3334 self.uuid, self.application, self.username, self.password, self.url)
3435
3536 def delete_account(self) -> bool:
main.py +1 −1
@@ -116,7 +116,7 @@ if __name__ == '__main__':
116116 else:
117117 key = input('Please enter your encryption key: ')
118118 crypto.encrypt(key)
119 elif database.table_check():
119 elif database.check_table():
120120 if args.new:
121121 process.create_account()
122122 elif args.list:
process.py +14 −11
@@ -23,12 +23,12 @@ Usage:
2323 Run this script in your terminal to access these functions.
2424"""
2525
26from account import Account
27import database
2826from string import ascii_letters, punctuation, digits
2927import random
3028import uuid
3129from prettytable import PrettyTable
30from account import Account
31import database
3232
3333
3434def generate_characters(n: int) -> list:
@@ -78,7 +78,8 @@ def generate_passphrase(n: int, sep: str) -> str:
7878 phrases = []
7979 lucky_number = random.choice(range(0, n))
8080 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())
8283 line = line.replace('\n', '')
8384 if _ == lucky_number:
8485 phrases.append(line.strip().capitalize() + str(_))
@@ -102,17 +103,17 @@ def list_accounts() -> None:
102103 print(t)
103104
104105
105def delete_account(uuid: str) -> None:
106def delete_account(account_uuid: str) -> None:
106107 """
107108 Deletes an account by its UUID.
108109
109110 Args:
110 uuid (str): The UUID of the account to delete
111 account_uuid (str): The UUID of the account to delete
111112
112113 Returns:
113114 None
114115 """
115 account_record = database.find_account(uuid)
116 account_record = database.find_account(account_uuid)
116117 account = Account(account_record[0][0],
117118 account_record[0][1],
118119 account_record[0][2],
@@ -130,7 +131,8 @@ def purge_accounts() -> None:
130131 None
131132 """
132133 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): ''')
134136 if check.lower() == 'y':
135137 database.purge_table()
136138 database.purge_database()
@@ -174,7 +176,7 @@ def create_account() -> None:
174176 if password_length < 8:
175177 print('Error: Your password length must be at least 8 characters.')
176178 return
177 password_string = generate_password(password_length)
179 password_string = generate_password(password_length) # pylint: disable=undefined-variable
178180 else:
179181 password_string = input('Please enter your desired password: ')
180182
@@ -185,16 +187,17 @@ def create_account() -> None:
185187
186188
187189
188def edit_account(uuid: str, edit_parameter: int) -> None:
190def edit_account(account_uuid: str, edit_parameter: int) -> None:
189191 """
190192 Allow users to edit any account information except the UUID.
191193
192194 Args:
193 uuid (str): Unique identifier of the account.
195 account_uuid (str): Unique identifier of the account.
194196 edit_parameter (int): Parameter indicating which field to edit.
195197 Valid values are 1 for application name, 2 for username,
196198 3 for password, and 4 for URL.
197199 """
200 field_name, new_value = ''
198201 if edit_parameter == 1:
199202 field_name = 'application'
200203 new_value = input('Please enter your desired Application name: ')
@@ -218,5 +221,5 @@ def edit_account(uuid: str, edit_parameter: int) -> None:
218221 elif edit_parameter == 4:
219222 field_name = 'url'
220223 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)
222225 print('Account successfully updated.')