summaryrefslogtreecommitdiff
path: root/gr-utils/python/modtool/cli
diff options
context:
space:
mode:
Diffstat (limited to 'gr-utils/python/modtool/cli')
-rw-r--r--gr-utils/python/modtool/cli/CMakeLists.txt22
-rw-r--r--gr-utils/python/modtool/cli/__init__.py15
-rw-r--r--gr-utils/python/modtool/cli/add.py140
-rw-r--r--gr-utils/python/modtool/cli/base.py158
-rw-r--r--gr-utils/python/modtool/cli/disable.py40
-rw-r--r--gr-utils/python/modtool/cli/info.py30
-rw-r--r--gr-utils/python/modtool/cli/makeyaml.py72
-rw-r--r--gr-utils/python/modtool/cli/newmod.py58
-rw-r--r--gr-utils/python/modtool/cli/rename.py71
-rw-r--r--gr-utils/python/modtool/cli/rm.py40
-rw-r--r--gr-utils/python/modtool/cli/update.py50
11 files changed, 0 insertions, 696 deletions
diff --git a/gr-utils/python/modtool/cli/CMakeLists.txt b/gr-utils/python/modtool/cli/CMakeLists.txt
deleted file mode 100644
index f00adfb4d8..0000000000
--- a/gr-utils/python/modtool/cli/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright 2018 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-
-include(GrPython)
-
-GR_PYTHON_INSTALL(FILES
- __init__.py
- add.py
- base.py
- disable.py
- info.py
- makeyaml.py
- newmod.py
- rm.py
- rename.py
- update.py
- DESTINATION ${GR_PYTHON_DIR}/gnuradio/modtool/cli
-)
diff --git a/gr-utils/python/modtool/cli/__init__.py b/gr-utils/python/modtool/cli/__init__.py
deleted file mode 100644
index 65f3603113..0000000000
--- a/gr-utils/python/modtool/cli/__init__.py
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# Copyright 2018 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-#
-
-from __future__ import print_function
-from __future__ import absolute_import
-from __future__ import unicode_literals
-
-from .base import cli, common_params, block_name, ModToolException
-from .base import setup_cli_logger, cli_input
diff --git a/gr-utils/python/modtool/cli/add.py b/gr-utils/python/modtool/cli/add.py
deleted file mode 100644
index e65bac1176..0000000000
--- a/gr-utils/python/modtool/cli/add.py
+++ /dev/null
@@ -1,140 +0,0 @@
-#
-# Copyright 2018 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-#
-""" Module to add new blocks """
-
-from __future__ import print_function
-from __future__ import absolute_import
-from __future__ import unicode_literals
-
-import re
-import getpass
-
-import click
-
-from ..core import ModToolAdd
-from ..tools import SequenceCompleter, ask_yes_no
-from .base import common_params, block_name, run, cli_input, ModToolException
-
-
-@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 not self.info['blockname'] or self.info['blockname'].isspace():
- 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 not self.info['copyrightholder'] or self.info['copyrightholder'].isspace():
- 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'] = cli_input("Please specify the copyright holder: ")
- if not self.info['copyrightholder'] or self.info['copyrightholder'].isspace():
- self.info['copyrightholder'] = "gr-{} author".format(self.info['modname'])
- 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'] = click.prompt(click.style(
- 'Enter valid argument list, including default arguments: \n',
- fg='cyan'),
- prompt_suffix='',
- default='',
- show_default=False)
-
-def get_py_qa(self):
- """ Get a boolean value for addition of py_qa """
- if self.add_py_qa is None:
- if not (self.info['blocktype'] in ('noblock') or self.skip_subdirs['python']):
- self.add_py_qa = ask_yes_no(click.style('Add Python QA code?', fg='cyan'), True)
- else:
- self.add_py_qa = False
-
-def get_cpp_qa(self):
- """ Get a boolean value for addition of cpp_qa """
- if self.add_cc_qa is None:
- if self.info['lang'] == 'cpp':
- self.add_cc_qa = ask_yes_no(click.style('Add C++ QA code?', fg='cyan'),
- not self.add_py_qa)
- else:
- self.add_cc_qa = False
diff --git a/gr-utils/python/modtool/cli/base.py b/gr-utils/python/modtool/cli/base.py
deleted file mode 100644
index 2462a71d88..0000000000
--- a/gr-utils/python/modtool/cli/base.py
+++ /dev/null
@@ -1,158 +0,0 @@
-#
-# Copyright 2018 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-#
-""" Base CLI module """
-
-from __future__ import print_function
-from __future__ import absolute_import
-from __future__ import unicode_literals
-
-import os
-import sys
-import logging
-import functools
-from importlib import import_module
-from pkg_resources import iter_entry_points
-from logging import Formatter, StreamHandler
-
-import click
-from click import ClickException
-from click_plugins import with_plugins
-
-from gnuradio import gr
-
-
-class ModToolException(ClickException):
- """ Exception class for enhanced CLI interface """
- def show(self, file = None):
- """ displays the colored message """
- click.secho('ModToolException: {}'.format(self.format_message()), fg='red')
-
-
-class CommandCLI(click.Group):
- """
- This is a derived class of the implemented click class
- which overrides some of the functional definitions for external
- plug-in support
- """
- cmd_folder = os.path.abspath(os.path.dirname(__file__))
-
- def list_commands(self, ctx):
- """
- Lists all the commands available in the modtool directory
- as well as the commands from external plug-ins.
- """
- cmds = []
- for filename in os.listdir(self.cmd_folder):
- if filename.endswith('.py') and not '_' in filename:
- cmds.append(filename[:-3])
- cmds.remove('base')
- cmds += self.commands
- return sorted(cmds)
-
- def get_command(self, ctx, cmd_name):
- """
- Returns a command object if it exists. The existing in-tree ModTool
- command is the priority over the same external plug-in command.
- """
- try:
- mod = import_module('gnuradio.modtool.cli.' + cmd_name)
- except ImportError:
- logging.error(ImportError)
- return self.commands.get(cmd_name)
- return mod.cli
-
-
-class ClickHandler(StreamHandler):
- """
- This is a derived class of implemented logging class
- StreamHandler which overrides some of its functional
- definitions to add colors to the stream output
- """
- def emit(self, record):
- """ Writes message to the stream """
- colormap = {
- 'DEBUG': ('white', 'black'),
- 'INFO': ('blue', None),
- 'WARNING': ('yellow', None),
- 'ERROR': ('red', None),
- 'CRITICAL': ('white', 'red'),
- }
- try:
- msg = self.format(record)
- colors = colormap.get(record.levelname, (None, None))
- fgcolor = colors[0]
- bgcolor = colors[1]
- click.secho(msg, fg=fgcolor, bg=bgcolor)
- self.flush()
- except Exception:
- self.handleError(record)
-
-
-def setup_cli_logger(logger):
- """ Sets up logger for CLI parsing """
- try:
- import colorama
- stream_handler = ClickHandler()
- logger.addHandler(stream_handler)
- except ImportError:
- stream_handler = logging.StreamHandler()
- logger.addHandler(stream_handler)
- finally:
- logger.setLevel(logging.INFO)
-
-
-def cli_input(msg):
- """ Returns enhanced input """
- return input(click.style(msg, fg='cyan'))
-
-
-def common_params(func):
- """ Common parameters for various modules"""
- @click.option('-d', '--directory', default='.',
- help="Base directory of the module. Defaults to the cwd.")
- @click.option('--skip-lib', is_flag=True,
- help="Don't do anything in the lib/ subdirectory.")
- @click.option('--skip-swig', is_flag=True,
- help="Don't do anything in the swig/ subdirectory.")
- @click.option('--skip-python', is_flag=True,
- help="Don't do anything in the python/ subdirectory.")
- @click.option('--skip-grc', is_flag=True,
- help="Don't do anything in the grc/ subdirectory.")
- @click.option('--scm-mode', type=click.Choice(['yes', 'no', 'auto']),
- default=gr.prefs().get_string('modtool', 'scm_mode', 'no'),
- help="Use source control management [ yes | no | auto ]).")
- @click.option('-y', '--yes', is_flag=True,
- help="Answer all questions with 'yes'. " +
- "This can overwrite and delete your files, so be careful.")
- @functools.wraps(func)
- def wrapper(*args, **kwargs):
- """ Decorator that wraps common options """
- return func(*args, **kwargs)
- return wrapper
-
-
-block_name = click.argument('blockname', nargs=1, required=False, metavar="BLOCK_NAME")
-
-
-@with_plugins(iter_entry_points('gnuradio.modtool.cli.plugins'))
-@click.command(cls=CommandCLI,
- epilog='Manipulate with GNU Radio modules source code tree. ' +
- 'Call it without options to run specified command interactively')
-def cli():
- """A tool for editing GNU Radio out-of-tree modules."""
- pass
-
-
-def run(module):
- """Call the run function of the core modules."""
- try:
- module.run()
- except ModToolException as err:
- click.echo(err, file=sys.stderr)
- exit(1)
diff --git a/gr-utils/python/modtool/cli/disable.py b/gr-utils/python/modtool/cli/disable.py
deleted file mode 100644
index 87f891e1c3..0000000000
--- a/gr-utils/python/modtool/cli/disable.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Copyright 2018 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-#
-""" Disable blocks module """
-
-from __future__ import print_function
-from __future__ import absolute_import
-from __future__ import unicode_literals
-
-import click
-
-from ..core import get_block_candidates, ModToolDisable
-from ..tools import SequenceCompleter
-from .base import common_params, block_name, run, cli_input
-
-
-@click.command('disable', short_help=ModToolDisable.description)
-@common_params
-@block_name
-def cli(**kwargs):
- """Disable a block (comments out CMake entries for files)"""
- kwargs['cli'] = True
- self = ModToolDisable(**kwargs)
- click.secho("GNU Radio module name identified: " + self.info['modname'], fg='green')
- get_pattern(self)
- run(self)
-
-def get_pattern(self):
- """ Get the regex pattern for block(s) to be disabled """
- if self.info['pattern'] is None:
- block_candidates = get_block_candidates()
- with SequenceCompleter(block_candidates):
- self.info['pattern'] = cli_input('Which blocks do you want to disable? (Regex): ')
- if not self.info['pattern'] or self.info['pattern'].isspace():
- self.info['pattern'] = '.'
diff --git a/gr-utils/python/modtool/cli/info.py b/gr-utils/python/modtool/cli/info.py
deleted file mode 100644
index df7a1f78b6..0000000000
--- a/gr-utils/python/modtool/cli/info.py
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# Copyright 2018 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-#
-""" Returns information about a module """
-
-from __future__ import print_function
-from __future__ import absolute_import
-from __future__ import unicode_literals
-
-import click
-
-from ..core import ModToolInfo
-from .base import common_params, run
-
-
-@click.command('info')
-@click.option('--python-readable', is_flag=True,
- help="Return the output in a format that's easier to read for Python scripts.")
-@click.option('--suggested-dirs',
- help="Suggest typical include dirs if nothing better can be detected.")
-@common_params
-def cli(**kwargs):
- """ Return information about a given module """
- self = ModToolInfo(**kwargs)
- run(self)
diff --git a/gr-utils/python/modtool/cli/makeyaml.py b/gr-utils/python/modtool/cli/makeyaml.py
deleted file mode 100644
index 834cc05a21..0000000000
--- a/gr-utils/python/modtool/cli/makeyaml.py
+++ /dev/null
@@ -1,72 +0,0 @@
-#
-# Copyright 2018 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-#
-""" Automatically create YAML bindings for GRC from block code """
-
-from __future__ import print_function
-from __future__ import absolute_import
-from __future__ import unicode_literals
-
-import os
-import click
-
-try:
- from gnuradio.blocktool import BlockHeaderParser
- from gnuradio.blocktool.core.base import BlockToolException
-except ImportError:
- have_blocktool = False
-else:
- have_blocktool = True
-
-from ..core import get_block_candidates, ModToolMakeYAML, yaml_generator
-from ..tools import SequenceCompleter
-from .base import common_params, block_name, run, cli_input
-
-
-@click.command('makeyaml', short_help=ModToolMakeYAML.description)
-@click.option('-b', '--blocktool', is_flag=True,
- help='Use blocktool support to print yaml output. FILE PATH mandatory if used.')
-@click.option('-o', '--output', is_flag=True,
- help='If given, a file with desired output format will be generated')
-@common_params
-@block_name
-def cli(**kwargs):
- """
- \b
- Make an YAML file for GRC block bindings
-
- Note: This does not work on python blocks
- """
- kwargs['cli'] = True
- if kwargs['blocktool']:
- kwargs['modtool'] = True
- if kwargs['blockname'] is None:
- raise BlockToolException('Missing argument FILE PATH with blocktool flag')
- kwargs['file_path'] = os.path.abspath(kwargs['blockname'])
- if os.path.isfile(kwargs['file_path']):
- parse_yml = BlockHeaderParser(**kwargs)
- parse_yml.run_blocktool()
- parse_yml.cli = True
- parse_yml.yaml = True
- yaml_generator(parse_yml, **kwargs)
- else:
- raise BlockToolException('Invalid file path.')
- else:
- self = ModToolMakeYAML(**kwargs)
- click.secho("GNU Radio module name identified: " + self.info['modname'], fg='green')
- get_pattern(self)
- run(self)
-
-def get_pattern(self):
- """ Get the regex pattern for block(s) to be parsed """
- if self.info['pattern'] is None:
- block_candidates = get_block_candidates()
- with SequenceCompleter(block_candidates):
- self.info['pattern'] = cli_input('Which blocks do you want to parse? (Regex): ')
- if not self.info['pattern'] or self.info['pattern'].isspace():
- self.info['pattern'] = '.'
diff --git a/gr-utils/python/modtool/cli/newmod.py b/gr-utils/python/modtool/cli/newmod.py
deleted file mode 100644
index cdb4b56cfb..0000000000
--- a/gr-utils/python/modtool/cli/newmod.py
+++ /dev/null
@@ -1,58 +0,0 @@
-#
-# Copyright 2018 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-#
-""" Create a whole new out-of-tree module """
-
-from __future__ import print_function
-from __future__ import absolute_import
-from __future__ import unicode_literals
-
-import re
-import os
-
-import click
-
-from gnuradio import gr
-from ..core import ModToolNewModule
-from .base import common_params, run, cli_input, ModToolException
-
-@click.command('newmod', short_help=ModToolNewModule.description)
-@click.option('--srcdir',
- help="Source directory for the module template.")
-@common_params
-@click.argument('module_name', metavar="MODULE-NAME", nargs=1, required=False)
-def cli(**kwargs):
- """
- \b
- Create a new out-of-tree module
-
- The argument MODULE-NAME is the name of the module to be added.
- """
- kwargs['cli'] = True
- self = ModToolNewModule(**kwargs)
- get_modname(self)
- self.dir = os.path.join(self.dir, 'gr-{}'.format(self.info['modname']))
- try:
- os.stat(self.dir)
- except OSError:
- pass # This is what should happen
- else:
- raise ModToolException('The given directory exists.')
- if self.srcdir is None:
- self.srcdir = os.path.join(gr.prefix(),'share','gnuradio','modtool','templates','gr-newmod')
- if not os.path.isdir(self.srcdir):
- raise ModToolException('Could not find gr-newmod source dir.')
- run(self)
-
-def get_modname(self):
- """ Get the name of the new module to be added """
- if self.info['modname'] is None:
- while not self.info['modname'] or self.info['modname'].isspace():
- self.info['modname'] = cli_input('Name of the new module: ')
- if not re.match('[a-zA-Z0-9_]+$', self.info['modname']):
- raise ModToolException('Invalid module name.')
diff --git a/gr-utils/python/modtool/cli/rename.py b/gr-utils/python/modtool/cli/rename.py
deleted file mode 100644
index 86777fa3fb..0000000000
--- a/gr-utils/python/modtool/cli/rename.py
+++ /dev/null
@@ -1,71 +0,0 @@
-#
-# Copyright 2018 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-#
-""" Module to rename blocks """
-
-from __future__ import print_function
-from __future__ import absolute_import
-from __future__ import unicode_literals
-
-import re
-
-import click
-
-from ..core import get_block_candidates, ModToolRename
-from ..tools import SequenceCompleter
-from .base import common_params, block_name, run, cli_input, ModToolException
-
-
-@click.command('rename', short_help=ModToolRename.description)
-@common_params
-@block_name
-@click.argument('new-name', metavar="NEW-BLOCK-NAME", nargs=1, required=False)
-def cli(**kwargs):
- """
- \b
- Rename a block inside a module.
-
- The argument NEW-BLOCK-NAME is the new name of the block.
- """
- kwargs['cli'] = True
- self = ModToolRename(**kwargs)
- click.secho("GNU Radio module name identified: " + self.info['modname'], fg='green')
- # first make sure the old block name is provided
- get_oldname(self)
- click.secho("Block/code to rename identifier: " + self.info['oldname'], fg='green')
- self.info['fulloldname'] = self.info['modname'] + '_' + self.info['oldname']
- # now get the new block name
- get_newname(self)
- click.secho("Block/code identifier: " + self.info['newname'], fg='green')
- self.info['fullnewname'] = self.info['modname'] + '_' + self.info['newname']
- run(self)
-
-def get_oldname(self):
- """ Get the old block name to be replaced """
- block_candidates = get_block_candidates()
- if self.info['oldname'] is None:
- with SequenceCompleter(block_candidates):
- while not self.info['oldname'] or self.info['oldname'].isspace():
- self.info['oldname'] = cli_input("Enter name of block/code to rename "+
- "(without module name prefix): ")
- if self.info['oldname'] not in block_candidates:
- choices = [x for x in block_candidates if self.info['oldname'] in x]
- if len(choices) > 0:
- click.secho("Suggested alternatives: "+str(choices), fg='yellow')
- raise ModToolException("Blockname for renaming does not exists!")
- if not re.match('[a-zA-Z0-9_]+', self.info['oldname']):
- raise ModToolException('Invalid block name.')
-
-def get_newname(self):
- """ Get the new block name """
- if self.info['newname'] is None:
- while not self.info['newname'] or self.info['newname'].isspace():
- self.info['newname'] = cli_input("Enter name of block/code "+
- "(without module name prefix): ")
- if not re.match('[a-zA-Z0-9_]+', self.info['newname']):
- raise ModToolException('Invalid block name.')
diff --git a/gr-utils/python/modtool/cli/rm.py b/gr-utils/python/modtool/cli/rm.py
deleted file mode 100644
index f4447d750a..0000000000
--- a/gr-utils/python/modtool/cli/rm.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Copyright 2018 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-#
-""" Remove blocks module """
-
-from __future__ import print_function
-from __future__ import absolute_import
-from __future__ import unicode_literals
-
-import click
-
-from ..core import get_block_candidates, ModToolRemove
-from ..tools import SequenceCompleter
-from .base import common_params, block_name, run, cli_input
-
-
-@click.command('remove', short_help=ModToolRemove.description)
-@common_params
-@block_name
-def cli(**kwargs):
- """ Remove block (delete files and remove Makefile entries) """
- kwargs['cli'] = True
- self = ModToolRemove(**kwargs)
- click.secho("GNU Radio module name identified: " + self.info['modname'], fg='green')
- get_pattern(self)
- run(self)
-
-def get_pattern(self):
- """ Returns the regex pattern for block(s) to be removed """
- if self.info['pattern'] is None:
- block_candidates = get_block_candidates()
- with SequenceCompleter(block_candidates):
- self.info['pattern'] = cli_input('Which blocks do you want to delete? (Regex): ')
- if not self.info['pattern'] or self.info['pattern'].isspace():
- self.info['pattern'] = '.'
diff --git a/gr-utils/python/modtool/cli/update.py b/gr-utils/python/modtool/cli/update.py
deleted file mode 100644
index 285007e15a..0000000000
--- a/gr-utils/python/modtool/cli/update.py
+++ /dev/null
@@ -1,50 +0,0 @@
-#
-# Copyright 2018 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-#
-""" Module to convert XML bindings to YAML bindings """
-
-from __future__ import print_function
-from __future__ import absolute_import
-from __future__ import unicode_literals
-
-import click
-
-from ..core import get_xml_candidates, ModToolUpdate
-from ..tools import SequenceCompleter
-from .base import block_name, run, cli_input, ModToolException
-
-
-@click.command('update', short_help=ModToolUpdate.description)
-@click.option('--complete', is_flag=True, default=None,
- help="Convert all the XML bindings to YAML.")
-@click.option('-I', '--include-blacklisted', is_flag=True, default=None,
- help="Include XML files with blacklisted names in the conversion process")
-@block_name
-def cli(**kwargs):
- """ Update the XML bindings to YAML bindings """
- kwargs['cli'] = True
- self = ModToolUpdate(**kwargs)
- click.secho("GNU Radio module name identified: " + self.info['modname'], fg='green')
- get_blockname(self)
- run(self)
-
-def get_blockname(self):
- """ Returns the blockname for block to be updated """
- if self.info['complete']:
- return
- block_candidates = get_xml_candidates()
- if self.info['blockname'] is None:
- with SequenceCompleter(block_candidates):
- self.info['blockname'] = cli_input('Which block do you wish to update? : ')
- if not self.info['blockname'] or self.info['blockname'].isspace():
- raise ModToolException('Block name not specified!')
- if self.info['blockname'] not in block_candidates:
- choices = [x for x in block_candidates if self.info['blockname'] in x]
- if len(choices) > 0:
- click.secho("Suggested alternatives: "+str(choices), fg='yellow')
- raise ModToolException("The XML bindings does not exists!")