diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-02-03 16:58:15 +0100 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-02-03 16:58:43 +0100 |
commit | db7e26bc73fd71bc88249131f57f7edef308fa63 (patch) | |
tree | d084ad2615012d53c50a230821761349eb978d56 /gr-utils/python | |
parent | 3c63f7334d6de70d655aa97fcccbfb950645f4d4 (diff) | |
parent | a35e10870bbb9a71b3ab66b1dc58135e08c9543e (diff) |
Merge branch 'master' into next
Diffstat (limited to 'gr-utils/python')
11 files changed, 51 insertions, 19 deletions
diff --git a/gr-utils/python/modtool/cmakefile_editor.py b/gr-utils/python/modtool/cmakefile_editor.py index d57c650c5e..4148ad1960 100644 --- a/gr-utils/python/modtool/cmakefile_editor.py +++ b/gr-utils/python/modtool/cmakefile_editor.py @@ -50,7 +50,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 319581c05e..50d817aa9e 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 58699a7be0..543562a287 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 b7d33c6113..b39c4c3f06 100644 --- a/gr-utils/python/modtool/modtool_add.py +++ b/gr-utils/python/modtool/modtool_add.py @@ -23,7 +23,7 @@ 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 @@ -71,15 +71,19 @@ class ModToolAdd(ModTool): if self._info['blocktype'] is None: # 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'] = raw_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'] = raw_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'] = raw_input("Language (python/cpp): ") + language_candidates = ('c++', 'cpp', 'python') + with SequenceCompleter(language_candidates): + while self._info['lang'] not in language_candidates: + self._info['lang'] = raw_input("Language (python/cpp): ") if self._info['lang'] == 'c++': self._info['lang'] = 'cpp' diff --git a/gr-utils/python/modtool/modtool_rename.py b/gr-utils/python/modtool/modtool_rename.py index f0ff412a89..6b1f6da11d 100644 --- a/gr-utils/python/modtool/modtool_rename.py +++ b/gr-utils/python/modtool/modtool_rename.py @@ -182,7 +182,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 d1061aac8c..767cb6b083 100644 --- a/gr-utils/python/modtool/modtool_rm.py +++ b/gr-utils/python/modtool/modtool_rm.py @@ -25,7 +25,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 @@ -48,7 +48,8 @@ class ModToolRemove(ModTool): if options.blockname is not None: self._info['pattern'] = options.blockname else: - self._info['pattern'] = raw_input('Which blocks do you want to delete? (Regex): ') + with SequenceCompleter(): + self._info['pattern'] = raw_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 ec6023ab3b..9b0ef7db5e 100644 --- a/gr-utils/python/modtool/scm.py +++ b/gr-utils/python/modtool/scm.py @@ -205,7 +205,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 globals().values(): diff --git a/gr-utils/python/modtool/util_functions.py b/gr-utils/python/modtool/util_functions.py index de7f3d29b6..59f8984ca3 100644 --- a/gr-utils/python/modtool/util_functions.py +++ b/gr-utils/python/modtool/util_functions.py @@ -22,6 +22,7 @@ import re import sys +import readline # None of these must depend on other modtool stuff! @@ -135,3 +136,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) |