Reduced lines used for KeyboardInterrupt exception

This commit is contained in:
2022-05-22 23:43:34 -04:00
parent 7aa9ea63e2
commit 13d466bb21
+22 -49
View File
@@ -619,6 +619,7 @@ def remove_data(): # deletes an entry from the server and flags it for local de
if __name__ == "__main__":
try:
silent_sync = 0
# retrieve typed argument
argument_list, argument = argv, ''
@@ -653,74 +654,42 @@ if __name__ == "__main__":
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
s_exit(1)
else:
try:
tweak()
s_exit(0)
except KeyboardInterrupt:
print('\n')
s_exit(0)
# run function based on argument
error = 0 # create an error flag to determine if syncing should occur at end
if argument.startswith('/'):
read_shortcut()
elif argument == '':
try:
no_arg()
except KeyboardInterrupt:
print('\n')
s_exit(0)
elif argument == 'help' or argument == '--help' or argument == '-h' or argument == 'license' or \
argument == 'version' or argument == '-v' or argument == 'add' or argument == 'edit' or argument == 'copy':
elif argument == 'help' or argument == '--help' or argument == '-h' or argument == 'license' or argument \
== 'version' or argument == '-v' or argument == 'add' or argument == 'edit' or argument == 'copy':
print_info()
elif argument.startswith('add note') or argument.startswith('add -n') or argument.startswith('add password') \
or argument.startswith('add -p'):
try:
add_entry()
except KeyboardInterrupt:
print('\n')
s_exit(0)
elif argument.startswith('add folder') or argument.startswith('add -f'):
try:
add_folder()
except KeyboardInterrupt:
print('\n')
s_exit(0)
elif argument.startswith('edit rename') or argument.startswith('edit relocate') or argument.startswith('edit -r'):
elif argument.startswith('edit rename') or argument.startswith('edit relocate') or argument.startswith(
'edit -r'):
silent_sync = 1
try:
rename()
except KeyboardInterrupt:
print('\n')
s_exit(0)
elif argument.startswith('edit username') or argument.startswith('edit -u') or argument.startswith('edit password')\
or argument.startswith('edit -p') or argument.startswith('edit url') or argument.startswith('edit -l') or \
elif argument.startswith('edit username') or argument.startswith('edit -u') or argument.startswith(
'edit password') \
or argument.startswith('edit -p') or argument.startswith('edit url') or argument.startswith(
'edit -l') or \
argument.startswith('edit note') or argument.startswith('edit -n'):
try:
edit()
except KeyboardInterrupt:
print('\n')
s_exit(0)
elif argument.startswith('gen'):
try:
gen()
except KeyboardInterrupt:
print('\n')
s_exit(0)
elif argument.startswith('copy username') or argument.startswith('copy -u') or argument.startswith('copy password')\
elif argument.startswith('copy username') or argument.startswith('copy -u') or argument.startswith(
'copy password') \
or argument.startswith('copy -p') or argument.startswith('copy url') or argument.startswith('copy -l') \
or argument.startswith('copy note') or argument.startswith('copy -n'):
try:
copy_data()
except KeyboardInterrupt:
print('\n')
s_exit(0)
elif argument.startswith('shear') or argument.startswith('-rm'):
try:
remove_data()
except KeyboardInterrupt:
print('\n')
s_exit(0)
elif argument == 'sync' or argument == '-s':
sync()
else:
@@ -729,13 +698,17 @@ if __name__ == "__main__":
s_exit(1)
# sync at end of program if any changes were made
if argument != '' and argument != 'help' and argument != '--help' and argument != '-h' and argument != 'license' \
and argument != 'add' and argument != 'sync' and argument != 'edit' and not argument. \
startswith('copy username') and not argument.startswith('copy -u') and not argument. \
startswith('copy password') and not argument.startswith('copy -p') and not argument. \
startswith('copy url') and not argument.startswith('copy -l') and not argument. \
startswith('copy note') and not argument.startswith('copy -n') and argument != 'copy' and argument \
!= 'version' and argument != '-v' and error == 0 and argument.startswith('/') is False:
if argument != '' and argument != 'help' and argument != '--help' and argument != '-h' and argument != \
'license' and argument != 'add' and argument != 'sync' and argument != 'edit' and not argument\
.startswith('copy username') and not argument.startswith('copy -u') and not argument\
.startswith('copy password') and not argument.startswith('copy -p') and not argument\
.startswith('copy url') and not argument.startswith('copy -l') and not argument.startswith('copy note')\
and not argument.startswith('copy -n') and argument != 'copy' and argument != 'version' and argument \
!= '-v' and error == 0 and argument.startswith('/') is False:
sync()
s_exit(0)
except KeyboardInterrupt:
print('\n')
s_exit(0)