mirror of
https://github.com/certbot/certbot.git
synced 2026-05-28 04:34:11 -04:00
Address @schoen's review comments
This commit is contained in:
parent
0e4d9b00cd
commit
f520ca2556
3 changed files with 16 additions and 12 deletions
|
|
@ -1,4 +1,4 @@
|
|||
"""Provides tab completion when prompting users for a path."""
|
||||
"""Provides Tab completion when prompting users for a path."""
|
||||
import glob
|
||||
# readline module is not available on all systems
|
||||
try:
|
||||
|
|
@ -8,9 +8,9 @@ except ImportError:
|
|||
|
||||
|
||||
class Completer(object):
|
||||
"""Provides tab completion when prompting users for a path.
|
||||
"""Provides Tab completion when prompting users for a path.
|
||||
|
||||
This class is meant to be used with readline to provide tab
|
||||
This class is meant to be used with readline to provide Tab
|
||||
completion for users entering paths. The complete method can be
|
||||
passed to readline.set_completer directly, however, this function
|
||||
works best as a context manager. For example:
|
||||
|
|
@ -18,14 +18,14 @@ class Completer(object):
|
|||
with Completer():
|
||||
raw_input()
|
||||
|
||||
In this example, tab completion will be available during the call to
|
||||
In this example, Tab completion will be available during the call to
|
||||
raw_input above, however, readline will be restored to its previous
|
||||
state when exiting the body of the with statement.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self._completer = self._delims = self._iter = None
|
||||
self._iter = self._original_completer = self._original_delims = None
|
||||
|
||||
def complete(self, text, state):
|
||||
"""Provides path completion for use with readline.
|
||||
|
|
@ -43,8 +43,8 @@ class Completer(object):
|
|||
return next(self._iter, None)
|
||||
|
||||
def __enter__(self):
|
||||
self._completer = readline.get_completer()
|
||||
self._delims = readline.get_completer_delims()
|
||||
self._original_completer = readline.get_completer()
|
||||
self._original_delims = readline.get_completer_delims()
|
||||
|
||||
readline.set_completer(self.complete)
|
||||
readline.set_completer_delims(' \t\n;')
|
||||
|
|
@ -57,5 +57,5 @@ class Completer(object):
|
|||
readline.parse_and_bind('tab: complete')
|
||||
|
||||
def __exit__(self, unused_type, unused_value, unused_traceback):
|
||||
readline.set_completer_delims(self._delims)
|
||||
readline.set_completer(self._completer)
|
||||
readline.set_completer_delims(self._original_delims)
|
||||
readline.set_completer(self._original_completer)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ WIDTH = 72
|
|||
HEIGHT = 20
|
||||
|
||||
DSELECT_HELP = (
|
||||
"Use the arrow keys or tab to move between window elements. Space can be "
|
||||
"Use the arrow keys or Tab to move between window elements. Space can be "
|
||||
"used to complete the input path with the selected element in the "
|
||||
"directory window. Pressing enter will select the currently highlighted "
|
||||
"button.")
|
||||
|
|
@ -559,7 +559,9 @@ class NoninteractiveDisplay(object):
|
|||
"""Simulate prompting the user for a directory.
|
||||
|
||||
This function returns default if it is not ``None``, otherwise,
|
||||
an exception is raised.
|
||||
an exception is raised explaining the problem. If cli_flag is
|
||||
not ``None``, the error message will include the flag that can
|
||||
be used to set this value with the CLI.
|
||||
|
||||
:param str message: prompt to give the user
|
||||
:param default: default value to return (if one exists)
|
||||
|
|
|
|||
|
|
@ -449,7 +449,9 @@ class IDisplay(zope.interface.Interface):
|
|||
:param str message: prompt to give the user
|
||||
:param default: the default value to return, if one exists, when
|
||||
using the NoninteractiveDisplay
|
||||
:param str cli_flag: option used to set this value with the CLI
|
||||
:param str cli_flag: option used to set this value with the CLI,
|
||||
if one exists, to be included in error messages given by
|
||||
NoninteractiveDisplay
|
||||
|
||||
:returns: tuple of the form (`code`, `string`) where
|
||||
`code` - int display exit code
|
||||
|
|
|
|||
Loading…
Reference in a new issue