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__": if __name__ == "__main__":
try:
silent_sync = 0 silent_sync = 0
# retrieve typed argument # retrieve typed argument
argument_list, argument = argv, '' argument_list, argument = argv, ''
@@ -653,74 +654,42 @@ if __name__ == "__main__":
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n') print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
s_exit(1) s_exit(1)
else: else:
try:
tweak() tweak()
s_exit(0) s_exit(0)
except KeyboardInterrupt:
print('\n')
s_exit(0)
# run function based on argument # run function based on argument
error = 0 # create an error flag to determine if syncing should occur at end error = 0 # create an error flag to determine if syncing should occur at end
if argument.startswith('/'): if argument.startswith('/'):
read_shortcut() read_shortcut()
elif argument == '': elif argument == '':
try:
no_arg() no_arg()
except KeyboardInterrupt: elif argument == 'help' or argument == '--help' or argument == '-h' or argument == 'license' or argument \
print('\n') == 'version' or argument == '-v' or argument == 'add' or argument == 'edit' or argument == 'copy':
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':
print_info() print_info()
elif argument.startswith('add note') or argument.startswith('add -n') or argument.startswith('add password') \ elif argument.startswith('add note') or argument.startswith('add -n') or argument.startswith('add password') \
or argument.startswith('add -p'): or argument.startswith('add -p'):
try:
add_entry() add_entry()
except KeyboardInterrupt:
print('\n')
s_exit(0)
elif argument.startswith('add folder') or argument.startswith('add -f'): elif argument.startswith('add folder') or argument.startswith('add -f'):
try:
add_folder() add_folder()
except KeyboardInterrupt: elif argument.startswith('edit rename') or argument.startswith('edit relocate') or argument.startswith(
print('\n') 'edit -r'):
s_exit(0)
elif argument.startswith('edit rename') or argument.startswith('edit relocate') or argument.startswith('edit -r'):
silent_sync = 1 silent_sync = 1
try:
rename() rename()
except KeyboardInterrupt: elif argument.startswith('edit username') or argument.startswith('edit -u') or argument.startswith(
print('\n') 'edit password') \
s_exit(0) or argument.startswith('edit -p') or argument.startswith('edit url') or argument.startswith(
elif argument.startswith('edit username') or argument.startswith('edit -u') or argument.startswith('edit password')\ 'edit -l') or \
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'): argument.startswith('edit note') or argument.startswith('edit -n'):
try:
edit() edit()
except KeyboardInterrupt:
print('\n')
s_exit(0)
elif argument.startswith('gen'): elif argument.startswith('gen'):
try:
gen() gen()
except KeyboardInterrupt: elif argument.startswith('copy username') or argument.startswith('copy -u') or argument.startswith(
print('\n') 'copy password') \
s_exit(0)
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 -p') or argument.startswith('copy url') or argument.startswith('copy -l') \
or argument.startswith('copy note') or argument.startswith('copy -n'): or argument.startswith('copy note') or argument.startswith('copy -n'):
try:
copy_data() copy_data()
except KeyboardInterrupt:
print('\n')
s_exit(0)
elif argument.startswith('shear') or argument.startswith('-rm'): elif argument.startswith('shear') or argument.startswith('-rm'):
try:
remove_data() remove_data()
except KeyboardInterrupt:
print('\n')
s_exit(0)
elif argument == 'sync' or argument == '-s': elif argument == 'sync' or argument == '-s':
sync() sync()
else: else:
@@ -729,13 +698,17 @@ if __name__ == "__main__":
s_exit(1) s_exit(1)
# sync at end of program if any changes were made # sync at end of program if any changes were made
if argument != '' and argument != 'help' and argument != '--help' and argument != '-h' and argument != 'license' \ if argument != '' and argument != 'help' and argument != '--help' and argument != '-h' and argument != \
and argument != 'add' and argument != 'sync' and argument != 'edit' and not 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 username') and not argument.startswith('copy -u') and not argument\
startswith('copy password') and not argument.startswith('copy -p') 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 url') and not argument.startswith('copy -l') and not argument.startswith('copy note')\
startswith('copy note') and not argument.startswith('copy -n') and argument != 'copy' and argument \ and not argument.startswith('copy -n') and argument != 'copy' and argument != 'version' and argument \
!= 'version' and argument != '-v' and error == 0 and argument.startswith('/') is False: != '-v' and error == 0 and argument.startswith('/') is False:
sync() sync()
s_exit(0) s_exit(0)
except KeyboardInterrupt:
print('\n')
s_exit(0)