-
Notifications
You must be signed in to change notification settings - Fork 97
/
base.py
34 lines (24 loc) · 929 Bytes
/
base.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# -*- coding: utf-8 -*-
from __future__ import print_function
from blessings import Terminal
class BaseConsoleRender(object):
title_inline = False
def __init__(self, question, theme=None, terminal=None, show_default=False,
*args, **kwargs):
super(BaseConsoleRender, self).__init__(*args, **kwargs)
self.question = question
self.terminal = terminal or Terminal()
self.answers = {}
self.theme = theme
self.show_default = show_default
def get_header(self):
return self.question.message
def get_current_value(self):
return ''
def get_options(self):
return []
def read_input(self):
raise NotImplementedError('Abstract')
def handle_validation_error(self, error):
return '"{e}" is not a valid {q}.'.format(e=error.value,
q=self.question.name)