1 from __future__
import annotations
9 from whichcraft
import which
21 Check whether an executable exists on PATH.
22 @param name Name of the executable
23 @return True if executable exists, False otherwise
25 return which(name)
is not None
29 """!Write a message to standard output and flush the buffer"""
36 Ask a yes/no question via input() and return their answer.
37 @param question The question that is presented to the user.
38 @param default The presumed answer if the user just hits <Enter>.
39 It must be "yes" (the default), "no" or None (meaning
40 an answer is required of the user).
41 @return True if the answer is "yes", False otherwise
43 valid = {
"yes":
True,
"y":
True,
"ye":
True,
"no":
False,
"n":
False}
46 elif default ==
"yes":
51 raise ValueError(f
"invalid default answer: '{default}'")
55 choice = input().lower()
56 if default
is not None and choice ==
"":
60 print(
"Please respond with 'yes' or 'no' " "(or 'y' or 'n').")
64 for i, (name, _)
in enumerate(options):
65 print(f
"{i+1}) {name}")
68 input_raw = input(f
"Your selection [{default}]: ")
70 selected_nr = default - 1
72 selected_nr = int(input_raw) - 1
73 if 0 <= selected_nr < len(options):
74 _, selected = options[selected_nr]
76 print(f
"Please select a valid option")
80 with open(file_path,
"r")
as stream:
82 return yaml.safe_load(stream)
83 except yaml.YAMLError
as exc: