summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Cuervo <cuervonicolas@gmail.com>2019-11-14 21:51:43 +0100
committerMartin Braun <martin.braun@ettus.com>2020-01-02 14:26:42 -0800
commita1d8932e3ce36227cb1dc3d41fda189c2d315961 (patch)
tree3505d4a5724466a1cd3d54644d1865639ed64333
parent85239e9f9d44748e1da48c1838be0c7c4beff9e7 (diff)
Modtool: Update - Add option to convert blacklisted files
Also avoid the misleading behavior that implies conversion when it isn't happening while also deleting the XML with a blacklisted name.
-rw-r--r--gr-utils/python/modtool/cli/update.py2
-rw-r--r--gr-utils/python/modtool/core/update.py6
-rw-r--r--grc/converter/main.py11
3 files changed, 14 insertions, 5 deletions
diff --git a/gr-utils/python/modtool/cli/update.py b/gr-utils/python/modtool/cli/update.py
index 509e9daa20..7045750751 100644
--- a/gr-utils/python/modtool/cli/update.py
+++ b/gr-utils/python/modtool/cli/update.py
@@ -34,6 +34,8 @@ 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 """
diff --git a/gr-utils/python/modtool/core/update.py b/gr-utils/python/modtool/core/update.py
index e3bd831989..f1b63f74f4 100644
--- a/gr-utils/python/modtool/core/update.py
+++ b/gr-utils/python/modtool/core/update.py
@@ -52,9 +52,10 @@ class ModToolUpdate(ModTool):
name = 'update'
description = 'Update the grc bindings for a block'
- def __init__(self, blockname=None, complete=False, **kwargs):
+ def __init__(self, blockname=None, complete=False, include_blacklisted=False, **kwargs):
ModTool.__init__(self, blockname, **kwargs)
self.info['complete'] = complete
+ self.info['include_blacklisted'] = include_blacklisted
def validate(self):
@@ -86,7 +87,8 @@ class ModToolUpdate(ModTool):
for blockname in blocks:
xml_file = "{}_{}.xml".format(module_name, blockname)
yml_file = "{}_{}.block.yml".format(module_name, blockname)
- conv.load_block_xml(path+xml_file)
+ if not conv.load_block_xml(path+xml_file, self.info["include_blacklisted"]):
+ continue
logger.info("Converted {} to {}".format(xml_file, yml_file))
os.remove(path+xml_file)
nsubs = self._run_cmakelists(xml_file, yml_file)
diff --git a/grc/converter/main.py b/grc/converter/main.py
index 171f98341b..36c712bbfc 100644
--- a/grc/converter/main.py
+++ b/grc/converter/main.py
@@ -94,10 +94,15 @@ class Converter(object):
with open(self.cache_file, 'w', encoding='utf-8') as cache_file:
json.dump(self.cache, cache_file)
- def load_block_xml(self, xml_file):
+ def load_block_xml(self, xml_file, force=False):
"""Load block description from xml file"""
- if any(part in xml_file for part in excludes):
- return
+ if any(part in xml_file for part in excludes) and not force:
+ logger.warn('Skipping {} because name is blacklisted!'
+ .format(xml_file))
+ return False
+ elif any(part in xml_file for part in excludes) and force:
+ logger.warn('Forcing conversion of blacklisted file: {}'
+ .format(xml_file))
block_id_from_xml = path.basename(xml_file)[:-4]
yml_file = path.join(self.output_dir, block_id_from_xml + '.block.yml')