Made an empty stings cancel out of the plugin selection.

This commit is contained in:
Jeremy Fincher 2004-02-09 19:01:47 +00:00
parent b63fc24865
commit 53f9c0aa94
2 changed files with 6 additions and 2 deletions

View File

@ -430,7 +430,8 @@ def main():
# until we get example strings again, this will default to false
#showUsage =yn('Would you like the option of seeing usage examples?')
showUsage = False
name = expect('What plugin would you like to look at?', plugins)
name = expect('What plugin would you like to look at?',
plugins, acceptEmpty=True)
while name:
module = loadPlugin(name)
if module is not None:

View File

@ -49,7 +49,8 @@ def output(s, unformatted=True):
print
# doindent is used in yn().
def expect(prompt, possibilities, recursed=False, doindent=True, default=None):
def expect(prompt, possibilities, recursed=False,
doindent=True, default=None, acceptEmpty=False):
"""Prompt the user with prompt, allow them to choose from possibilities.
If possibilities is empty, allow anything.
@ -82,6 +83,8 @@ def expect(prompt, possibilities, recursed=False, doindent=True, default=None):
return s
elif not s and default is not None:
return default
elif not s and acceptEmpty:
return s
else:
return expect(originalPrompt, possibilities, recursed=True,
doindent=doindent, default=default)