From a62f90d8cc96b9dea9289ad6e420d1c0b16f6c36 Mon Sep 17 00:00:00 2001
From: Martin Braun <martin.braun@kit.edu>
Date: Thu, 24 Jan 2013 19:33:03 +0100
Subject: utils: added modtool

---
 gr-utils/src/python/modtool/grc_xml_generator.py | 85 ++++++++++++++++++++++++
 1 file changed, 85 insertions(+)
 create mode 100644 gr-utils/src/python/modtool/grc_xml_generator.py

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

diff --git a/gr-utils/src/python/modtool/grc_xml_generator.py b/gr-utils/src/python/modtool/grc_xml_generator.py
new file mode 100644
index 0000000000..2fa61863f2
--- /dev/null
+++ b/gr-utils/src/python/modtool/grc_xml_generator.py
@@ -0,0 +1,85 @@
+import xml.etree.ElementTree as ET
+from util_functions import is_number, xml_indent
+
+### GRC XML Generator ########################################################
+try:
+    import lxml.etree
+    LXML_IMPORTED = True
+except ImportError:
+    LXML_IMPORTED = False
+
+class GRCXMLGenerator(object):
+    """ Create and write the XML bindings for a GRC block. """
+    def __init__(self, modname=None, blockname=None, doc=None, params=None, iosig=None):
+        """docstring for __init__"""
+        params_list = ['$'+s['key'] for s in params if s['in_constructor']]
+        # Can't make a dict 'cause order matters
+        self._header = (('name', blockname.replace('_', ' ').capitalize()),
+                        ('key', '%s_%s' % (modname, blockname)),
+                        ('category', modname.upper()),
+                        ('import', 'import %s' % modname),
+                        ('make', '%s.%s(%s)' % (modname, blockname, ', '.join(params_list)))
+                       )
+        self.params = params
+        self.iosig = iosig
+        self.doc = doc
+        self.root = None
+        if LXML_IMPORTED:
+            self._prettyprint = self._lxml_prettyprint
+        else:
+            self._prettyprint = self._manual_prettyprint
+
+    def _lxml_prettyprint(self):
+        """ XML pretty printer using lxml """
+        return lxml.etree.tostring(
+                   lxml.etree.fromstring(ET.tostring(self.root, encoding="UTF-8")),
+                   pretty_print=True
+               )
+
+    def _manual_prettyprint(self):
+        """ XML pretty printer using xml_indent """
+        xml_indent(self.root)
+        return ET.tostring(self.root, encoding="UTF-8")
+
+    def make_xml(self):
+        """ Create the actual tag tree """
+        root = ET.Element("block")
+        iosig = self.iosig
+        for tag, value in self._header:
+            this_tag = ET.SubElement(root, tag)
+            this_tag.text = value
+        for param in self.params:
+            param_tag = ET.SubElement(root, 'param')
+            ET.SubElement(param_tag, 'name').text = param['key'].capitalize()
+            ET.SubElement(param_tag, 'key').text = param['key']
+            if len(param['default']):
+                ET.SubElement(param_tag, 'value').text = param['default']
+            ET.SubElement(param_tag, 'type').text = param['type']
+        for inout in sorted(iosig.keys()):
+            if iosig[inout]['max_ports'] == '0':
+                continue
+            for i in range(len(iosig[inout]['type'])):
+                s_tag = ET.SubElement(root, {'in': 'sink', 'out': 'source'}[inout])
+                ET.SubElement(s_tag, 'name').text = inout
+                ET.SubElement(s_tag, 'type').text = iosig[inout]['type'][i]
+                if iosig[inout]['vlen'][i] != '1':
+                    vlen = iosig[inout]['vlen'][i]
+                    if is_number(vlen):
+                        ET.SubElement(s_tag, 'vlen').text = vlen
+                    else:
+                        ET.SubElement(s_tag, 'vlen').text = '$'+vlen
+                if i == len(iosig[inout]['type'])-1:
+                    if not is_number(iosig[inout]['max_ports']):
+                        ET.SubElement(s_tag, 'nports').text = iosig[inout]['max_ports']
+                    elif len(iosig[inout]['type']) < int(iosig[inout]['max_ports']):
+                        ET.SubElement(s_tag, 'nports').text = str(int(iosig[inout]['max_ports']) -
+                                                                  len(iosig[inout]['type'])+1)
+        if self.doc is not None:
+            ET.SubElement(root, 'doc').text = self.doc
+        self.root = root
+
+    def save(self, filename):
+        """ Write the XML file """
+        self.make_xml()
+        open(filename, 'w').write(self._prettyprint())
+
-- 
cgit v1.2.3


From 9ef0f125355a4541c691f18d05ad7ca7b6f7125e Mon Sep 17 00:00:00 2001
From: Martin Braun <martin.braun@kit.edu>
Date: Sun, 27 Jan 2013 16:57:04 +0100
Subject: modtool: added copyleft headers

---
 gr-utils/src/python/modtool/__init__.py          |  2 +-
 gr-utils/src/python/modtool/cmakefile_editor.py  | 21 ++++++++++-
 gr-utils/src/python/modtool/code_generator.py    | 21 ++++++++++-
 gr-utils/src/python/modtool/grc_xml_generator.py | 21 ++++++++++-
 gr-utils/src/python/modtool/modtool_add.py       | 21 ++++++++++-
 gr-utils/src/python/modtool/modtool_base.py      | 21 ++++++++++-
 gr-utils/src/python/modtool/modtool_disable.py   | 21 ++++++++++-
 gr-utils/src/python/modtool/modtool_help.py      | 44 ++++++++++++------------
 gr-utils/src/python/modtool/modtool_info.py      | 21 ++++++++++-
 gr-utils/src/python/modtool/modtool_makexml.py   | 21 ++++++++++-
 gr-utils/src/python/modtool/modtool_newmod.py    | 23 +++++++++++--
 gr-utils/src/python/modtool/modtool_rm.py        | 21 ++++++++++-
 gr-utils/src/python/modtool/parser_cc_block.py   | 21 ++++++++++-
 gr-utils/src/python/modtool/templates.py         | 22 ++++++++++--
 gr-utils/src/python/modtool/util_functions.py    | 21 ++++++++++-
 15 files changed, 284 insertions(+), 38 deletions(-)

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

diff --git a/gr-utils/src/python/modtool/__init__.py b/gr-utils/src/python/modtool/__init__.py
index a107472540..7935e4b482 100644
--- a/gr-utils/src/python/modtool/__init__.py
+++ b/gr-utils/src/python/modtool/__init__.py
@@ -1,5 +1,5 @@
 #
-# Copyright 2012 Free Software Foundation, Inc.
+# Copyright 2013 Free Software Foundation, Inc.
 #
 # This file is part of GNU Radio
 #
diff --git a/gr-utils/src/python/modtool/cmakefile_editor.py b/gr-utils/src/python/modtool/cmakefile_editor.py
index b182757076..ed5b714253 100644
--- a/gr-utils/src/python/modtool/cmakefile_editor.py
+++ b/gr-utils/src/python/modtool/cmakefile_editor.py
@@ -1,8 +1,27 @@
+#
+# Copyright 2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
 """ Edit CMakeLists.txt files """
 
 import re
 
-### CMakeFile.txt editor class ###############################################
 class CMakeFileEditor(object):
     """A tool for editing CMakeLists.txt files. """
     def __init__(self, filename, separator='\n    ', indent='    '):
diff --git a/gr-utils/src/python/modtool/code_generator.py b/gr-utils/src/python/modtool/code_generator.py
index b727f611e5..525b3d1e9a 100644
--- a/gr-utils/src/python/modtool/code_generator.py
+++ b/gr-utils/src/python/modtool/code_generator.py
@@ -1,3 +1,23 @@
+#
+# Copyright 2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
 """ A code generator (needed by ModToolAdd) """
 
 from templates import Templates
@@ -7,7 +27,6 @@ from util_functions import str_to_python_comment
 from util_functions import strip_default_values
 from util_functions import strip_arg_types
 
-### Code generator class #####################################################
 class GRMTemplate(Cheetah.Template.Template):
     """ An extended template class """
     def __init__(self, src, searchList):
diff --git a/gr-utils/src/python/modtool/grc_xml_generator.py b/gr-utils/src/python/modtool/grc_xml_generator.py
index 2fa61863f2..7ccd443196 100644
--- a/gr-utils/src/python/modtool/grc_xml_generator.py
+++ b/gr-utils/src/python/modtool/grc_xml_generator.py
@@ -1,7 +1,26 @@
+#
+# Copyright 2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
 import xml.etree.ElementTree as ET
 from util_functions import is_number, xml_indent
 
-### GRC XML Generator ########################################################
 try:
     import lxml.etree
     LXML_IMPORTED = True
