-
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
-
- def boolean_question(question):
- accept = ["y", "Y", "yes", "Yes", "YES"]
- decline = ["n", "N", "no", "No", "NO"]
- valid_answers = accept + decline
-
- answer = input(question)
- while answer not in valid_answers:
- print("Please enter a valid option.\n")
- answer = input(question)
-
- return True if answer in accept else False
-
- def choose_folder(question):
- folder = input(question)
- while not os.path.isdir(folder):
- print("Please enter a valid path.\n")
- folder = input(question)
- return folder
-
-
- if __name__ == "__main__":
- # Ask questions that are answered by a yes or no and return a boolean
- include_home = boolean_question("Do you want to include home? (y/n): ")
- use_patched_tar = boolean_question("Are you going to use Fedora's patched tar? (y/n): ")
- use_default_folder = boolean_question("Do you want to save in the default folder? (y/n): ")
-
- # Use the previously defined variables
- if use_default_folder:
- default_folder = "/"
- else:
- default_folder = choose_folder("Insert the path where the backup will be created: ")
-
- print("include_home:", include_home)
- print("use_patched_tar:", use_patched_tar)
- print("use_default_folder:", use_default_folder)
- print("default_folder:", default_folder)
-