File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919requirements_path : str = os .path .join (top_dir , "requirements.txt" )
2020venv_orig_requirements_path : str = os .path .join (venv_path , "_requirements.txt" )
2121venv_python_version_path : str = os .path .join (venv_path , "python_version" )
22+ #: Whether this script is run interactively,
23+ #: i.e. whether user input is possible to answer questions.
24+ #: Value is True if interactive (i.e. stdout is attached to a terminal), False otherwise.
25+ isInteractive = hasattr (sys .stdout , "isatty" ) and sys .stdout .isatty ()
2226
2327
24- def askYesNoQuestion (message : str ) -> bool :
28+ def askYesNoQuestion (message : str , default : bool = True ) -> bool :
2529 """
2630 Displays the given message to the user and accepts y or n as input.
2731 Any other input causes the question to be asked again.
28- @returns: True for y and n for False.
32+ If isInteractive is False, the default is always returned.
33+ @returns: True for y and False for n.
2934 """
30- while True :
35+ while isInteractive :
3136 answer = input (
3237 message + " [y/n]: "
3338 )
@@ -37,6 +42,7 @@ def askYesNoQuestion(message: str) -> bool:
3742 return True
3843 else :
3944 continue # ask again
45+ return default
4046
4147
4248def fetchRequirementsSet (path : str ) -> Set [str ]:
You can’t perform that action at this time.
0 commit comments