diff options
author | Marcus Müller <marcus.mueller@ettus.com> | 2018-02-09 00:31:23 +0100 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-02-08 16:04:19 -0800 |
commit | f783dd54a2a81bbd7a03b17e26a5563199c52015 (patch) | |
tree | 0f62380640aaea1debc85367c8da19a8c0f62f3d | |
parent | b6caf24cd5173d42d8b9c34579e42fc7a5936f37 (diff) |
modtool: SequenceCompleter has default [] sequence
Fixes #1602, where SequenceCompleter was called from `gr_modtool rm`
without any argument.
Note that the longer-term goal is still to amend the `rm` statement's
code to prepare a good list of candidates instead of reducing the usage
of SequenceCompleter to just enabling readline editing capabilities.
-rw-r--r-- | gr-utils/python/modtool/util_functions.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/gr-utils/python/modtool/util_functions.py b/gr-utils/python/modtool/util_functions.py index b20970175c..9a949c8031 100644 --- a/gr-utils/python/modtool/util_functions.py +++ b/gr-utils/python/modtool/util_functions.py @@ -150,10 +150,13 @@ class SequenceCompleter(object): """ A simple completer function wrapper to be used with readline, e.g. option_iterable = ("search", "seek", "destroy") readline.set_completer(SequenceCompleter(option_iterable).completefunc) + + Typical usage is with the `with` statement. Restores the previous completer + at exit, thus nestable. """ - def __init__(self, sequence): - self._seq = sequence + def __init__(self, sequence=None): + self._seq = sequence or [] self._tmp_matches = [] def completefunc(self, text, state): |