prompt.py 523 B

1234567891011121314151617181920
  1. """
  2. Prompting CLI utilities
  3. @author: olivier.massot, 05-2020
  4. """
  5. def ask_confirmation(msg):
  6. """ Ask confirmation to the user with the given message.
  7. Returns True if the user confirmed
  8. """
  9. msg += "\nWould you like to continue? (yes/no)"
  10. while 1:
  11. answer = input(msg)
  12. if answer in ('oui', 'yes', 'y', 'o'):
  13. return True
  14. elif answer in ('non', 'no', 'n'):
  15. return False
  16. else:
  17. msg = "The answer could'nt be understood. Continue? (yes/no)"