spacepaste

  1.  
  2. #!/usr/bin/env python3
  3. # -*- coding: utf-8 -*-
  4. def boolean_question(question):
  5. accept = ["y", "Y", "yes", "Yes", "YES"]
  6. decline = ["n", "N", "no", "No", "NO"]
  7. valid_answers = accept + decline
  8. answer = input(question)
  9. while answer not in valid_answers:
  10. print("Please enter a valid option.\n")
  11. answer = input(question)
  12. return True if answer in accept else False
  13. def choose_folder(question):
  14. folder = input(question)
  15. while not os.path.isdir(folder):
  16. print("Please enter a valid path.\n")
  17. folder = input(question)
  18. return folder
  19. if __name__ == "__main__":
  20. # Ask questions that are answered by a yes or no and return a boolean
  21. include_home = boolean_question("Do you want to include home? (y/n): ")
  22. use_patched_tar = boolean_question("Are you going to use Fedora's patched tar? (y/n): ")
  23. use_default_folder = boolean_question("Do you want to save in the default folder? (y/n): ")
  24. # Use the previously defined variables
  25. if use_default_folder:
  26. default_folder = "/"
  27. else:
  28. default_folder = choose_folder("Insert the path where the backup will be created: ")
  29. print("include_home:", include_home)
  30. print("use_patched_tar:", use_patched_tar)
  31. print("use_default_folder:", use_default_folder)
  32. print("default_folder:", default_folder)
  33.