summaryrefslogtreecommitdiff
path: root/gr-utils/src/python/modtool
diff options
context:
space:
mode:
Diffstat (limited to 'gr-utils/src/python/modtool')
-rw-r--r--gr-utils/src/python/modtool/__init__.py2
-rw-r--r--gr-utils/src/python/modtool/cmakefile_editor.py21
-rw-r--r--gr-utils/src/python/modtool/code_generator.py21
-rw-r--r--gr-utils/src/python/modtool/grc_xml_generator.py21
-rw-r--r--gr-utils/src/python/modtool/modtool_add.py21
-rw-r--r--gr-utils/src/python/modtool/modtool_base.py21
-rw-r--r--gr-utils/src/python/modtool/modtool_disable.py21
-rw-r--r--gr-utils/src/python/modtool/modtool_help.py44
-rw-r--r--gr-utils/src/python/modtool/modtool_info.py21
-rw-r--r--gr-utils/src/python/modtool/modtool_makexml.py21
-rw-r--r--gr-utils/src/python/modtool/modtool_newmod.py23
-rw-r--r--gr-utils/src/python/modtool/modtool_rm.py21
-rw-r--r--gr-utils/src/python/modtool/parser_cc_block.py21
-rw-r--r--gr-utils/src/python/modtool/templates.py22
-rw-r--r--gr-utils/src/python/modtool/util_functions.py21
15 files changed, 284 insertions, 38 deletions
diff --git a/gr-utils/src/python/modtool/__init__.py b/gr-utils/src/python/modtool/__init__.py
index a10747254..7935e4b48 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 b18275707..ed5b71425 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 b727f611e..525b3d1e9 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 2fa61863f..7ccd44319 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 581f3b0aa..a6c84bea8 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 edb0f14ee..d824910e9 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 67f15ad53..b0fb13245 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 a1dd3c466..79474a963 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 80fa27832..e774db911 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 5a1a24f1b..acf3e459c 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 0c69cb69e..7a5f635dd 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 16bfeb34c..bdbd802f3 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 447fe113d..d11353cc7 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 f41049c5a..91d8370b9 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 029ae04bf..33d8ad333 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