6 sys
.exit("Can't find conf module.")
12 def __init__(self
, stdout
=None, stdin
=None):
13 """Set stdout and stdin"""
15 self
.stdout
= sys
.stdout
19 self
.stdin
= sys
.stdin
23 def __call__(self
, message
, color
=None, newline
=True, *ignore
):
24 """Show message on stdout
26 message - message that would be shown
27 color - opional color of the message
28 newline - end with newline?
31 self
.show(message
, newline
)
33 self
.color(message
, color
, newline
)
36 def show(self
, message
="", newline
=True, *ignore
):
37 """Default message printer"""
39 self
.stdout
.write(message
+ "\n")
41 self
.stdout
.write(message
)
43 def read(self
, message
=""):
45 self
.show(message
+ " ", newline
=False)
46 return self
.stdin
.readline()
48 def ask(self
, question
, color
=None, answer
=" [Y/n]"):
50 self
.color(question
+ answer
, color
, False)
51 a
= self
.stdin
.readline()
58 def color(self
, msg
, color
=None, newline
=False):
59 """Print message with colors
60 By default it doesn't end with new line character.
64 self
.show(conf
.color
[color
] + msg
+ conf
.color
["none"], newline
)