Fixed inconsistent spacing between items in entry reader

Former-commit-id: 268667df04d1bd7f22733475dc7079c698bba46a
Former-commit-id: 160b24686e81f304cb8426aaf043c239c2ab967f
This commit is contained in:
2023-05-13 22:39:48 -04:00
parent 6288c45ba0
commit 99379ec1b1
+12 -14
View File
@@ -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