From f13404e76fb23395c2d25a551b715ba3cd0f20af Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Sun, 7 Jan 2024 17:05:18 -0500 Subject: [PATCH] Apply consistent code formatting, especially regarding additive and multiplicative operators --- lib/sshync.py | 4 +- lib/sshyp.py | 120 +++++++++++++++++++++++++------------------------- lib/stweak.py | 27 ++++++------ 3 files changed, 75 insertions(+), 76 deletions(-) diff --git a/lib/sshync.py b/lib/sshync.py index 009702c..5c9704d 100644 --- a/lib/sshync.py +++ b/lib/sshync.py @@ -78,8 +78,8 @@ def remote_list_fetch(_user_data): _deletion_database = _remote_data[0].strip().splitlines() _folder_database = _remote_data[1].strip().splitlines() _titles_mods = _remote_data[2].strip().splitlines() - return _deletion_database, _folder_database, _titles_mods[:len(_titles_mods)//2], \ - _titles_mods[len(_titles_mods)//2:] + return _deletion_database, _folder_database, _titles_mods[:len(_titles_mods) // 2], \ + _titles_mods[len(_titles_mods) // 2:] # checks for and acts upon files and folders marked for deletion diff --git a/lib/sshyp.py b/lib/sshyp.py index feedc47..b4df1ce 100755 --- a/lib/sshyp.py +++ b/lib/sshyp.py @@ -31,10 +31,10 @@ def entry_list_gen(_directory=f"{home}/.local/share/sshyp/"): else: _print_string = f"\u001b[38;5;8m{_filename[:-4]}\u001b[0m" # -3 instead of -4 to account for trailing space character - _char_counter += len(_filename)-3 + _char_counter += len(_filename) - 3 if _char_counter >= _width: # reset _char_counter to length of first entry in new line - _char_counter = len(_filename)-3 + _char_counter = len(_filename) - 3 print() print(_print_string + ' ', end='') _color_alternator = _color_alternator * -1 @@ -82,7 +82,7 @@ def string_gen(_complexity, _length): if _complexity == 's': _character_pool = string.ascii_letters + string.digits elif _complexity == 'f': - _character_pool = string.digits + string.ascii_letters + string.punctuation.replace('/', '').replace('\\', '')\ + _character_pool = string.digits + string.ascii_letters + string.punctuation.replace('/', '').replace('\\', '') \ .replace("'", '').replace('"', '').replace('`', '').replace('~', '') else: _character_pool = string.digits + string.ascii_letters + string.punctuation @@ -201,7 +201,7 @@ def whitelist_verify(_port, _username_ssh, _ip, _client_device_id, _identity): from getpass import getpass _quick_unlock_password = getpass(prompt='\nquick-unlock pin: ') _quick_unlock_password_excluded = \ - run(('ssh', '-i', _identity, '-p', _port, f"{_username_ssh}@{_ip}", + run(('ssh', '-i', _identity, '-p', _port, f"{_username_ssh}@{_ip}", f"gpg --pinentry-mode loopback --passphrase '{_quick_unlock_password}' " f"-qd ~/.config/sshyp/excluded.gpg"), stdout=PIPE, text=True).stdout.rstrip() while _i < len(_quick_unlock_password_excluded): @@ -287,20 +287,20 @@ def copy_id_check(_port, _username_ssh, _ip, _client_device_id, _identity, _sshy # prints help text based on argument def print_info(): if arguments[0] in ('version', '-v'): - _blank = '\u001b[38;5;7;48;5;8m\\\u001b[38;5;15;48;5;15m' + 55*' ' + '\u001b[38;5;7;48;5;8m/\u001b[0m' - _border = '\u001b[38;5;7;48;5;8m' + 14*'<>' + '-' + 14*'<>' + '\u001b[0m\n' + _blank = '\u001b[38;5;7;48;5;8m\\\u001b[38;5;15;48;5;15m' + 55 * ' ' + '\u001b[38;5;7;48;5;8m/\u001b[0m' + _border = '\u001b[38;5;7;48;5;8m' + 14 * '<>' + '-' + 14 * '<>' + '\u001b[0m\n' print(f"""\nsshyp is a simple, self-hosted, sftp-synchronized\npassword manager for unix(-like) systems\n -{9*' '}..{15*' '}\u001b[38;5;12m♥♥ \u001b[38;5;9m♥♥\u001b[0m{15*' '}.. -{8*' '}/()\\''.''.{7*' '}\u001b[38;5;12m♥♥♥\u001b[0m♥♥♥♥\u001b[0m{7*' '}.''.''/()\\{3*' '}_) -{5*' '}_.{3*' '}:{7*' '}*{7*' '}\u001b[38;5;9m♥♥♥♥♥\u001b[0m{7*' '}*{7*' '}:{3*' '}<[◎]|_|= - }}-}}-*]{4*' '}`..'..'{9*' '}\u001b[0m♥♥♥\u001b[0m{9*' '}`..'..'{6*' '}| -{4*' '}◎-◎{4*' '}//{3*' '}\\\\{10*' '}\u001b[38;5;9m♥\u001b[0m{10*' '}//{3*' '}\\\\{5*' '}/|\\""") - print(f"{_border}{_blank}\n\u001b[38;5;7;48;5;8m\\\u001b[38;5;15;48;5;15m{18*' '}\u001b[38;5;15;48;5;8msshyp " - f"version 1.5.2\u001b[38;5;15;48;5;15m{18*' '}\u001b[38;5;7;48;5;8m/\u001b[0m") - print(f"\u001b[38;5;7;48;5;8m\\\u001b[38;5;15;48;5;15m{14*' '}\u001b[38;5;15;48;5;8mthe fortified flock" - f" update\u001b[38;5;15;48;5;15m{15*' '}\u001b[38;5;7;48;5;8m/\u001b[0m\n{_blank}") - print(f"\u001b[38;5;7;48;5;8m\\\u001b[38;5;15;48;5;15m{9*' '}\u001b[38;5;15;48;5;8mcopyright 2021-2024 ", - f"randall winkhart\u001b[38;5;15;48;5;15m{9*' '}\u001b[38;5;7;48;5;8m/\u001b[0m") +{9 * ' '}..{15 * ' '}\u001b[38;5;12m♥♥ \u001b[38;5;9m♥♥\u001b[0m{15 * ' '}.. +{8 * ' '}/()\\''.''.{7 * ' '}\u001b[38;5;12m♥♥♥\u001b[0m♥♥♥♥\u001b[0m{7 * ' '}.''.''/()\\{3 * ' '}_) +{5 * ' '}_.{3 * ' '}:{7 * ' '}*{7 * ' '}\u001b[38;5;9m♥♥♥♥♥\u001b[0m{7 * ' '}*{7 * ' '}:{3 * ' '}<[◎]|_|= + }}-}}-*]{4 * ' '}`..'..'{9 * ' '}\u001b[0m♥♥♥\u001b[0m{9 * ' '}`..'..'{6 * ' '}| +{4 * ' '}◎-◎{4 * ' '}//{3 * ' '}\\\\{10 * ' '}\u001b[38;5;9m♥\u001b[0m{10 * ' '}//{3 * ' '}\\\\{5 * ' '}/|\\""") + print(f"{_border}{_blank}\n\u001b[38;5;7;48;5;8m\\\u001b[38;5;15;48;5;15m{18 * ' '}\u001b[38;5;15;48;5;8msshyp " + f"version 1.5.2\u001b[38;5;15;48;5;15m{18 * ' '}\u001b[38;5;7;48;5;8m/\u001b[0m") + print(f"\u001b[38;5;7;48;5;8m\\\u001b[38;5;15;48;5;15m{14 * ' '}\u001b[38;5;15;48;5;8mthe fortified flock" + f" update\u001b[38;5;15;48;5;15m{15 * ' '}\u001b[38;5;7;48;5;8m/\u001b[0m\n{_blank}") + print(f"\u001b[38;5;7;48;5;8m\\\u001b[38;5;15;48;5;15m{9 * ' '}\u001b[38;5;15;48;5;8mcopyright 2021-2024 ", + f"randall winkhart\u001b[38;5;15;48;5;15m{9 * ' '}\u001b[38;5;7;48;5;8m/\u001b[0m") print(f"{_blank}\n{_border}\nsee https://github.com/rwinkhart/sshyp for more information\n") elif arguments[0] == 'license': print('\nThis program is free software: you can redistribute it and/or modify it under the terms of\nversion 3 ' @@ -312,31 +312,31 @@ def print_info(): print(f"""\n\u001b[1musage:\u001b[0m sshyp / add