3 from colorama
import Fore, Back, init
14 if line.startswith(
'+'):
15 yield Fore.GREEN + line + Fore.RESET
16 elif line.startswith(
'-'):
17 yield Fore.RED + line + Fore.RESET
18 elif line.startswith(
'^'):
19 yield Fore.BLUE + line + Fore.RESET
30 COLUMNS = list(map(int, subprocess.check_output([
'stty',
'size']).split()))[1]
32 line =
'+' + (
'-' * (COLUMNS - 2)) +
'+' 33 header += getattr(Fore, fore) + getattr(Back, back) + line
34 n = COLUMNS - len(s) - 3
35 header +=
'| ' + s +
' ' * n +
'|' 36 header += line + Back.RESET + Fore.RESET
41 return getattr(Fore, fore) + s + Fore.RESET
52 """Ask a yes/no question via my_input() and return their answer. 54 Based on http://code.activestate.com/recipes/577058/ 56 'question' is a string that is presented to the user. 57 'default' is the presumed answer if the user just hits <Enter>. 58 It must be 'yes' (the default), 'no' or None (meaning 59 an answer is required of the user). 61 The 'answer' return value is True for 'yes' or False for 'no'. 63 valid = {
'yes':
True,
'y':
True,
'ye':
True,
64 'no':
False,
'n':
False}
67 elif default ==
'yes':
72 raise ValueError(
"invalid default answer: '%s'" % default)
76 if default
is not None and choice ==
'':
81 print(
"Please respond with 'yes' or 'no' (or 'y' or 'n').")
def query_yes_no(question, default='no')
def color_text(s, fore='YELLOW')
def color_header(s, fore='WHITE', back='BLUE')
def __getattr__(self, name)