diff --git a/gr-utils/src/python/modtool/modtool_add.py b/gr-utils/src/python/modtool/modtool_add.py
index 581f3b0aaf..a6c84bea85 100644
--- a/gr-utils/src/python/modtool/modtool_add.py
+++ b/gr-utils/src/python/modtool/modtool_add.py
@@ -1,3 +1,23 @@
+#
+# Copyright 2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
 """ Module to add new blocks """
 
 import os
@@ -12,7 +32,6 @@ from templates import Templates
 from code_generator import get_template
 import Cheetah.Template
 
-### Add new block module #####################################################
 class ModToolAdd(ModTool):
     """ Add block to the out-of-tree module. """
     name = 'add'
diff --git a/gr-utils/src/python/modtool/modtool_base.py b/gr-utils/src/python/modtool/modtool_base.py
index edb0f14eed..d824910e95 100644
--- a/gr-utils/src/python/modtool/modtool_base.py
+++ b/gr-utils/src/python/modtool/modtool_base.py
@@ -1,3 +1,23 @@
+#
+# Copyright 2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
 """ Base class for the modules """
 
 import os
@@ -8,7 +28,6 @@ from optparse import OptionParser, OptionGroup
 from util_functions import get_modname
 from templates import Templates
 
-### ModTool base class #######################################################
 class ModTool(object):
     """ Base class for all modtool command classes. """
     def __init__(self):
diff --git a/gr-utils/src/python/modtool/modtool_disable.py b/gr-utils/src/python/modtool/modtool_disable.py
index 67f15ad537..b0fb132451 100644
--- a/gr-utils/src/python/modtool/modtool_disable.py
+++ b/gr-utils/src/python/modtool/modtool_disable.py
@@ -1,3 +1,23 @@
+#
+# Copyright 2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
 """ Disable blocks module """
 
 import os
@@ -8,7 +28,6 @@ from optparse import OptionGroup
 from modtool_base import ModTool
 from cmakefile_editor import CMakeFileEditor
 
-### Disable module ###########################################################
 class ModToolDisable(ModTool):
     """ Disable block (comments out CMake entries for files) """
     name = 'disable'
diff --git a/gr-utils/src/python/modtool/modtool_help.py b/gr-utils/src/python/modtool/modtool_help.py
index a1dd3c4660..79474a9631 100644
--- a/gr-utils/src/python/modtool/modtool_help.py
+++ b/gr-utils/src/python/modtool/modtool_help.py
@@ -1,30 +1,30 @@
+#
+# Copyright 2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
 """ The help module """
 
-from modtool_base import ModTool
-from modtool_info import ModToolInfo
-from modtool_add import ModToolAdd
-from modtool_rm import ModToolRemove
-from modtool_newmod import ModToolNewModule
-from modtool_disable import ModToolDisable
-from modtool_makexml import ModToolMakeXML
-from util_functions import get_command_from_argv
+from gnuradio.modtool import *
+from util_functions import get_command_from_argv, get_class_dict
 from templates import Templates
 
-def get_class_dict():
-    " Return a dictionary of the available commands in the form command->class "
-    classdict = {}
-    for g in globals().values():
-        try:
-            if issubclass(g, ModTool):
-                classdict[g.name] = g
-                for a in g.aliases:
-                    classdict[a] = g
-        except (TypeError, AttributeError):
-            pass
-    return classdict
-
 
-### Help module ##############################################################
 def print_class_descriptions():
     ''' Go through all ModTool* classes and print their name,
         alias and description. '''
diff --git a/gr-utils/src/python/modtool/modtool_info.py b/gr-utils/src/python/modtool/modtool_info.py
index 80fa278321..e774db9114 100644
--- a/gr-utils/src/python/modtool/modtool_info.py
+++ b/gr-utils/src/python/modtool/modtool_info.py
@@ -1,3 +1,23 @@
+#
+# Copyright 2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
 """ Returns information about a module """
 
 import os
@@ -6,7 +26,6 @@ from optparse import OptionGroup
 from modtool_base import ModTool
 from util_functions import get_modname
 
-### Info module ##############################################################
 class ModToolInfo(ModTool):
     """ Return information about a given module """
     name = 'info'
diff --git a/gr-utils/src/python/modtool/modtool_makexml.py b/gr-utils/src/python/modtool/modtool_makexml.py
index 5a1a24f1bb..acf3e459c0 100644
--- a/gr-utils/src/python/modtool/modtool_makexml.py
+++ b/gr-utils/src/python/modtool/modtool_makexml.py
@@ -1,3 +1,23 @@
+#
+# Copyright 2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
 """ Automatically create XML bindings for GRC from block code """
 
 import sys
