summaryrefslogtreecommitdiff
path: root/gr-utils/python/modtool/modtool_disable.py
diff options
context:
space:
mode:
authorDouglas Anderson <danderson@ntia.doc.gov>2017-02-12 15:52:19 -0800
committerJohnathan Corgan <johnathan@corganlabs.com>2017-02-26 18:21:22 -0800
commit9e625c4821f4c63421b3d3747c0c4f358fef6c5f (patch)
tree41dedbe053417be7314cdce15d64fbbb89db4d8d /gr-utils/python/modtool/modtool_disable.py
parente5aabcc6a4a9335f3ef8abf5f89104b626e9364d (diff)
python3: update non-GRC components to use python2 or python3
Diffstat (limited to 'gr-utils/python/modtool/modtool_disable.py')
-rw-r--r--gr-utils/python/modtool/modtool_disable.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/gr-utils/python/modtool/modtool_disable.py b/gr-utils/python/modtool/modtool_disable.py
index 1772a740f3..629a810cb0 100644
--- a/gr-utils/python/modtool/modtool_disable.py
+++ b/gr-utils/python/modtool/modtool_disable.py
@@ -20,12 +20,16 @@
#
""" Disable blocks module """
+from __future__ import print_function
+from __future__ import absolute_import
+from __future__ import unicode_literals
+
import os
import re
import sys
-from modtool_base import ModTool
-from cmakefile_editor import CMakeFileEditor
+from .modtool_base import ModTool
+from .cmakefile_editor import CMakeFileEditor
class ModToolDisable(ModTool):
@@ -46,7 +50,7 @@ class ModToolDisable(ModTool):
if options.blockname is not None:
self._info['pattern'] = options.blockname
else:
- self._info['pattern'] = raw_input('Which blocks do you want to disable? (Regex): ')
+ self._info['pattern'] = eval(input('Which blocks do you want to disable? (Regex): '))
if len(self._info['pattern']) == 0:
self._info['pattern'] = '.'
@@ -62,7 +66,7 @@ class ModToolDisable(ModTool):
try:
initfile = open(self._file['pyinit']).read()
except IOError:
- print "Could not edit __init__.py, that might be a problem."
+ print("Could not edit __init__.py, that might be a problem.")
return False
pymodname = os.path.splitext(fname)[0]
initfile = re.sub(r'((from|import)\s+\b'+pymodname+r'\b)', r'#\1', initfile)
@@ -93,14 +97,14 @@ class ModToolDisable(ModTool):
self._info['modname'], fname),
r'//\1', swigfile)
if nsubs > 0:
- print "Changing %s..." % self._file['swig']
+ print("Changing %s..." % self._file['swig'])
if nsubs > 1: # Need to find a single BLOCK_MAGIC
blockname = os.path.splitext(fname[len(self._info['modname'])+1:])[0]
if self._info['version'] == '37':
blockname = os.path.splitext(fname)[0]
(swigfile, nsubs) = re.subn('(GR_SWIG_BLOCK_MAGIC2?.+%s.+;)' % blockname, r'//\1', swigfile)
if nsubs > 1:
- print "Hm, changed more then expected while editing %s." % self._file['swig']
+ print("Hm, changed more then expected while editing %s." % self._file['swig'])
open(self._file['swig'], 'w').write(swigfile)
self.scm.mark_file_updated(self._file['swig'])
return False
@@ -112,7 +116,7 @@ class ModToolDisable(ModTool):
if self._info['version'] == '37':
blockname = os.path.splitext(fname)[0]
swigfile = re.sub('(%include\s+"'+fname+'")', r'//\1', swigfile)
- print "Changing %s..." % self._file['swig']
+ print("Changing %s..." % self._file['swig'])
swigfile = re.sub('(GR_SWIG_BLOCK_MAGIC2?.+'+blockname+'.+;)', r'//\1', swigfile)
open(self._file['swig'], 'w').write(swigfile)
self.scm.mark_file_updated(self._file['swig'])
@@ -135,13 +139,13 @@ class ModToolDisable(ModTool):
cmake = CMakeFileEditor(os.path.join(subdir, 'CMakeLists.txt'))
except IOError:
continue
- print "Traversing %s..." % subdir
+ print("Traversing %s..." % subdir)
filenames = cmake.find_filenames_match(self._info['pattern'])
yes = self._info['yes']
for fname in filenames:
file_disabled = False
if not yes:
- ans = raw_input("Really disable %s? [Y/n/a/q]: " % fname).lower().strip()
+ ans = input("Really disable %s? [Y/n/a/q]: " % fname).lower().strip()
if ans == 'a':
yes = True
if ans == 'q':
@@ -155,5 +159,5 @@ class ModToolDisable(ModTool):
cmake.disable_file(fname)
cmake.write()
self.scm.mark_files_updated((os.path.join(subdir, 'CMakeLists.txt'),))
- print "Careful: 'gr_modtool disable' does not resolve dependencies."
+ print("Careful: 'gr_modtool disable' does not resolve dependencies.")