77
76
cursor at the leftmost position."""
78
77
raise NotImplementedError(self.clear_term)
80
def get_boolean(self, prompt):
81
"""Get a boolean question answered from the user.
83
:param prompt: a message to prompt the user with. Should be a single
84
line without terminating \n.
85
:return: True or False for y/yes or n/no.
87
raise NotImplementedError(self.get_boolean)
90
class CLIUIFactory(UIFactory):
91
"""Common behaviour for command line UI factories."""
94
super(CLIUIFactory, self).__init__()
95
self.stdin = sys.stdin
97
def get_boolean(self, prompt):
99
# FIXME: make a regexp and handle case variations as well.
102
line = self.stdin.readline()
103
if line in ('y\n', 'yes\n'):
105
if line in ('n\n', 'no\n'):
108
def prompt(self, prompt):
109
"""Emit prompt on the CLI."""
112
class SilentUIFactory(CLIUIFactory):
80
class SilentUIFactory(UIFactory):
113
81
"""A UI Factory which never prints anything.
115
83
This is the default UI, if another one is never registered.