@@ -11,7 +31,6 @@ from parser_cc_block import ParserCCBlock
 from grc_xml_generator import GRCXMLGenerator
 from cmakefile_editor import CMakeFileEditor
 
-### Remove module ###########################################################
 class ModToolMakeXML(ModTool):
     """ Make XML file for GRC block bindings """
     name = 'makexml'
diff --git a/gr-utils/src/python/modtool/modtool_newmod.py b/gr-utils/src/python/modtool/modtool_newmod.py
index 0c69cb69e8..7a5f635dde 100644
--- a/gr-utils/src/python/modtool/modtool_newmod.py
+++ b/gr-utils/src/python/modtool/modtool_newmod.py
@@ -1,3 +1,23 @@
+#
+# Copyright 2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
 """ Create a whole new out-of-tree module """
 
 import shutil
@@ -6,7 +26,6 @@ import re
 from optparse import OptionGroup
 from modtool_base import ModTool
 
-### New out-of-tree-mod module ###############################################
 class ModToolNewModule(ModTool):
     """ Create a new out-of-tree module """
     name = 'newmod'
@@ -36,7 +55,6 @@ class ModToolNewModule(ModTool):
         self._dir = options.directory
         if self._dir == '.':
             self._dir = './gr-%s' % self._info['modname']
-        print 'Module directory is "%s".' % self._dir
         try:
             os.stat(self._dir)
         except OSError:
@@ -56,6 +74,7 @@ class ModToolNewModule(ModTool):
             shutil.copytree('/home/braun/.usrlocal/share/gnuradio/modtool/gr-newmod', self._dir)
             os.chdir(self._dir)
         except OSError:
+            print 'FAILED'
             print 'Could not create directory %s. Quitting.' % self._dir
             exit(2)
         for root, dirs, files in os.walk('.'):
diff --git a/gr-utils/src/python/modtool/modtool_rm.py b/gr-utils/src/python/modtool/modtool_rm.py
index 16bfeb34ce..bdbd802f33 100644
--- a/gr-utils/src/python/modtool/modtool_rm.py
+++ b/gr-utils/src/python/modtool/modtool_rm.py
@@ -1,3 +1,23 @@
+#
+# Copyright 2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
 """ Remove blocks module """
 
 import os
@@ -10,7 +30,6 @@ from util_functions import remove_pattern_from_file
 from modtool_base import ModTool
 from cmakefile_editor import CMakeFileEditor
 
-### Remove module ###########################################################
 class ModToolRemove(ModTool):
     """ Remove block (delete files and remove Makefile entries) """
     name = 'remove'
diff --git a/gr-utils/src/python/modtool/parser_cc_block.py b/gr-utils/src/python/modtool/parser_cc_block.py
index 447fe113dd..d11353cc7a 100644
--- a/gr-utils/src/python/modtool/parser_cc_block.py
+++ b/gr-utils/src/python/modtool/parser_cc_block.py
@@ -1,8 +1,27 @@
+#
+# Copyright 2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
 ''' A parser for blocks written in C++ '''
 import re
 import sys
 
-### Parser for CC blocks ####################################################
 def dummy_translator(the_type, default_v=None):
     """ Doesn't really translate. """
     return the_type
diff --git a/gr-utils/src/python/modtool/templates.py b/gr-utils/src/python/modtool/templates.py
index f41049c5ae..91d8370b98 100644
--- a/gr-utils/src/python/modtool/templates.py
+++ b/gr-utils/src/python/modtool/templates.py
@@ -1,10 +1,28 @@
+#
+# Copyright 2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
 ''' All the templates for skeleton files (needed by ModToolAdd) '''
 
 from datetime import datetime
 
-### Templates ################################################################
 Templates = {}
-Templates36 = {}
 
 # Default licence
 Templates['defaultlicense'] = '''
diff --git a/gr-utils/src/python/modtool/util_functions.py b/gr-utils/src/python/modtool/util_functions.py
index 029ae04bfa..33d8ad3339 100644
--- a/gr-utils/src/python/modtool/util_functions.py
+++ b/gr-utils/src/python/modtool/util_functions.py
@@ -1,9 +1,28 @@
+#
+# Copyright 2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
 """ Utility functions for gr_modtool.py """
 
 import re
 import sys
 
-### Utility functions ########################################################
 def get_command_from_argv(possible_cmds):
     """ Read the requested command from argv. This can't be done with optparse,
     since the option parser isn't defined before the command is known, and
-- 
cgit v1.2.3