mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-29 22:22:33 +01:00
Gave output an option fd.
This commit is contained in:
parent
920b4cfd18
commit
c63c7a1764
@ -42,14 +42,14 @@ import supybot.utils as utils
|
|||||||
|
|
||||||
useBold = False
|
useBold = False
|
||||||
|
|
||||||
def output(s, unformatted=True):
|
def output(s, unformatted=True, fd=sys.stdout):
|
||||||
if unformatted:
|
if unformatted:
|
||||||
s = textwrap.fill(utils.normalizeWhitespace(s), width=65)
|
s = textwrap.fill(utils.normalizeWhitespace(s), width=65)
|
||||||
print s
|
print >>fd, s
|
||||||
print
|
print >>fd
|
||||||
|
|
||||||
def expect(prompt, possibilities, recursed=False, default=None,
|
def expect(prompt, possibilities, recursed=False, default=None,
|
||||||
acceptEmpty=False):
|
acceptEmpty=False, fd=sys.stdout):
|
||||||
"""Prompt the user with prompt, allow them to choose from possibilities.
|
"""Prompt the user with prompt, allow them to choose from possibilities.
|
||||||
|
|
||||||
If possibilities is empty, allow anything.
|
If possibilities is empty, allow anything.
|
||||||
@ -72,12 +72,12 @@ def expect(prompt, possibilities, recursed=False, default=None,
|
|||||||
prompt = prompt.replace('/ ', '/')
|
prompt = prompt.replace('/ ', '/')
|
||||||
prompt = prompt.strip() + ' '
|
prompt = prompt.strip() + ' '
|
||||||
if useBold:
|
if useBold:
|
||||||
print ansi.BOLD,
|
print >>fd, ansi.BOLD,
|
||||||
s = raw_input(prompt)
|
s = raw_input(prompt)
|
||||||
if useBold:
|
if useBold:
|
||||||
print ansi.RESET
|
print >>fd, ansi.RESET
|
||||||
s = s.strip()
|
s = s.strip()
|
||||||
print
|
print >>fd
|
||||||
if possibilities:
|
if possibilities:
|
||||||
if s in possibilities:
|
if s in possibilities:
|
||||||
return s
|
return s
|
||||||
|
Loading…
Reference in New Issue
Block a user