From 99379ec1b193dd74f953bee0a28f2c3770845b38 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Sat, 13 May 2023 22:39:48 -0400 Subject: [PATCH] Fixed inconsistent spacing between items in entry reader Former-commit-id: 268667df04d1bd7f22733475dc7079c698bba46a Former-commit-id: 160b24686e81f304cb8426aaf043c239c2ab967f --- lib/sshyp.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/sshyp.py b/lib/sshyp.py index a97507b..f100f69 100755 --- a/lib/sshyp.py +++ b/lib/sshyp.py @@ -46,25 +46,25 @@ def entry_list_gen(_directory=f"{home}/.local/share/sshyp/"): # displays the contents of an entry in a readable format def entry_reader(_decrypted_entry): - _entry_lines, _notes_flag = open(_decrypted_entry, 'r').readlines(), 0 + _entry_lines, _notes_flag = [line.strip() for line in open(_decrypted_entry, 'r').readlines()], 0 if pass_show: _entry_password = f'\u001b[38;5;10m{_entry_lines[0]}\u001b[0m' else: - _entry_password = f'\u001b[38;5;3mend command in "--show" or "-s" to view\u001b[0m\n' + _entry_password = f'\u001b[38;5;3mend command in "--show" or "-s" to view\u001b[0m' print() for _num in range(len(_entry_lines)): try: - if _num == 0 and _entry_lines[1] != '\n': - print(f"\u001b[38;5;15;48;5;238musername:\u001b[0m\n{_entry_lines[1]}") - elif _num == 1 and _entry_lines[0] != '\n': - print(f"\u001b[38;5;15;48;5;238mpassword:\u001b[0m\n{_entry_password}") - elif _num == 2 and _entry_lines[2] != '\n': - print(f"\u001b[38;5;15;48;5;238murl:\u001b[0m\n{_entry_lines[_num]}") - elif _num >= 3 and _entry_lines[_num] != '\n' and _notes_flag != 1: + if _num == 0 and _entry_lines[1] != '': + print(f"\u001b[38;5;15;48;5;238musername:\u001b[0m\n{_entry_lines[1]}\n") + elif _num == 1 and _entry_lines[0] != '': + print(f"\u001b[38;5;15;48;5;238mpassword:\u001b[0m\n{_entry_password}\n") + elif _num == 2 and _entry_lines[2] != '': + print(f"\u001b[38;5;15;48;5;238murl:\u001b[0m\n{_entry_lines[_num]}\n") + elif _num >= 3 and _entry_lines[_num] != '' and _notes_flag != 1: _notes_flag = 1 - print('\u001b[38;5;15;48;5;238mnotes:\u001b[0m\n' + _entry_lines[_num].strip('\n')) + print('\u001b[38;5;15;48;5;238mnotes:\u001b[0m\n' + _entry_lines[_num]) elif _num >= 3 and _notes_flag == 1: - print(_entry_lines[_num].strip('\n')) + print(_entry_lines[_num]) if _notes_flag == 1: try: _line_test = _entry_lines[_num + 1] @@ -72,9 +72,7 @@ def entry_reader(_decrypted_entry): print() except IndexError: if _num == 0: - print(f"\u001b[38;5;15;48;5;238mpassword:\u001b[0m\n{_entry_password}") - if pass_show: - print() + print(f"\u001b[38;5;15;48;5;238mpassword:\u001b[0m\n{_entry_password}\n") # generates and returns a random string based on input