summaryrefslogtreecommitdiff
path: root/gr-utils/src/python/modtool/modtool_newmod.py
diff options
context:
space:
mode:
Diffstat (limited to 'gr-utils/src/python/modtool/modtool_newmod.py')
-rw-r--r--gr-utils/src/python/modtool/modtool_newmod.py28
1 files changed, 7 insertions, 21 deletions
diff --git a/gr-utils/src/python/modtool/modtool_newmod.py b/gr-utils/src/python/modtool/modtool_newmod.py
index 730b72e39..9b2dc6e30 100644
--- a/gr-utils/src/python/modtool/modtool_newmod.py
+++ b/gr-utils/src/python/modtool/modtool_newmod.py
@@ -1,14 +1,10 @@
""" Create a whole new out-of-tree module """
+import shutil
import os
import re
-import sys
-import base64
-import tarfile
from optparse import OptionGroup
-
from modtool_base import ModTool
-from newmod_tarfile import NEWMOD_TARFILE
### New out-of-tree-mod module ###############################################
class ModToolNewModule(ModTool):
@@ -36,7 +32,7 @@ class ModToolNewModule(ModTool):
self._info['modname'] = raw_input('Name of the new module: ')
if not re.match('[a-zA-Z0-9_]+', self._info['modname']):
print 'Invalid module name.'
- sys.exit(2)
+ exit(2)
self._dir = options.directory
if self._dir == '.':
self._dir = './gr-%s' % self._info['modname']
@@ -47,30 +43,21 @@ class ModToolNewModule(ModTool):
pass # This is what should happen
else:
print 'The given directory exists.'
- sys.exit(2)
+ exit(2)
def run(self):
"""
- * Unpack the tar.bz2 to the new locations
- * Remove the bz2
+ * Copy the example dir recursively
* Open all files, rename howto and HOWTO to the module name
* Rename files and directories that contain the word howto
"""
- print "Creating directory..."
+ print "Creating out-of-tree module in %s..." % self._dir
try:
- os.mkdir(self._dir)
+ shutil.copytree('/home/braun/.usrlocal/share/gnuradio/modtool/gr-newmod', self._dir)
os.chdir(self._dir)
except OSError:
print 'Could not create directory %s. Quitting.' % self._dir
- sys.exit(2)
- print "Copying howto example..."
- open('tmp.tar.bz2', 'wb').write(base64.b64decode(NEWMOD_TARFILE))
- print "Unpacking..."
- tar = tarfile.open('tmp.tar.bz2', mode='r:bz2')
- tar.extractall()
- tar.close()
- os.unlink('tmp.tar.bz2')
- print "Replacing occurences of 'howto' to '%s'..." % self._info['modname'],
+ exit(2)
for root, dirs, files in os.walk('.'):
for filename in files:
f = os.path.join(root, filename)
@@ -85,4 +72,3 @@ class ModToolNewModule(ModTool):
print "Done."
print "Use 'gr_modtool add' to add a new block to this currently empty module."
-