diff options
author | Christian Cleberg <hello@cleberg.net> | 2025-04-05 13:36:49 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-05 13:36:49 -0500 |
commit | c8617ce8aecb40ccf1d13c02dcd7d7e74e79b56b (patch) | |
tree | cf901030197768b2aa21d2d3fcf0426948a94111 /yoshi/process.py | |
parent | 1fc982100a13de26bfca3419d1a6c5a65acad3d2 (diff) | |
download | yoshi-cli-c8617ce8aecb40ccf1d13c02dcd7d7e74e79b56b.tar.gz yoshi-cli-c8617ce8aecb40ccf1d13c02dcd7d7e74e79b56b.tar.bz2 yoshi-cli-c8617ce8aecb40ccf1d13c02dcd7d7e74e79b56b.zip |
migrate from pylint to ruff-action (#4)
* migrate from pylint to ruff-action
* temporarily disable push param
* Commit from GitHub Actions (Pylint)
* re-enable push param
---------
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'yoshi/process.py')
-rw-r--r-- | yoshi/process.py | 105 |
1 files changed, 58 insertions, 47 deletions
diff --git a/yoshi/process.py b/yoshi/process.py index f09c036..ed9f456 100644 --- a/yoshi/process.py +++ b/yoshi/process.py @@ -32,6 +32,7 @@ from yoshi.account import Account from yoshi import database from yoshi.wordlist import WORDLIST + def generate_characters(n: int) -> list: """ Generates a list of n random characters from the set of ASCII letters, @@ -61,7 +62,7 @@ def shuffle_characters(characters: list) -> str: str: A string representation of the shuffled characters """ random.shuffle(characters) - character_string = ''.join(characters) + character_string = "".join(characters) return character_string @@ -96,7 +97,7 @@ def list_accounts() -> None: None """ accounts = database.find_accounts() - t = PrettyTable(['UUID', 'Application', 'Username', 'Password', 'URL']) + t = PrettyTable(["UUID", "Application", "Username", "Password", "URL"]) for account in accounts: t.add_row([account[0], account[1], account[2], account[3], account[4]]) print(t) @@ -113,13 +114,15 @@ def delete_account(account_uuid: str) -> None: None """ account_record = database.find_account(account_uuid) - account = Account(account_record[0][0], - account_record[0][1], - account_record[0][2], - account_record[0][3], - account_record[0][4]) + account = Account( + account_record[0][0], + account_record[0][1], + account_record[0][2], + account_record[0][3], + account_record[0][4], + ) if account.delete_account(): - print('Account successfully deleted.') + print("Account successfully deleted.") def purge_accounts() -> None: @@ -130,12 +133,15 @@ def purge_accounts() -> None: None """ check = input( - '''Are you absolutely sure you want to delete your password vault? - This action is irreversible. (y/n): ''') - if check.lower() == 'y': + """Are you absolutely sure you want to delete your password vault? + This action is irreversible. (y/n): """ + ) + if check.lower() == "y": database.purge_table() database.purge_database() - print('The password vault has been purged. You may now exit or create a new one.') + print( + "The password vault has been purged. You may now exit or create a new one." + ) def create_account() -> None: @@ -145,46 +151,50 @@ def create_account() -> None: Returns: None """ - application_string = input('Please enter a name for this account: ') - username_string = input('Please enter your username for this account: ') - url_string = input('(Optional) Please enter a URL for this account: ') + application_string = input("Please enter a name for this account: ") + username_string = input("Please enter your username for this account: ") + url_string = input("(Optional) Please enter a URL for this account: ") password_type = input( - '''Do you want a random character password (p), an XKCD-style passphrase -(x), or a custom password (c)? (p|x|c): ''' + """Do you want a random character password (p), an XKCD-style passphrase +(x), or a custom password (c)? (p|x|c): """ ) - if password_type not in ['p', 'x', 'c']: - print('Error: Invalid choice. Please choose p, x, or c.') + if password_type not in ["p", "x", "c"]: + print("Error: Invalid choice. Please choose p, x, or c.") return - if password_type == 'x': + if password_type == "x": password_length = int( - input('Please enter number of words to include (min. 2): ') + input("Please enter number of words to include (min. 2): ") ) if password_length < 3: - print('Error: Your passphrase length must be at least 3 words.') + print("Error: Your passphrase length must be at least 3 words.") return password_separator = input( - 'Please enter your desired separator symbol (_,-, ~, etc.): ' + "Please enter your desired separator symbol (_,-, ~, etc.): " ) password_string = generate_passphrase(password_length, password_separator) - elif password_type == 'p': + elif password_type == "p": password_length = int( - input('Please enter your desired password length (min. 8): ') + input("Please enter your desired password length (min. 8): ") ) if password_length < 8: - print('Error: Your password length must be at least 8 characters.') + print("Error: Your password length must be at least 8 characters.") return password_characters = generate_characters(password_length) password_string = shuffle_characters(password_characters) else: - password_string = input('Please enter your desired password: ') - - account = Account(str(uuid.uuid4()), application_string, - username_string, password_string, url_string) + password_string = input("Please enter your desired password: ") + + account = Account( + str(uuid.uuid4()), + application_string, + username_string, + password_string, + url_string, + ) account.save_account() - print('Account saved to the vault. Use `--list` to see all saved accounts.') - + print("Account saved to the vault. Use `--list` to see all saved accounts.") def edit_account(account_uuid: str, edit_parameter: int) -> None: @@ -197,29 +207,30 @@ def edit_account(account_uuid: str, edit_parameter: int) -> None: Valid values are 1 for application name, 2 for username, 3 for password, and 4 for URL. """ - field_name, new_value = '' + field_name, new_value = "" if edit_parameter == 1: - field_name = 'application' - new_value = input('Please enter your desired Application name: ') + field_name = "application" + new_value = input("Please enter your desired Application name: ") elif edit_parameter == 2: - field_name = 'username' - new_value = input('Please enter your desired username: ') + field_name = "username" + new_value = input("Please enter your desired username: ") elif edit_parameter == 3: - field_name = 'password' + field_name = "password" type_check = input( - 'Do you want a new random password or to enter a custom password? ' - '(random/custom): ').lower() - if type_check == 'random': - password_length = int(input('Please enter your desired password length: ')) + "Do you want a new random password or to enter a custom password? " + "(random/custom): " + ).lower() + if type_check == "random": + password_length = int(input("Please enter your desired password length: ")) if password_length < 8: - print('Error: Your password length must be at least 8 characters.') + print("Error: Your password length must be at least 8 characters.") else: password_characters = generate_characters(password_length) new_value = shuffle_characters(password_characters) else: - new_value = input('Please enter your desired password: ') + new_value = input("Please enter your desired password: ") elif edit_parameter == 4: - field_name = 'url' - new_value = input('Please enter your desired URL: ') + field_name = "url" + new_value = input("Please enter your desired URL: ") database.update_account(field_name, new_value, account_uuid) - print('Account successfully updated.') + print("Account successfully updated.") |