summaryrefslogtreecommitdiff
path: root/gr-utils/python/modtool/util_functions.py
diff options
context:
space:
mode:
Diffstat (limited to 'gr-utils/python/modtool/util_functions.py')
-rw-r--r--gr-utils/python/modtool/util_functions.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/gr-utils/python/modtool/util_functions.py b/gr-utils/python/modtool/util_functions.py
index 6ba73d82ac..edd98fde8f 100644
--- a/gr-utils/python/modtool/util_functions.py
+++ b/gr-utils/python/modtool/util_functions.py
@@ -1,5 +1,5 @@
#
-# Copyright 2013 Free Software Foundation, Inc.
+# Copyright 2013, 2018 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -143,10 +143,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):
@@ -162,5 +165,5 @@ class SequenceCompleter(object):
readline.set_completer(self.completefunc)
readline.parse_and_bind("tab: complete")
- def __exit__(self):
+ def __exit__(self, exception_type, exception_value, traceback):
readline.set_completer(self._old_completer)