3 from colorama
import Fore, Back, init
11 rows, columns = map(int, subprocess.check_output([
'stty',
'size']).split())
16 if line.startswith(
'+'):
17 yield Fore.GREEN + line + Fore.RESET
18 elif line.startswith(
'-'):
19 yield Fore.RED + line + Fore.RESET
20 elif line.startswith(
'^'):
21 yield Fore.BLUE + line + Fore.RESET
28 line =
'+' + (
'-' * (columns - 2)) +
'+' 29 header += getattr(Fore, fore) + getattr(Back, back) + line
30 n = columns - len(s) - 3
31 header +=
'| ' + s +
' ' * n +
'|' 32 header += line + Back.RESET + Fore.RESET
37 return getattr(Fore, fore) + s + Fore.RESET
41 """Ask a yes/no question via raw_input() and return their answer. 43 Based on http://code.activestate.com/recipes/577058/ 45 "question" is a string that is presented to the user. 46 "default" is the presumed answer if the user just hits <Enter>. 47 It must be "yes" (the default), "no" or None (meaning 48 an answer is required of the user). 50 The "answer" return value is True for "yes" or False for "no". 52 valid = {
"yes":
True,
"y":
True,
"ye":
True,
53 "no":
False,
"n":
False}
56 elif default ==
"yes":
61 raise ValueError(
"invalid default answer: '%s'" % default)
64 choice = raw_input(
color_text(question + prompt)).lower()
65 if default
is not None and choice ==
'':
70 print(
"Please respond with 'yes' or 'no' (or 'y' or 'n').")
def color_text(s, fore='YELLOW')
def query_yes_no(question, default="no")
def color_header(s, fore='WHITE', back='BLUE')
def __getattr__(self, name)