diff options
Diffstat (limited to 'gr-utils/python')
36 files changed, 159 insertions, 101 deletions
diff --git a/gr-utils/python/modtool/gr-newmod/CMakeLists.txt b/gr-utils/python/modtool/gr-newmod/CMakeLists.txt index 3f316a78b4..30540c124e 100644 --- a/gr-utils/python/modtool/gr-newmod/CMakeLists.txt +++ b/gr-utils/python/modtool/gr-newmod/CMakeLists.txt @@ -1,6 +1,7 @@ # Copyright 2011,2012,2014,2016 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-howto # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gr-utils/python/modtool/gr-newmod/apps/CMakeLists.txt b/gr-utils/python/modtool/gr-newmod/apps/CMakeLists.txt index c837d77f67..e92732f65f 100644 --- a/gr-utils/python/modtool/gr-newmod/apps/CMakeLists.txt +++ b/gr-utils/python/modtool/gr-newmod/apps/CMakeLists.txt @@ -1,6 +1,7 @@ # Copyright 2011 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-howto # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gr-utils/python/modtool/gr-newmod/cmake/Modules/FindGnuradioRuntime.cmake b/gr-utils/python/modtool/gr-newmod/cmake/Modules/FindGnuradioRuntime.cmake index afed684a5e..86044e52a3 100644 --- a/gr-utils/python/modtool/gr-newmod/cmake/Modules/FindGnuradioRuntime.cmake +++ b/gr-utils/python/modtool/gr-newmod/cmake/Modules/FindGnuradioRuntime.cmake @@ -31,6 +31,6 @@ if(PC_GNURADIO_RUNTIME_FOUND) endif(PC_GNURADIO_RUNTIME_FOUND) INCLUDE(FindPackageHandleStandardArgs) -# do not check GNURADIO_RUNTIME_INCLUDE_DIRS, is not set when default include path us used. +# do not check GNURADIO_RUNTIME_INCLUDE_DIRS, is not set when default include path is used. FIND_PACKAGE_HANDLE_STANDARD_ARGS(GNURADIO_RUNTIME DEFAULT_MSG GNURADIO_RUNTIME_LIBRARIES) MARK_AS_ADVANCED(GNURADIO_RUNTIME_LIBRARIES GNURADIO_RUNTIME_INCLUDE_DIRS) 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 beeeebe72a..6b7bbc9d20 100644 --- a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrMiscUtils.cmake +++ b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrMiscUtils.cmake @@ -1,6 +1,7 @@ # Copyright 2010-2011,2014 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-howto # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPlatform.cmake b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPlatform.cmake index 00a53d04d9..ed9fc82580 100644 --- a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPlatform.cmake +++ b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPlatform.cmake @@ -1,6 +1,7 @@ # Copyright 2011 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-howto # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPython.cmake b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPython.cmake index 6b997c0869..588236e8b8 100644 --- a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPython.cmake +++ b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPython.cmake @@ -1,6 +1,7 @@ # Copyright 2010-2011 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-howto # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by 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 bce51b23dd..e23c770228 100644 --- a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrSwig.cmake +++ b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrSwig.cmake @@ -1,6 +1,7 @@ # Copyright 2010-2011 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-howto # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrTest.cmake b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrTest.cmake index 62caab4b51..186e2d5333 100644 --- a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrTest.cmake +++ b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrTest.cmake @@ -1,6 +1,7 @@ # Copyright 2010-2011 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-howto # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gr-utils/python/modtool/gr-newmod/docs/CMakeLists.txt b/gr-utils/python/modtool/gr-newmod/docs/CMakeLists.txt index f16fbf6db4..8c86a96fc2 100644 --- a/gr-utils/python/modtool/gr-newmod/docs/CMakeLists.txt +++ b/gr-utils/python/modtool/gr-newmod/docs/CMakeLists.txt @@ -1,6 +1,7 @@ # Copyright 2011 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-howto # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gr-utils/python/modtool/gr-newmod/docs/doxygen/CMakeLists.txt b/gr-utils/python/modtool/gr-newmod/docs/doxygen/CMakeLists.txt index 1b4479929b..7aa31fcecd 100644 --- a/gr-utils/python/modtool/gr-newmod/docs/doxygen/CMakeLists.txt +++ b/gr-utils/python/modtool/gr-newmod/docs/doxygen/CMakeLists.txt @@ -1,6 +1,7 @@ # Copyright 2011 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-howto # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by 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 da8cb6ac38..cabbb34167 100644 --- a/gr-utils/python/modtool/gr-newmod/docs/doxygen/Doxyfile.in +++ b/gr-utils/python/modtool/gr-newmod/docs/doxygen/Doxyfile.in @@ -989,7 +989,7 @@ HTML_COLORSTYLE_GAMMA = 80 # page will contain the date and time when the page was generated. Setting # this to NO can help when comparing the output of multiple runs. -HTML_TIMESTAMP = YES +HTML_TIMESTAMP = NO # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the 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 7470475c2c..33bc2afd07 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 @@ -121,7 +121,7 @@ INLINE_INHERITED_MEMB = NO # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. -FULL_PATH_NAMES = YES +FULL_PATH_NAMES = NO # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is @@ -957,7 +957,7 @@ HTML_COLORSTYLE_GAMMA = 80 # page will contain the date and time when the page was generated. Setting # this to NO can help when comparing the output of multiple runs. -HTML_TIMESTAMP = YES +HTML_TIMESTAMP = NO # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the diff --git a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/__init__.py b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/__init__.py index b7a8884519..22f4eb351d 100644 --- a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/__init__.py +++ b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/__init__.py @@ -1,7 +1,8 @@ # # Copyright 2010 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-howto # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/base.py b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/base.py index 0f0adf255b..b21369221c 100644 --- a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/base.py +++ b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/base.py @@ -1,7 +1,8 @@ # # Copyright 2010 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-howto # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/doxyindex.py b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/doxyindex.py index 4284af25ec..5401bf2666 100644 --- a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/doxyindex.py +++ b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/doxyindex.py @@ -1,7 +1,8 @@ # # Copyright 2010 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-howto # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/text.py b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/text.py index de2d19b532..caf0b05480 100644 --- a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/text.py +++ b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/text.py @@ -1,7 +1,8 @@ # # Copyright 2010 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-howto # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gr-utils/python/modtool/gr-newmod/docs/doxygen/swig_doc.py b/gr-utils/python/modtool/gr-newmod/docs/doxygen/swig_doc.py index c735b1291b..07c5b75401 100644 --- a/gr-utils/python/modtool/gr-newmod/docs/doxygen/swig_doc.py +++ b/gr-utils/python/modtool/gr-newmod/docs/doxygen/swig_doc.py @@ -1,7 +1,8 @@ # # Copyright 2010-2012 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-howto # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gr-utils/python/modtool/gr-newmod/grc/CMakeLists.txt b/gr-utils/python/modtool/gr-newmod/grc/CMakeLists.txt index d776de7523..b0ce5e79a9 100644 --- a/gr-utils/python/modtool/gr-newmod/grc/CMakeLists.txt +++ b/gr-utils/python/modtool/gr-newmod/grc/CMakeLists.txt @@ -1,6 +1,7 @@ # Copyright 2011 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-howto # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gr-utils/python/modtool/gr-newmod/include/howto/CMakeLists.txt b/gr-utils/python/modtool/gr-newmod/include/howto/CMakeLists.txt index 1cfb5a6eac..664ca26a34 100644 --- a/gr-utils/python/modtool/gr-newmod/include/howto/CMakeLists.txt +++ b/gr-utils/python/modtool/gr-newmod/include/howto/CMakeLists.txt @@ -1,6 +1,7 @@ # Copyright 2011,2012 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-howto # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gr-utils/python/modtool/gr-newmod/include/howto/api.h b/gr-utils/python/modtool/gr-newmod/include/howto/api.h index db5f81f394..03620be2df 100644 --- a/gr-utils/python/modtool/gr-newmod/include/howto/api.h +++ b/gr-utils/python/modtool/gr-newmod/include/howto/api.h @@ -1,7 +1,8 @@ /* * Copyright 2011 Free Software Foundation, Inc. * - * This file is part of GNU Radio + * This file was generated by gr_modtool, a tool from the GNU Radio framework + * This file is a part of gr-howto * * GNU Radio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gr-utils/python/modtool/gr-newmod/lib/CMakeLists.txt b/gr-utils/python/modtool/gr-newmod/lib/CMakeLists.txt index 24ffa41fc1..64b7c1d4ab 100644 --- a/gr-utils/python/modtool/gr-newmod/lib/CMakeLists.txt +++ b/gr-utils/python/modtool/gr-newmod/lib/CMakeLists.txt @@ -1,6 +1,7 @@ # Copyright 2011,2012,2016 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-howto # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gr-utils/python/modtool/gr-newmod/lib/qa_howto.cc b/gr-utils/python/modtool/gr-newmod/lib/qa_howto.cc index f86aed4aa1..2f10a3a564 100644 --- a/gr-utils/python/modtool/gr-newmod/lib/qa_howto.cc +++ b/gr-utils/python/modtool/gr-newmod/lib/qa_howto.cc @@ -1,7 +1,8 @@ /* * Copyright 2012 Free Software Foundation, Inc. * - * This file is part of GNU Radio + * This file was generated by gr_modtool, a tool from the GNU Radio framework + * This file is a part of gr-howto * * GNU Radio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gr-utils/python/modtool/gr-newmod/lib/qa_howto.h b/gr-utils/python/modtool/gr-newmod/lib/qa_howto.h index 23f0f7f33e..c50bde3ec7 100644 --- a/gr-utils/python/modtool/gr-newmod/lib/qa_howto.h +++ b/gr-utils/python/modtool/gr-newmod/lib/qa_howto.h @@ -2,7 +2,8 @@ /* * Copyright 2012 Free Software Foundation, Inc. * - * This file is part of GNU Radio + * This file was generated by gr_modtool, a tool from the GNU Radio framework + * This file is a part of gr-howto * * GNU Radio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gr-utils/python/modtool/gr-newmod/lib/test_howto.cc b/gr-utils/python/modtool/gr-newmod/lib/test_howto.cc index cc89dc90f3..699bb5b640 100644 --- a/gr-utils/python/modtool/gr-newmod/lib/test_howto.cc +++ b/gr-utils/python/modtool/gr-newmod/lib/test_howto.cc @@ -2,7 +2,8 @@ /* * Copyright 2012 Free Software Foundation, Inc. * - * This file is part of GNU Radio + * This file was generated by gr_modtool, a tool from the GNU Radio framework + * This file is a part of gr-howto * * GNU Radio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gr-utils/python/modtool/gr-newmod/python/CMakeLists.txt b/gr-utils/python/modtool/gr-newmod/python/CMakeLists.txt index 9901854c8f..4b5303cc6f 100644 --- a/gr-utils/python/modtool/gr-newmod/python/CMakeLists.txt +++ b/gr-utils/python/modtool/gr-newmod/python/CMakeLists.txt @@ -1,6 +1,7 @@ # Copyright 2011 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-howto # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gr-utils/python/modtool/gr-newmod/swig/CMakeLists.txt b/gr-utils/python/modtool/gr-newmod/swig/CMakeLists.txt index 5810b6c1ea..bc11347447 100644 --- a/gr-utils/python/modtool/gr-newmod/swig/CMakeLists.txt +++ b/gr-utils/python/modtool/gr-newmod/swig/CMakeLists.txt @@ -1,6 +1,7 @@ # Copyright 2011 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-howto # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/gr-utils/python/modtool/modtool_add.py b/gr-utils/python/modtool/modtool_add.py index acc0385ac4..46ff74168a 100644 --- a/gr-utils/python/modtool/modtool_add.py +++ b/gr-utils/python/modtool/modtool_add.py @@ -1,5 +1,5 @@ # -# Copyright 2013-2014 Free Software Foundation, Inc. +# Copyright 2013, 2017 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -71,6 +71,18 @@ class ModToolAdd(ModTool): def setup(self, options): ModTool.setup(self, options) + if self._info['blockname'] is None: + if len(args) >= 2: + self._info['blockname'] = args[1] + else: + self._info['blockname'] = raw_input("Enter name of block/code (without module name prefix): ") + if os.path.isfile("./lib/"+self._info['blockname']+"_impl.cc") or os.path.isfile("./python/"+self._info['blockname']+".py"): + raise ModToolException('The given blockname already exists!') + if not re.match('[a-zA-Z0-9_]+', self._info['blockname']): + raise ModToolException('Invalid block name.') + print "Block/code identifier: " + self._info['blockname'] + self._info['fullblockname'] = self._info['modname'] + '_' + self._info['blockname'] + self._info['blocktype'] = options.block_type if self._info['blocktype'] is None: # Print list out of blocktypes to user for reference @@ -94,7 +106,7 @@ class ModToolAdd(ModTool): print("Language: %s" % {'cpp': 'C++', 'python': 'Python'}[self._info['lang']]) if ((self._skip_subdirs['lib'] and self._info['lang'] == 'cpp') - or (self._skip_subdirs['python'] and self._info['lang'] == 'python')): + or (self._skip_subdirs['python'] and self._info['lang'] == 'python')): raise ModToolException('Missing or skipping relevant subdir.') if self._info['blockname'] is None: @@ -106,7 +118,16 @@ class ModToolAdd(ModTool): if not options.license_file: self._info['copyrightholder'] = options.copyright if self._info['copyrightholder'] is None: - self._info['copyrightholder'] = '<+YOU OR YOUR COMPANY+>' + user = getpass.getuser() + git_user = self.scm.get_gituser() + if git_user: + copyright_candidates = (user, git_user, 'GNU Radio') + else: + copyright_candidates = (user, 'GNU Radio') + with SequenceCompleter(copyright_candidates): + self._info['copyrightholder'] = raw_input("Please specify the copyright holder: ") + if not self._info['copyrightholder'] or self._info['copyrightholder'].isspace(): + self._info['copyrightholder'] = "gr-"+self._info['modname']+" author" elif self._info['is_component']: print("For GNU Radio components the FSF is added as copyright holder") self._license_file = options.license_file @@ -159,8 +180,8 @@ class ModToolAdd(ModTool): """ Go, go, go. """ self.setup(options) has_swig = ( - self._info['lang'] == 'cpp' - and not self._skip_subdirs['swig'] + self._info['lang'] == 'cpp' + and not self._skip_subdirs['swig'] ) has_grc = False if self._info['lang'] == 'cpp': @@ -186,14 +207,14 @@ class ModToolAdd(ModTool): """ def _add_qa(): " Add C++ QA files for 3.7 API " - fname_qa_h = 'qa_%s.h' % self._info['blockname'] + fname_qa_h = 'qa_%s.h' % self._info['blockname'] fname_qa_cc = 'qa_%s.cc' % self._info['blockname'] self._write_tpl('qa_cpp', 'lib', fname_qa_cc) - self._write_tpl('qa_h', 'lib', fname_qa_h) + self._write_tpl('qa_h', 'lib', fname_qa_h) if not self._skip_cmakefiles: try: append_re_line_sequence(self._file['cmlib'], - '\$\{CMAKE_CURRENT_SOURCE_DIR\}/qa_%s.cc.*\n' % self._info['modname'], + r'\$\{CMAKE_CURRENT_SOURCE_DIR\}/qa_%s.cc.*\n' % self._info['modname'], ' ${CMAKE_CURRENT_SOURCE_DIR}/qa_%s.cc' % self._info['blockname']) append_re_line_sequence(self._file['qalib'], '#include.*\n', @@ -202,26 +223,26 @@ class ModToolAdd(ModTool): '(addTest.*suite.*\n|new CppUnit.*TestSuite.*\n)', ' s->addTest(gr::%s::qa_%s::suite());' % (self._info['modname'], self._info['blockname']) - ) + ) self.scm.mark_files_updated((self._file['qalib'],)) except IOError: print("Can't add C++ QA files.") fname_cc = None - fname_h = None - if self._info['version'] == '37': - fname_h = self._info['blockname'] + '.h' + fname_h = None + if self._info['version'] == '37': + fname_h = self._info['blockname'] + '.h' fname_cc = self._info['blockname'] + '.cc' if self._info['blocktype'] in ('source', 'sink', 'sync', 'decimator', 'interpolator', 'general', 'hier', 'tagged_stream'): fname_cc = self._info['blockname'] + '_impl.cc' - self._write_tpl('block_impl_h', 'lib', self._info['blockname'] + '_impl.h') + self._write_tpl('block_impl_h', 'lib', self._info['blockname'] + '_impl.h') self._write_tpl('block_impl_cpp', 'lib', fname_cc) - self._write_tpl('block_def_h', self._info['includedir'], fname_h) + self._write_tpl('block_def_h', self._info['includedir'], fname_h) else: # Pre-3.7 or autotools - fname_h = self._info['fullblockname'] + '.h' + fname_h = self._info['fullblockname'] + '.h' fname_cc = self._info['fullblockname'] + '.cc' - self._write_tpl('block_h36', self._info['includedir'], fname_h) - self._write_tpl('block_cpp36', 'lib', fname_cc) + self._write_tpl('block_h36', self._info['includedir'], fname_h) + self._write_tpl('block_cpp36', 'lib', fname_cc) if self._add_cc_qa: if self._info['version'] == '37': _add_qa() @@ -254,14 +275,15 @@ class ModToolAdd(ModTool): swig_block_magic_str = render_template('swig_block_magic', **self._info) open(self._file['swig'], 'a').write(swig_block_magic_str) include_str = '#include "%s%s%s.h"' % ( - {True: 'gnuradio/' + self._info['modname'], False: self._info['modname']}[self._info['is_component']], - mod_block_sep, - self._info['blockname']) + {True: 'gnuradio/' + self._info['modname'], + False: self._info['modname']}[self._info['is_component']], + mod_block_sep, + self._info['blockname']) if re.search('#include', open(self._file['swig'], 'r').read()): append_re_line_sequence(self._file['swig'], '^#include.*\n', include_str) else: # I.e., if the swig file is empty oldfile = open(self._file['swig'], 'r').read() - regexp = re.compile('^%\{\n', re.MULTILINE) + regexp = re.compile(r'^%\{\n', re.MULTILINE) oldfile = regexp.sub('%%{\n%s\n' % include_str, oldfile, count=1) open(self._file['swig'], 'w').write(oldfile) self.scm.mark_files_updated((self._file['swig'],)) @@ -280,8 +302,8 @@ class ModToolAdd(ModTool): return print("Editing %s/CMakeLists.txt..." % self._info['pydir']) open(self._file['cmpython'], 'a').write( - 'GR_ADD_TEST(qa_%s ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/%s)\n' % \ - (self._info['blockname'], fname_py_qa)) + 'GR_ADD_TEST(qa_%s ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/%s)\n' % \ + (self._info['blockname'], fname_py_qa)) self.scm.mark_files_updated((self._file['cmpython'],)) def _run_python(self): @@ -295,7 +317,8 @@ class ModToolAdd(ModTool): self._write_tpl('block_python', self._info['pydir'], fname_py) append_re_line_sequence(self._file['pyinit'], '(^from.*import.*\n|# import any pure.*\n)', - 'from %s import %s' % (self._info['blockname'], self._info['blockname'])) + 'from %s import %s' % (self._info['blockname'], + self._info['blockname'])) self.scm.mark_files_updated((self._file['pyinit'],)) if self._skip_cmakefiles: return diff --git a/gr-utils/python/modtool/modtool_base.py b/gr-utils/python/modtool/modtool_base.py index e0ae963f20..4263e498f7 100644 --- a/gr-utils/python/modtool/modtool_base.py +++ b/gr-utils/python/modtool/modtool_base.py @@ -51,6 +51,7 @@ class ModTool(object): self._has_subdirs[subdir] = False self._skip_subdirs[subdir] = False self._dir = None + self.scm = None @staticmethod def setup_parser(parser): @@ -102,7 +103,7 @@ class ModTool(object): if self._info['version'] == '36' and ( os.path.isdir(os.path.join('include', self._info['modname'])) or os.path.isdir(os.path.join('include', 'gnuradio', self._info['modname'])) - ): + ): self._info['version'] = '37' if options.skip_lib or not self._has_subdirs['lib']: self._skip_subdirs['lib'] = True @@ -121,14 +122,14 @@ class ModTool(object): def _setup_files(self): """ Initialise the self._file[] dictionary """ if not self._skip_subdirs['swig']: - self._file['swig'] = os.path.join('swig', self._get_mainswigfile()) + self._file['swig'] = os.path.join('swig', self._get_mainswigfile()) self._info['pydir'] = 'python' if os.path.isdir(os.path.join('python', self._info['modname'])): self._info['pydir'] = os.path.join('python', self._info['modname']) - self._file['qalib'] = os.path.join('lib', 'qa_%s.cc' % self._info['modname']) - self._file['pyinit'] = os.path.join(self._info['pydir'], '__init__.py') - self._file['cmlib'] = os.path.join('lib', 'CMakeLists.txt') - self._file['cmgrc'] = os.path.join('grc', 'CMakeLists.txt') + self._file['qalib'] = os.path.join('lib', 'qa_%s.cc' % self._info['modname']) + self._file['pyinit'] = os.path.join(self._info['pydir'], '__init__.py') + self._file['cmlib'] = os.path.join('lib', 'CMakeLists.txt') + self._file['cmgrc'] = os.path.join('grc', 'CMakeLists.txt') self._file['cmpython'] = os.path.join(self._info['pydir'], 'CMakeLists.txt') if self._info['is_component']: self._info['includedir'] = os.path.join('include', 'gnuradio', self._info['modname']) @@ -165,7 +166,7 @@ class ModTool(object): self._info['is_component'] = False for f in files: if os.path.isfile(f) and f == 'CMakeLists.txt': - if re.search('find_package\(Gnuradio', open(f).read()) is not None: + if re.search(r'find_package\(Gnuradio', open(f).read()) is not None: self._info['version'] = '36' # Might be 37, check that later has_makefile = True elif re.search('GR_REGISTER_COMPONENT', open(f).read()) is not None: diff --git a/gr-utils/python/modtool/modtool_disable.py b/gr-utils/python/modtool/modtool_disable.py index 619858978d..556b2e1ab2 100644 --- a/gr-utils/python/modtool/modtool_disable.py +++ b/gr-utils/python/modtool/modtool_disable.py @@ -76,11 +76,11 @@ class ModToolDisable(ModTool): def _handle_cc_qa(cmake, fname): """ Do stuff for cc qa """ if self._info['version'] == '37': - cmake.comment_out_lines('\$\{CMAKE_CURRENT_SOURCE_DIR\}/'+fname) + cmake.comment_out_lines(r'\$\{CMAKE_CURRENT_SOURCE_DIR\}/'+fname) fname_base = os.path.splitext(fname)[0] ed = CMakeFileEditor(self._file['qalib']) # Abusing the CMakeFileEditor... - ed.comment_out_lines('#include\s+"%s.h"' % fname_base, comment_str='//') - ed.comment_out_lines('%s::suite\(\)' % fname_base, comment_str='//') + ed.comment_out_lines(r'#include\s+"%s.h"' % fname_base, comment_str='//') + ed.comment_out_lines(r'%s::suite\(\)' % fname_base, comment_str='//') ed.write() self.scm.mark_file_updated(self._file['qalib']) elif self._info['version'] == '36': @@ -93,9 +93,8 @@ class ModToolDisable(ModTool): """ Comment out include files from the SWIG file, as well as the block magic """ swigfile = open(self._file['swig']).read() - (swigfile, nsubs) = re.subn('(.include\s+"(%s/)?%s")' % ( - self._info['modname'], fname), - r'//\1', swigfile) + (swigfile, nsubs) = re.subn(r'(.include\s+"(%s/)?%s")' % ( + self._info['modname'], fname), r'//\1', swigfile) if nsubs > 0: print("Changing %s..." % self._file['swig']) if nsubs > 1: # Need to find a single BLOCK_MAGIC @@ -124,15 +123,16 @@ class ModToolDisable(ModTool): self.setup(options) # List of special rules: 0: subdir, 1: filename re match, 2: callback special_treatments = ( - ('python', 'qa.+py$', _handle_py_qa), - ('python', '^(?!qa).+py$', _handle_py_mod), - ('lib', 'qa.+\.cc$', _handle_cc_qa), - ('include/%s' % self._info['modname'], '.+\.h$', _handle_h_swig), - ('include', '.+\.h$', _handle_h_swig), - ('swig', '.+\.i$', _handle_i_swig) + ('python', r'qa.+py$', _handle_py_qa), + ('python', r'^(?!qa).+py$', _handle_py_mod), + ('lib', r'qa.+\.cc$', _handle_cc_qa), + ('include/%s' % self._info['modname'], r'.+\.h$', _handle_h_swig), + ('include', r'.+\.h$', _handle_h_swig), + ('swig', r'.+\.i$', _handle_i_swig) ) for subdir in self._subdirs: - if self._skip_subdirs[subdir]: continue + if self._skip_subdirs[subdir]: + continue if self._info['version'] == '37' and subdir == 'include': subdir = 'include/%s' % self._info['modname'] try: diff --git a/gr-utils/python/modtool/modtool_info.py b/gr-utils/python/modtool/modtool_info.py index 4be302e03e..bae6df36ed 100644 --- a/gr-utils/python/modtool/modtool_info.py +++ b/gr-utils/python/modtool/modtool_info.py @@ -70,7 +70,7 @@ class ModToolInfo(ModTool): if self._info['version'] == '36' and ( os.path.isdir(os.path.join('include', mod_info['modname'])) or os.path.isdir(os.path.join('include', 'gnuradio', mod_info['modname'])) - ): + ): self._info['version'] = '37' mod_info['version'] = self._info['version'] if 'is_component' in list(self._info.keys()) and self._info['is_component']: @@ -111,7 +111,7 @@ class ModToolInfo(ModTool): base_build_dir = mod_info['base_dir'] if 'is_component' in list(mod_info.keys()): (base_build_dir, rest_dir) = os.path.split(base_build_dir) - has_build_dir = os.path.isdir(os.path.join(base_build_dir , 'build')) + has_build_dir = os.path.isdir(os.path.join(base_build_dir, 'build')) if (has_build_dir and os.path.isfile(os.path.join(base_build_dir, 'CMakeCache.txt'))): return os.path.join(base_build_dir, 'build') else: @@ -131,10 +131,11 @@ class ModToolInfo(ModTool): cmakecache_fid = open(os.path.join(mod_info['build_dir'], 'CMakeCache.txt')) for line in cmakecache_fid: if line.find('GNURADIO_RUNTIME_INCLUDE_DIRS:%s' % path_or_internal) != -1: - inc_dirs += line.replace('GNURADIO_RUNTIME_INCLUDE_DIRS:%s=' % path_or_internal, '').strip().split(';') + inc_dirs += line.replace('GNURADIO_RUNTIME_INCLUDE_DIRS:%s=' + % path_or_internal, '').strip().split(';') except IOError: pass - if len(inc_dirs) == 0 and self._suggested_dirs is not None: + if (not inc_dirs or inc_dirs.isspace) and self._suggested_dirs is not None: inc_dirs = [os.path.normpath(path) for path in self._suggested_dirs.split(':') if os.path.isdir(path)] return inc_dirs diff --git a/gr-utils/python/modtool/modtool_makexml.py b/gr-utils/python/modtool/modtool_makexml.py index 74fed4b7a1..90308d1b14 100644 --- a/gr-utils/python/modtool/modtool_makexml.py +++ b/gr-utils/python/modtool/modtool_makexml.py @@ -116,10 +116,10 @@ class ModToolMakeXML(ModTool): file_exists = True print("Warning: Overwriting existing GRC file.") grc_generator = GRCXMLGenerator( - modname=self._info['modname'], - blockname=blockname, - params=params, - iosig=iosig + modname=self._info['modname'], + blockname=blockname, + params=params, + iosig=iosig ) grc_generator.save(path_to_xml) if file_exists: @@ -148,7 +148,7 @@ class ModToolMakeXML(ModTool): 'std::vector<int>': 'int_vector', 'std::vector<float>': 'real_vector', 'std::vector<gr_complex>': 'complex_vector', - } + } if p_type in ('int',) and default_v is not None and len(default_v) > 1 and default_v[:2].lower() == '0x': return 'hex' try: @@ -175,4 +175,3 @@ class ModToolMakeXML(ModTool): raise ModToolException("Can't open some of the files necessary to parse {}.".format(fname_cc)) return (parser.read_params(), parser.read_io_signature(), blockname) - diff --git a/gr-utils/python/modtool/modtool_rename.py b/gr-utils/python/modtool/modtool_rename.py index b9112fb8c4..4af860b5d4 100644 --- a/gr-utils/python/modtool/modtool_rename.py +++ b/gr-utils/python/modtool/modtool_rename.py @@ -56,7 +56,7 @@ class ModToolRename(ModTool): ModTool.setup(self, options) if ((self._skip_subdirs['lib'] and self._info['lang'] == 'cpp') - or (self._skip_subdirs['python'] and self._info['lang'] == 'python')): + or (self._skip_subdirs['python'] and self._info['lang'] == 'python')): raise ModToolException('Missing or skipping relevant subdir.') # first make sure the old block name is provided diff --git a/gr-utils/python/modtool/modtool_rm.py b/gr-utils/python/modtool/modtool_rm.py index b503fa2bf3..7395c99bea 100644 --- a/gr-utils/python/modtool/modtool_rm.py +++ b/gr-utils/python/modtool/modtool_rm.py @@ -52,9 +52,10 @@ class ModToolRemove(ModTool): if options.blockname is not None: self._info['pattern'] = options.blockname else: - with SequenceCompleter(): + block_candidates = self.get_block_candidates() + with SequenceCompleter(block_candidates): self._info['pattern'] = input('Which blocks do you want to delete? (Regex): ') - if len(self._info['pattern']) == 0: + if not self._info['pattern'] or self._info['pattern'].isspace(): self._info['pattern'] = '.' def run(self, options): @@ -68,15 +69,15 @@ class ModToolRemove(ModTool): (base, ext) = os.path.splitext(filename) if ext == '.h': remove_pattern_from_file(self._file['qalib'], - '^#include "%s"\s*$' % filename) + r'^#include "%s"\s*$' % filename) remove_pattern_from_file(self._file['qalib'], - '^\s*s->addTest\(gr::%s::%s::suite\(\)\);\s*$' % ( - self._info['modname'], base) + r'^\s*s->addTest\(gr::%s::%s::suite\(\)\);\s*$' % ( + self._info['modname'], base) ) self.scm.mark_file_updated(self._file['qalib']) elif ext == '.cc': ed.remove_value('list', - '\$\{CMAKE_CURRENT_SOURCE_DIR\}/%s' % filename, + r'\$\{CMAKE_CURRENT_SOURCE_DIR\}/%s' % filename, to_ignore_start='APPEND test_%s_sources' % self._info['modname']) self.scm.mark_file_updated(ed.filename) else: @@ -119,8 +120,8 @@ class ModToolRemove(ModTool): py_files_deleted = self._run_subdir('python', ('*.py',), ('GR_PYTHON_INSTALL',), cmakeedit_func=_remove_py_test_case) for f in py_files_deleted: - remove_pattern_from_file(self._file['pyinit'], '.*import\s+%s.*' % f[:-3]) - remove_pattern_from_file(self._file['pyinit'], '.*from\s+%s\s+import.*\n' % f[:-3]) + remove_pattern_from_file(self._file['pyinit'], r'.*import\s+%s.*' % f[:-3]) + remove_pattern_from_file(self._file['pyinit'], r'.*from\s+%s\s+import.*\n' % f[:-3]) if not self._skip_subdirs['grc']: self._run_subdir('grc', ('*.xml',), ('install',)) diff --git a/gr-utils/python/modtool/scm.py b/gr-utils/python/modtool/scm.py index 5e80e24994..4b3d5116ac 100644 --- a/gr-utils/python/modtool/scm.py +++ b/gr-utils/python/modtool/scm.py @@ -84,6 +84,13 @@ class SCMRepository(object): """ Returns true if this repository manager is operating on an active, source-controlled directory. """ return self.is_empty + def get_gituser(self): + """ Gets the git user """ + try: + return subprocess.check_output('git config --global user.name', shell=True).strip() + except (OSError, subprocess.CalledProcessError): + return None + ### Git ##################################################################### class GitManagerGitPython(object): diff --git a/gr-utils/python/modtool/templates.py b/gr-utils/python/modtool/templates.py index 64c99802fe..10ee4a4e6c 100644 --- a/gr-utils/python/modtool/templates.py +++ b/gr-utils/python/modtool/templates.py @@ -505,22 +505,22 @@ ${str_to_python_comment(license)} from gnuradio import gr, gr_unittest from gnuradio import blocks % if lang == 'cpp': -import ${modname}_swig as ${modname} +import ${modname}.${modname}_swig as ${modname} % else: from ${blockname} import ${blockname} % endif -class qa_${blockname} (gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () +class qa_${blockname}(gr_unittest.TestCase): + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None - def test_001_t (self): + def test_001_t(self): # set up fg - self.tb.run () + self.tb.run() # check data 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) |