Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def copy_to_clipboard(generated):
global copied
selection = safe_input('Which password would you like to copy? [1/2/3] ').strip()
if selection in ['1', '2', '3']:
password = generated[int(selection) - 1]
else:
print(color('Invalid option. Pick either 1, 2 or 3.\n', Fore.RED))
return copy_to_clipboard(generated)
try:
pyperclip.copy(password)
copied = True
print('\nCopied!\n')
except pyperclip.exceptions.PyperclipException:
print(color('Could not copy! If you\'re using linux, make sure xclip is installed.\n', Fore.RED))
def copy_to_clipboard(self, data):
try:
pyperclip.copy(data)
except pyperclip.exceptions.PyperclipException:
self._ui.notify_error(errors.UnmessageError(
title='Clipboard error',
message='A copy/paste mechanism for your system could not be '
'found'))