-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ModTool: Add features and update functionalities #1873
Closed
Closed
Changes from 77 commits
Commits
Show all changes
82 commits
Select commit
Hold shift + click to select a range
27c87e2
CLI parsing: Change from Argparse to Click
swap-nil7 84f70ab
modtool: Remove redundant imports and functions
swap-nil7 19bfb95
gr_modtool: replace immutable namedtuples by class objects
swap-nil7 ac55488
modtool: Update SequenceCompleter for py3k compatibility
swap-nil7 4e0cab8
CLI: move commands to respective modules
swap-nil7 2da6d9c
CLI: add missing imports, fix the issue with click commands of submod…
swap-nil7 9d21470
modtool: Add a Click Plugin Architecture
swap-nil7 06baf14
CLI: Add short_help for gr_modtool --help
swap-nil7 18efc42
Plugin Architecture: Multicommand to Group
swap-nil7 a01a146
Plugin Architecture: Update for external plugins
swap-nil7 8d06d19
External Plugins: Complete
swap-nil7 da7c843
CLI: visual changes
swap-nil7 405447a
gr_modtool: Remove wildcard import statement
swap-nil7 db7f28d
modtool_base: newline at the end of file
swap-nil7 c60f507
Modtool: Remove unused imports and fix Pylint issues
swap-nil7 f64f6ed
CLI: use SimpleNamespace
swap-nil7 385db2e
API: move the code to modtool.core
swap-nil7 cb0d0cc
API: shift click code to the cli folder
swap-nil7 9f7b1e6
API: Add CMakeLists
swap-nil7 2bfcca2
API: Remove click code from the core maintaining the functionality
swap-nil7 c7f0723
CLI: move redundant code to the base
swap-nil7 ff2a45d
ModToolAdd: Shift portion from core to cli
swap-nil7 34cd898
ModToolAdd: Separate CLI and Core
swap-nil7 2b39810
ModToolAdd: Separated Core and CLI
swap-nil7 6224825
ModToolDisable: Core/CLI split
swap-nil7 fb6da18
ModToolRename: Core/CLI split
swap-nil7 01ae6e5
ModToolRemove: Core/CLI split
swap-nil7 21da87a
ModToolMakeXML: Core/CLI split
swap-nil7 3ec3556
grc_xml_generator: Outfile must be in binary mode
swap-nil7 02db700
ModtoolNewModule: Core/CLI split
swap-nil7 536f6c5
Core/CLI split: Clean up
swap-nil7 1f82ef3
Core/Cli split: Remove unused imports
swap-nil7 3fe0a63
ModToolNewModule: Update help page
swap-nil7 cfbb53e
API: Improve checks for Core modules
swap-nil7 f192744
ModToolAdd: add missing condition
swap-nil7 428e8d5
ModTool: Move some modules setup to __init__
swap-nil7 3e2e591
Modtool: Complete Base Module and Add module
swap-nil7 3391edd
Core/CLI split: Update CLI and Core modules
swap-nil7 e939c4a
ModToolMakeXML: Shift the setup code to __init__
swap-nil7 a3428bc
ModToolNewModule: moved the setup code to __init__
swap-nil7 7123996
ModToolRename: shift the setup code into __init__
swap-nil7 ea67a4f
ModToolRemove: Shift the setup code into __init__
swap-nil7 b6791f2
ModTool: Remove unused imports
swap-nil7 7424145
ModTool CLI: Change absolute imports to relative
swap-nil7 189dfd4
Core and CLI: Rename modules
swap-nil7 f4ba70c
ModTool Core: Avoid breaking of code for no arguments
swap-nil7 65fa252
CLI: rename modules
swap-nil7 91df381
Split core, template, and utility modules
swap-nil7 ec973c2
Core Modules: Replace *args with actual arguments
swap-nil7 ed262de
ModTool: Change some of the protected class members to public
swap-nil7 cc77775
ModTool Core: Specify module name
swap-nil7 c9b3c3c
replace raw 'open' with 'with open(file) as f
swap-nil7 1d28005
Modtool Core: Replace print with logging.logger
swap-nil7 a507236
API: modify classes so that the values can be assigned later
swap-nil7 36dfeb7
ModTool base: shift code from init to other functions to enable the c…
swap-nil7 08b5d2c
CLI: validation must occur at instantiation
swap-nil7 506ad89
ModTool: make the logger global
swap-nil7 3ce04e6
ModTool: Add test for modtool API
swap-nil7 44e6abe
ModTool: Add logger to the tools
swap-nil7 94bec4f
ModTool: Remove call to a protected method from CLI newmod
swap-nil7 99d8df9
ModToolMakeXML: decode bytes generated by xml.etree.Element.tostring
swap-nil7 9c6a59f
ModTool CLI: Add functional behaviour
swap-nil7 fc5c59d
ModTool: Add SequenceComplter, Fix bug for rename
swap-nil7 9df8d9e
ModTool: Add colors to the logger
swap-nil7 0138433
ModTool: Add colors if colorama is installed
swap-nil7 17df7e5
ModTool: Color Enhancement
swap-nil7 8b39d51
ModTool: Remove redundant styling of input
swap-nil7 1966185
ModTool: Interchange color of input and logger info
swap-nil7 6b20e21
ModTool Add: Split _run_lib to separate qa code
swap-nil7 8da4abd
ModTool: Basic Pylint fixes
swap-nil7 0d8d06f
ModTool Python Templates: Relative imports
swap-nil7 3ca51e3
ModTool Tests: Add Pylint Tests (commented)
swap-nil7 685340c
ModTool: Replace XML Generator by YAML Generator
swap-nil7 4f07af1
YAML Generator: Lint fixes and append .block to file name
swap-nil7 08d06a5
ModTool Templates: Replace XML template with YAML template
swap-nil7 758aa2f
ModTool: Remove future imports and update copyright templates
swap-nil7 71f9c68
ModTool: Update README and restructure CMakeLists
swap-nil7 c174d46
Uncomment pylint tests, use str.format, restructure imports
swap-nil7 c1757a9
ModTool: Add XML to YAML Converter (option: update)
swap-nil7 5b6a877
ModTool Update: Add feature for conversion of all XML bindings
swap-nil7 31608d2
ModTool: Minor enhancements
swap-nil7 a9b88a4
Modtool: Import modules from future for Py2k compatibility
swap-nil7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,5 +51,4 @@ if(ENABLE_GR_UTILS) | |
add_subdirectory(python/utils) | ||
add_subdirectory(python/modtool) | ||
|
||
|
||
endif(ENABLE_GR_UTILS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
gr_modtool: Swiss Army Knife for editing GNU Radio modules and -components. | ||
|
||
Adding a new subcommand | ||
======================= | ||
Adding a new subcommand for Command Line Interface | ||
================================================== | ||
|
||
* Add a new file called modtool_SUBCOMMAND | ||
* Add a new file called SUBCOMMAND in the cli directory | ||
* Create a function cli with the decorator @click.command or @click.group | ||
* Add the necessary options for the command or command group | ||
* Add that file to __init__.py and CMakeLists.txt in the cli directory | ||
|
||
|
||
Adding a new subcommand for Exposing as an API | ||
============================================== | ||
|
||
* Add a new file called SUBCOMMAND in the core directory | ||
* Have a look at the other subcommands, it must inherit from ModTool | ||
* Add that file to __init__.py and CMakeLists.txt | ||
* Add that file to __init__.py and CMakeLists.txt in the core directory | ||
|
||
|
||
The gr-newmod directory inside the templates directory | ||
====================================================== | ||
|
||
The gr-newmod directory | ||
======================= | ||
This dir basically contains a copy of gr-howto-write-a-block from the gnuradio | ||
sources, with some differences: | ||
- All example blocks, apps, grc files (...) and references thereto in the | ||
CMake files are removed | ||
- In the top-level CMake file, the project is called 'gr-howto'. | ||
- Any time anything relevant is changed in gr-howto-write-a-block, it should | ||
be changed here, too. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +0,0 @@ | ||
from __future__ import absolute_import | ||
from __future__ import unicode_literals | ||
# | ||
# Copyright 2013-2014 Free Software Foundation, Inc. | ||
# | ||
# This file is part of GNU Radio | ||
# | ||
# 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 | ||
# the Free Software Foundation; either version 3, or (at your option) | ||
# any later version. | ||
# | ||
# GNU Radio is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with GNU Radio; see the file COPYING. If not, write to | ||
# the Free Software Foundation, Inc., 51 Franklin Street, | ||
# Boston, MA 02110-1301, USA. | ||
# | ||
|
||
from .cmakefile_editor import CMakeFileEditor | ||
from .grc_xml_generator import GRCXMLGenerator | ||
from .modtool_base import ModTool, ModToolException, get_modtool_modules | ||
from .modtool_add import ModToolAdd | ||
from .modtool_disable import ModToolDisable | ||
from .modtool_info import ModToolInfo | ||
from .modtool_makexml import ModToolMakeXML | ||
from .modtool_newmod import ModToolNewModule | ||
from .modtool_rm import ModToolRemove | ||
from .modtool_rename import ModToolRename | ||
from .templates import Templates | ||
# Leave this at the end | ||
from .parser_cc_block import ParserCCBlock | ||
from .util_functions import * | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2018 Free Software Foundation, Inc. | ||
# | ||
# This file is part of GNU Radio | ||
# | ||
# 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 | ||
# the Free Software Foundation; either version 3, or (at your option) | ||
# any later version. | ||
# | ||
# GNU Radio is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with GNU Radio; see the file COPYING. If not, write to | ||
# the Free Software Foundation, Inc., 51 Franklin Street, | ||
# Boston, MA 02110-1301, USA. | ||
|
||
include(GrPython) | ||
|
||
GR_PYTHON_INSTALL(FILES | ||
__init__.py | ||
add.py | ||
base.py | ||
disable.py | ||
info.py | ||
makeyaml.py | ||
newmod.py | ||
rm.py | ||
rename.py | ||
DESTINATION ${GR_PYTHON_DIR}/gnuradio/modtool/cli | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# | ||
# Copyright 2018 Free Software Foundation, Inc. | ||
# | ||
# This file is part of GNU Radio | ||
# | ||
# 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 | ||
# the Free Software Foundation; either version 3, or (at your option) | ||
# any later version. | ||
# | ||
# GNU Radio is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with GNU Radio; see the file COPYING. If not, write to | ||
# the Free Software Foundation, Inc., 51 Franklin Street, | ||
# Boston, MA 02110-1301, USA. | ||
# | ||
|
||
from .base import cli, common_params, block_name, ModToolException | ||
from .base import setup_cli_logger, cli_input |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
# | ||
# Copyright 2018 Free Software Foundation, Inc. | ||
# | ||
# This file is part of GNU Radio | ||
# | ||
# 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 | ||
# the Free Software Foundation; either version 3, or (at your option) | ||
# any later version. | ||
# | ||
# GNU Radio is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with GNU Radio; see the file COPYING. If not, write to | ||
# the Free Software Foundation, Inc., 51 Franklin Street, | ||
# Boston, MA 02110-1301, USA. | ||
# | ||
""" Module to add new blocks """ | ||
|
||
import re | ||
|
||
import click | ||
|
||
from ..core import ModToolAdd | ||
from ..tools import SequenceCompleter, ask_yes_no | ||
from .base import ModToolException | ||
from .base import common_params, block_name, run, cli_input | ||
|
||
|
||
@click.command('add') | ||
@click.option('-t', '--block-type', type=click.Choice(ModToolAdd.block_types), | ||
help="One of {}.".format(', '.join(ModToolAdd.block_types))) | ||
@click.option('--license-file', | ||
help="File containing the license header for every source code file.") | ||
@click.option('--copyright', | ||
help="Name of the copyright holder (you or your company) MUST be a quoted string.") | ||
@click.option('--argument-list', default="", | ||
help="The argument list for the constructor and make functions.") | ||
@click.option('--add-python-qa', is_flag=True, default=None, | ||
help="If given, Python QA code is automatically added if possible.") | ||
@click.option('--add-cpp-qa', is_flag=True, default=None, | ||
help="If given, C++ QA code is automatically added if possible.") | ||
@click.option('--skip-cmakefiles', is_flag=True, | ||
help="If given, only source files are written, but CMakeLists.txt files are left unchanged.") | ||
@click.option('-l', '--lang', type=click.Choice(ModToolAdd.language_candidates), | ||
help="Programming Language") | ||
@common_params | ||
@block_name | ||
def cli(**kwargs): | ||
"""Adds a block to the out-of-tree module.""" | ||
kwargs['cli'] = True | ||
self = ModToolAdd(**kwargs) | ||
click.secho("GNU Radio module name identified: " + self.info['modname'], fg='green') | ||
get_blocktype(self) | ||
get_lang(self) | ||
click.secho("Language: {}".format({'cpp': 'C++', 'python': 'Python'}[self.info['lang']]), fg='green') | ||
if ((self.skip_subdirs['lib'] and self.info['lang'] == 'cpp') | ||
or (self.skip_subdirs['python'] and self.info['lang'] == 'python')): | ||
raise ModToolException('Missing or skipping relevant subdir.') | ||
get_blockname(self) | ||
click.secho("Block/code identifier: " + self.info['blockname'], fg='green') | ||
self.info['fullblockname'] = self.info['modname'] + '_' + self.info['blockname'] | ||
if not self.license_file: | ||
get_copyrightholder(self) | ||
self.info['license'] = self.setup_choose_license() | ||
get_arglist(self) | ||
get_py_qa(self) | ||
get_cpp_qa(self) | ||
if self.info['version'] == 'autofoo' and not self.skip_cmakefiles: | ||
click.secho("Warning: Autotools modules are not supported. "+ | ||
"Files will be created, but Makefiles will not be edited.", | ||
fg='yellow') | ||
self.skip_cmakefiles = True | ||
run(self) | ||
|
||
def get_blocktype(self): | ||
""" Get the blocktype of the block to be added """ | ||
if self.info['blocktype'] is None: | ||
click.secho(str(self.block_types), fg='yellow') | ||
with SequenceCompleter(self.block_types): | ||
while self.info['blocktype'] not in self.block_types: | ||
self.info['blocktype'] = cli_input("Enter block type: ") | ||
if self.info['blocktype'] not in self.block_types: | ||
click.secho('Must be one of ' + str(self.block_types), fg='yellow') | ||
|
||
def get_lang(self): | ||
""" Get the Programming Language of the block to be added """ | ||
if self.info['lang'] is None: | ||
with SequenceCompleter(self.language_candidates): | ||
while self.info['lang'] not in self.language_candidates: | ||
self.info['lang'] = cli_input("Language (python/cpp): ") | ||
if self.info['lang'] == 'c++': | ||
self.info['lang'] = 'cpp' | ||
|
||
def get_blockname(self): | ||
""" Get the blockname""" | ||
if self.info['blockname'] is None: | ||
while not self.info['blockname'] or self.info['blockname'].isspace(): | ||
self.info['blockname'] = cli_input("Enter name of block/code (without module name prefix): ") | ||
if not re.match('[a-zA-Z0-9_]+', self.info['blockname']): | ||
raise ModToolException('Invalid block name.') | ||
|
||
def get_copyrightholder(self): | ||
""" Get the copyrightholder of the block to be added """ | ||
if self.info['copyrightholder'] is None: | ||
self.info['copyrightholder'] = '<+YOU OR YOUR COMPANY+>' | ||
elif self.info['is_component']: | ||
click.secho("For GNU Radio components the FSF is added as copyright holder", | ||
fg='cyan') | ||
|
||
def get_arglist(self): | ||
""" Get the argument list of the block to be added """ | ||
if self.info['arglist'] is not None: | ||
self.info['arglist'] = cli_input('Enter valid argument list, including default arguments: ') | ||
|
||
def get_py_qa(self): | ||
""" Get a boolean value for addition of py_qa """ | ||
if not (self.info['blocktype'] in ('noblock') or self.skip_subdirs['python']): | ||
if self.add_py_qa is None: | ||
self.add_py_qa = ask_yes_no(click.style('Add Python QA code?', fg='cyan'), True) | ||
|
||
def get_cpp_qa(self): | ||
""" Get a boolean value for addition of cpp_qa """ | ||
if self.info['lang'] == 'cpp': | ||
if self.add_cc_qa is None: | ||
self.add_cc_qa = ask_yes_no(click.style('Add C++ QA code?', fg='cyan'), | ||
not self.add_py_qa) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When modifying a file, don't replace the year but add it to keep track of its changes
# Copyright 2011, 2018 Free Software Foundation, Inc.
This goes for all mods on the Copyright year that you made
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The files that are newly created will have only 2018. All the
core
scripts and thetools
scripts have a previous copyright intact.