summaryrefslogtreecommitdiff
path: root/gr-utils/python/modtool/modtool_makexml.py
diff options
context:
space:
mode:
authorMarcus Müller <marcus@hostalia.de>2018-08-31 23:02:22 +0200
committerMarcus Müller <marcus@hostalia.de>2018-08-31 23:02:22 +0200
commit254fe5e89403d4de1fa6663d09efdf946996aff3 (patch)
tree62877d7ac7fdedf6c397c51e22ac6f97eba97ddf /gr-utils/python/modtool/modtool_makexml.py
parent896d1c9da31963ecf5b0d90942c2af51ca998a69 (diff)
parent5ad935c3a3dd46ce2860b13e2b774e4841784616 (diff)
Merge remote-tracking branch 'origin/next' into merge_next
Diffstat (limited to 'gr-utils/python/modtool/modtool_makexml.py')
-rw-r--r--gr-utils/python/modtool/modtool_makexml.py57
1 files changed, 30 insertions, 27 deletions
diff --git a/gr-utils/python/modtool/modtool_makexml.py b/gr-utils/python/modtool/modtool_makexml.py
index c45759c605..90308d1b14 100644
--- a/gr-utils/python/modtool/modtool_makexml.py
+++ b/gr-utils/python/modtool/modtool_makexml.py
@@ -20,49 +20,52 @@
#
""" Automatically create XML bindings for GRC from block code """
+from __future__ import print_function
+from __future__ import absolute_import
+from __future__ import unicode_literals
+
import os
import re
import glob
-from modtool_base import ModTool, ModToolException
-from parser_cc_block import ParserCCBlock
-from grc_xml_generator import GRCXMLGenerator
-from cmakefile_editor import CMakeFileEditor
-from util_functions import ask_yes_no
+from .modtool_base import ModTool, ModToolException
+from .parser_cc_block import ParserCCBlock
+from .grc_xml_generator import GRCXMLGenerator
+from .cmakefile_editor import CMakeFileEditor
+from .util_functions import ask_yes_no
class ModToolMakeXML(ModTool):
""" Make XML file for GRC block bindings """
name = 'makexml'
- aliases = ('mx',)
+ description = 'Generate XML files for GRC block bindings.'
def __init__(self):
ModTool.__init__(self)
- def setup_parser(self):
+ @staticmethod
+ def setup_parser(parser):
""" Initialise the option parser for 'gr_modtool makexml' """
- parser = ModTool.setup_parser(self)
- parser.usage = """%prog info [options]. \n Call %prog without any options to run it interactively.
+ parser.usage = """%s
Note: This does not work on Python blocks!
- """
- return parser
+ """ % parser.usage
+ ModTool.setup_parser_block(parser)
- def setup(self, options, args):
- ModTool.setup(self, options, args)
+ def setup(self, options):
+ ModTool.setup(self, options)
- if options.block_name is not None:
- self._info['pattern'] = options.block_name
- elif len(args) >= 2:
- self._info['pattern'] = args[1]
+ if options.blockname is not None:
+ self._info['pattern'] = options.blockname
else:
- self._info['pattern'] = raw_input('Which blocks do you want to parse? (Regex): ')
- if not self._info['pattern'] or self._info['pattern'].isspace():
+ self._info['pattern'] = input('Which blocks do you want to parse? (Regex): ')
+ if len(self._info['pattern']) == 0:
self._info['pattern'] = '.'
- def run(self):
+ def run(self, options):
""" Go, go, go! """
- print "Warning: This is an experimental feature. Don't expect any magic."
+ print("Warning: This is an experimental feature. Don't expect any magic.")
+ self.setup(options)
# 1) Go through lib/
if not self._skip_subdirs['lib']:
if self._info['version'] == '37':
@@ -81,12 +84,12 @@ class ModToolMakeXML(ModTool):
""" Search for files matching pattern in the given path. """
files = sorted(glob.glob("%s/%s"% (path, path_glob)))
files_filt = []
- print "Searching for matching files in %s/:" % path
+ print("Searching for matching files in %s/:" % path)
for f in files:
if re.search(self._info['pattern'], os.path.basename(f)) is not None:
files_filt.append(f)
- if not files_filt:
- print "None found."
+ if len(files_filt) == 0:
+ print("None found.")
return files_filt
def _make_grc_xml_from_block_data(self, params, iosig, blockname):
@@ -111,7 +114,7 @@ class ModToolMakeXML(ModTool):
return
else:
file_exists = True
- print "Warning: Overwriting existing GRC file."
+ print("Warning: Overwriting existing GRC file.")
grc_generator = GRCXMLGenerator(
modname=self._info['modname'],
blockname=blockname,
@@ -126,7 +129,7 @@ class ModToolMakeXML(ModTool):
if not self._skip_subdirs['grc']:
ed = CMakeFileEditor(self._file['cmgrc'])
if re.search(fname_xml, ed.cfile) is None and not ed.check_for_glob('*.xml'):
- print "Adding GRC bindings to grc/CMakeLists.txt..."
+ print("Adding GRC bindings to grc/CMakeLists.txt...")
ed.append_value('install', fname_xml, to_ignore_end='DESTINATION[^()]+')
ed.write()
self.scm.mark_files_updated(self._file['cmgrc'])
@@ -159,7 +162,7 @@ class ModToolMakeXML(ModTool):
blockname = blockname.replace(self._info['modname']+'_', '', 1)
return (blockname, fname_h)
# Go, go, go
- print "Making GRC bindings for %s..." % fname_cc
+ print("Making GRC bindings for %s..." % fname_cc)
(blockname, fname_h) = _get_blockdata(fname_cc)
try:
parser = ParserCCBlock(fname_cc,