76
77
cursor at the leftmost position."""
77
78
raise NotImplementedError(self.clear_term)
80
class SilentUIFactory(UIFactory):
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):
81
113
"""A UI Factory which never prints anything.
83
115
This is the default UI, if another one is never registered.