From 9e625c4821f4c63421b3d3747c0c4f358fef6c5f Mon Sep 17 00:00:00 2001
From: Douglas Anderson <danderson@ntia.doc.gov>
Date: Sun, 12 Feb 2017 15:52:19 -0800
Subject: python3: update non-GRC components to use python2 or python3

---
 gr-utils/python/modtool/modtool_makexml.py | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

(limited to 'gr-utils/python/modtool/modtool_makexml.py')

diff --git a/gr-utils/python/modtool/modtool_makexml.py b/gr-utils/python/modtool/modtool_makexml.py
index 5f53749163..f4c24c7463 100644
--- a/gr-utils/python/modtool/modtool_makexml.py
+++ b/gr-utils/python/modtool/modtool_makexml.py
@@ -20,15 +20,19 @@
 #
 """ 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):
@@ -54,13 +58,13 @@ class ModToolMakeXML(ModTool):
         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): ')
+            self._info['pattern'] = eval(input('Which blocks do you want to parse? (Regex): '))
         if len(self._info['pattern']) == 0:
             self._info['pattern'] = '.'
 
     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']:
@@ -80,12 +84,12 @@ class ModToolMakeXML(ModTool):
         """ Search for files matching pattern in the given path. """
         files = 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 len(files_filt) == 0:
-            print "None found."
+            print("None found.")
         return files_filt
 
     def _make_grc_xml_from_block_data(self, params, iosig, blockname):
@@ -110,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,
@@ -125,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'])
@@ -158,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,
-- 
cgit v1.2.3