summaryrefslogtreecommitdiff
path: root/gr-utils/python/modtool
diff options
context:
space:
mode:
Diffstat (limited to 'gr-utils/python/modtool')
-rw-r--r--gr-utils/python/modtool/cmakefile_editor.py2
-rw-r--r--gr-utils/python/modtool/gr-newmod/cmake/Modules/CMakeParseArgumentsCopy.cmake2
-rw-r--r--gr-utils/python/modtool/gr-newmod/cmake/Modules/GrMiscUtils.cmake4
-rw-r--r--gr-utils/python/modtool/gr-newmod/cmake/Modules/GrSwig.cmake4
-rw-r--r--gr-utils/python/modtool/gr-newmod/docs/doxygen/Doxyfile.in2
-rw-r--r--gr-utils/python/modtool/gr-newmod/docs/doxygen/Doxyfile.swig_doc.in2
-rw-r--r--gr-utils/python/modtool/modtool_add.py21
-rw-r--r--gr-utils/python/modtool/modtool_rename.py2
-rw-r--r--gr-utils/python/modtool/modtool_rm.py5
-rw-r--r--gr-utils/python/modtool/scm.py2
-rw-r--r--gr-utils/python/modtool/util_functions.py27
11 files changed, 52 insertions, 21 deletions
diff --git a/gr-utils/python/modtool/cmakefile_editor.py b/gr-utils/python/modtool/cmakefile_editor.py
index eee555476f..1b644287f9 100644
--- a/gr-utils/python/modtool/cmakefile_editor.py
+++ b/gr-utils/python/modtool/cmakefile_editor.py
@@ -53,7 +53,7 @@ class CMakeFileEditor(object):
Then run:
>>> C.remove_value('list', 'file.cc', 'SOURCES')
- Returns the number of occurences of entry in the current file
+ Returns the number of occurrences of entry in the current file
that were removed.
"""
# In the case of the example above, these are cases we need to catch:
diff --git a/gr-utils/python/modtool/gr-newmod/cmake/Modules/CMakeParseArgumentsCopy.cmake b/gr-utils/python/modtool/gr-newmod/cmake/Modules/CMakeParseArgumentsCopy.cmake
index 7ce4c49ae5..66016cb2ff 100644
--- a/gr-utils/python/modtool/gr-newmod/cmake/Modules/CMakeParseArgumentsCopy.cmake
+++ b/gr-utils/python/modtool/gr-newmod/cmake/Modules/CMakeParseArgumentsCopy.cmake
@@ -58,7 +58,7 @@
# the new option.
# E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in
# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would
-# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor.
+# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefore.
#=============================================================================
# Copyright 2010 Alexander Neundorf <neundorf@kde.org>
diff --git a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrMiscUtils.cmake b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrMiscUtils.cmake
index c65a8ca725..cc8e7c17dc 100644
--- a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrMiscUtils.cmake
+++ b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrMiscUtils.cmake
@@ -186,7 +186,7 @@ endfunction(GR_LIBRARY_FOO)
# GR_GEN_TARGET_DEPS(unique_name target_deps <target1> <target2> ...)
# ADD_CUSTOM_COMMAND(<the usual args> ${target_deps})
#
-# Custom command cant depend on targets, but can depend on executables,
+# Custom command can't depend on targets, but can depend on executables,
# and executables can depend on targets. So this is the process:
########################################################################
function(GR_GEN_TARGET_DEPS name var)
@@ -205,7 +205,7 @@ function(GR_GEN_TARGET_DEPS name var)
endif(ARGN)
if(CMAKE_CROSSCOMPILING)
- set(${var} "DEPENDS;${name}" PARENT_SCOPE) #cant call command when cross
+ set(${var} "DEPENDS;${name}" PARENT_SCOPE) #can't call command when cross
else()
set(${var} "DEPENDS;${name};COMMAND;${name}" PARENT_SCOPE)
endif()
diff --git a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrSwig.cmake b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrSwig.cmake
index 2c163cac01..bce51b23dd 100644
--- a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrSwig.cmake
+++ b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrSwig.cmake
@@ -35,7 +35,7 @@ include(GrPython)
function(GR_SWIG_MAKE_DOCS output_file)
if(ENABLE_DOXYGEN)
- #setup the input files variable list, quote formated
+ #setup the input files variable list, quote formatted
set(input_files)
unset(INPUT_PATHS)
foreach(input_path ${ARGN})
@@ -242,7 +242,7 @@ def get_swig_deps(file_path, level):
inc_path = os.path.join(inc_dir, inc_file)
if not os.path.exists(inc_path): continue
deps.extend(get_swig_deps(inc_path, level-1))
- break #found, we dont search in lower prio inc dirs
+ break #found, we don't search in lower prio inc dirs
return deps
if __name__ == '__main__':
diff --git a/gr-utils/python/modtool/gr-newmod/docs/doxygen/Doxyfile.in b/gr-utils/python/modtool/gr-newmod/docs/doxygen/Doxyfile.in
index ef07c13205..da8cb6ac38 100644
--- a/gr-utils/python/modtool/gr-newmod/docs/doxygen/Doxyfile.in
+++ b/gr-utils/python/modtool/gr-newmod/docs/doxygen/Doxyfile.in
@@ -945,7 +945,7 @@ HTML_STYLESHEET =
# user-defined cascading style sheet that is included after the standard
# style sheets created by doxygen. Using this option one can overrule
# certain style aspects. This is preferred over using HTML_STYLESHEET
-# since it does not replace the standard style sheet and is therefor more
+# since it does not replace the standard style sheet and is therefore more
# robust against future updates. Doxygen will copy the style sheet file to
# the output directory.
diff --git a/gr-utils/python/modtool/gr-newmod/docs/doxygen/Doxyfile.swig_doc.in b/gr-utils/python/modtool/gr-newmod/docs/doxygen/Doxyfile.swig_doc.in
index 19e17dc925..7470475c2c 100644
--- a/gr-utils/python/modtool/gr-newmod/docs/doxygen/Doxyfile.swig_doc.in
+++ b/gr-utils/python/modtool/gr-newmod/docs/doxygen/Doxyfile.swig_doc.in
@@ -913,7 +913,7 @@ HTML_STYLESHEET =
# user-defined cascading style sheet that is included after the standard
# style sheets created by doxygen. Using this option one can overrule
# certain style aspects. This is preferred over using HTML_STYLESHEET
-# since it does not replace the standard style sheet and is therefor more
+# since it does not replace the standard style sheet and is therefore more
# robust against future updates. Doxygen will copy the style sheet file to
# the output directory.
diff --git a/gr-utils/python/modtool/modtool_add.py b/gr-utils/python/modtool/modtool_add.py
index 8c5eed29ec..acc0385ac4 100644
--- a/gr-utils/python/modtool/modtool_add.py
+++ b/gr-utils/python/modtool/modtool_add.py
@@ -27,7 +27,7 @@ from __future__ import unicode_literals
import os
import re
-from .util_functions import append_re_line_sequence, ask_yes_no
+from .util_functions import append_re_line_sequence, ask_yes_no, SequenceCompleter
from .cmakefile_editor import CMakeFileEditor
from .modtool_base import ModTool, ModToolException
from .templates import Templates
@@ -73,17 +73,21 @@ class ModToolAdd(ModTool):
self._info['blocktype'] = options.block_type
if self._info['blocktype'] is None:
- # Print(list out of blocktypes to user for reference)
+ # Print list out of blocktypes to user for reference
print(str(self._block_types))
- while self._info['blocktype'] not in self._block_types:
- self._info['blocktype'] = input("Enter block type: ")
- if self._info['blocktype'] not in self._block_types:
- print('Must be one of ' + str(self._block_types))
+ with SequenceCompleter(sorted(self._block_types)):
+ while self._info['blocktype'] not in self._block_types:
+ self._info['blocktype'] = input("Enter block type: ")
+ if self._info['blocktype'] not in self._block_types:
+ print('Must be one of ' + str(self._block_types))
+
# Allow user to specify language interactively if not set
self._info['lang'] = options.lang
if self._info['lang'] is None:
- while self._info['lang'] not in ['c++', 'cpp', 'python']:
- self._info['lang'] = input("Language (python/cpp): ")
+ language_candidates = ('c++', 'cpp', 'python')
+ with SequenceCompleter(language_candidates):
+ while self._info['lang'] not in language_candidates:
+ self._info['lang'] = input("Language (python/cpp): ")
if self._info['lang'] == 'c++':
self._info['lang'] = 'cpp'
@@ -315,4 +319,3 @@ class ModToolAdd(ModTool):
ed.append_value('install', fname_grc, to_ignore_end='DESTINATION[^()]+')
ed.write()
self.scm.mark_files_updated((self._file['cmgrc'],))
-
diff --git a/gr-utils/python/modtool/modtool_rename.py b/gr-utils/python/modtool/modtool_rename.py
index c2229f28fb..b9112fb8c4 100644
--- a/gr-utils/python/modtool/modtool_rename.py
+++ b/gr-utils/python/modtool/modtool_rename.py
@@ -186,7 +186,7 @@ class ModToolRename(ModTool):
if not os.path.isfile(filename):
return False
else:
- print("In '%s' renaming occurences of '%s' to '%s'" % (filename, old, new))
+ print("In '%s' renaming occurrences of '%s' to '%s'" % (filename, old, new))
cfile = open(filename).read()
(cfile, nsubs) = re.subn(old, new, cfile)
diff --git a/gr-utils/python/modtool/modtool_rm.py b/gr-utils/python/modtool/modtool_rm.py
index dffd5c2e45..b503fa2bf3 100644
--- a/gr-utils/python/modtool/modtool_rm.py
+++ b/gr-utils/python/modtool/modtool_rm.py
@@ -29,7 +29,7 @@ import re
import sys
import glob
-from .util_functions import remove_pattern_from_file
+from .util_functions import remove_pattern_from_file, SequenceCompleter
from .modtool_base import ModTool
from .cmakefile_editor import CMakeFileEditor
@@ -52,7 +52,8 @@ class ModToolRemove(ModTool):
if options.blockname is not None:
self._info['pattern'] = options.blockname
else:
- self._info['pattern'] = input('Which blocks do you want to delete? (Regex): ')
+ with SequenceCompleter():
+ self._info['pattern'] = input('Which blocks do you want to delete? (Regex): ')
if len(self._info['pattern']) == 0:
self._info['pattern'] = '.'
diff --git a/gr-utils/python/modtool/scm.py b/gr-utils/python/modtool/scm.py
index f219cc3aaa..5e80e24994 100644
--- a/gr-utils/python/modtool/scm.py
+++ b/gr-utils/python/modtool/scm.py
@@ -208,7 +208,7 @@ class SCMRepoFactory(object):
return SCMRepository(self.path_to_repo)
def make_empty_scm_manager(self, scm_type='git'):
- """ Returns a valid, usable object of type SCMRepository for an unitialized dir. """
+ """ Returns a valid, usable object of type SCMRepository for an uninitialized dir. """
if self.options.scm_mode == 'no':
return SCMRepository(self.path_to_repo)
for glbl in list(globals().values()):
diff --git a/gr-utils/python/modtool/util_functions.py b/gr-utils/python/modtool/util_functions.py
index bdf1d84164..6ba73d82ac 100644
--- a/gr-utils/python/modtool/util_functions.py
+++ b/gr-utils/python/modtool/util_functions.py
@@ -24,6 +24,7 @@ from __future__ import unicode_literals
import re
import sys
+import readline
# None of these must depend on other modtool stuff!
@@ -137,3 +138,29 @@ def ask_yes_no(question, default):
return default
else:
return not default
+
+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)
+ """
+
+ def __init__(self, sequence):
+ self._seq = sequence
+ self._tmp_matches = []
+
+ def completefunc(self, text, state):
+ if not text and state < len(self._seq):
+ return self._seq[state]
+ if not state:
+ self._tmp_matches = filter(lambda candidate: candidate.startswith(text), self._seq)
+ if state < len(self._tmp_matches):
+ return self._tmp_matches[state]
+
+ def __enter__(self):
+ self._old_completer = readline.get_completer()
+ readline.set_completer(self.completefunc)
+ readline.parse_and_bind("tab: complete")
+
+ def __exit__(self):
+ readline.set_completer(self._old_completer)