示例#1
0
    def setup(self, options, args):
        ModTool.setup(self, options, args)

        if ((self._skip_subdirs['lib'] and self._info['lang'] == 'cpp') or
            (self._skip_subdirs['python'] and self._info['lang'] == 'python')):
            raise ModToolException('Missing or skipping relevant subdir.')

        # first make sure the old block name is provided
        self._info['oldname'] = options.old_name
        if self._info['oldname'] is None:
            if len(args) >= 2:
                self._info['oldname'] = args[1]
            else:
                self._info['oldname'] = raw_input(
                    "Enter name of block/code to rename (without module name prefix): "
                )
        if not re.match('[a-zA-Z0-9_]+', self._info['oldname']):
            raise ModToolException('Invalid block name.')
        print "Block/code to rename identifier: " + self._info['oldname']
        self._info['fulloldname'] = self._info['modname'] + '_' + self._info[
            'oldname']

        # now get the new block name
        self._info['newname'] = options.new_name
        if self._info['newname'] is None:
            if len(args) >= 2:
                self._info['newname'] = args[2]
            else:
                self._info['newname'] = raw_input(
                    "Enter name of block/code (without module name prefix): ")
        if not re.match('[a-zA-Z0-9_]+', self._info['newname']):
            raise ModToolException('Invalid block name.')
        print "Block/code identifier: " + self._info['newname']
        self._info['fullnewname'] = self._info['modname'] + '_' + self._info[
            'newname']
示例#2
0
    def setup(self, options, args):
        ModTool.setup(self, options, args)

        if ((self._skip_subdirs['lib'] and self._info['lang'] == 'cpp')
             or (self._skip_subdirs['python'] and self._info['lang'] == 'python')):
            raise ModToolException('Missing or skipping relevant subdir.')

        # first make sure the old block name is provided
        self._info['oldname'] = options.old_name
        if self._info['oldname'] is None:
            if len(args) >= 2:
                self._info['oldname'] = args[1]
            else:
                self._info['oldname'] = raw_input("Enter name of block/code to rename (without module name prefix): ")
        if not re.match('[a-zA-Z0-9_]+', self._info['oldname']):
            raise ModToolException('Invalid block name.')
        print "Block/code to rename identifier: " + self._info['oldname']
        self._info['fulloldname'] = self._info['modname'] + '_' + self._info['oldname']

        # now get the new block name
        self._info['newname'] = options.new_name
        if self._info['newname'] is None:
            if len(args) >= 2:
                self._info['newname'] = args[2]
            else:
                self._info['newname'] = raw_input("Enter name of block/code (without module name prefix): ")
        if not re.match('[a-zA-Z0-9_]+', self._info['newname']):
            raise ModToolException('Invalid block name.')
        print "Block/code identifier: " + self._info['newname']
        self._info['fullnewname'] = self._info['modname'] + '_' + self._info['newname']
示例#3
0
    def setup(self, options, args):
        ModTool.setup(self, options, args)

        self._info['blocktype'] = options.block_type
        if self._info['blocktype'] is None:
            # Print list out of blocktypes to user for reference
            print str(self._block_types)
            while self._info['blocktype'] not in self._block_types:
                self._info['blocktype'] = raw_input("Enter block type: ")
                if self._info['blocktype'] not in self._block_types:
                    print 'Must be one of ' + str(self._block_types)
        # Allow user to specify language interactively if not set
        self._info['lang'] = options.lang
        if self._info['lang'] is None:
            while self._info['lang'] not in ['cpp', 'python']:
                self._info['lang'] = raw_input("Language (python/cpp): ")
        if self._info['lang'] == 'c++':
            self._info['lang'] = 'cpp'

        print "Language: %s" % {'cpp': 'C++', 'python': 'Python'}[self._info['lang']]

        if ((self._skip_subdirs['lib'] and self._info['lang'] == 'cpp')
             or (self._skip_subdirs['python'] and self._info['lang'] == 'python')):
            raise ModToolException('Missing or skipping relevant subdir.')

        if self._info['blockname'] is None:
            if len(args) >= 2:
                self._info['blockname'] = args[1]
            else:
                self._info['blockname'] = raw_input("Enter name of block/code (without module name prefix): ")
        if not re.match('[a-zA-Z0-9_]+', self._info['blockname']):
            raise ModToolException('Invalid block name.')
        print "Block/code identifier: " + self._info['blockname']
        self._info['fullblockname'] = self._info['modname'] + '_' + self._info['blockname']
        if not options.license_file:
            self._info['copyrightholder'] = options.copyright
            if self._info['copyrightholder'] is None:
                self._info['copyrightholder'] = '<+YOU OR YOUR COMPANY+>'
            elif self._info['is_component']:
                print "For GNU Radio components the FSF is added as copyright holder"
        self._license_file = options.license_file
        self._info['license'] = self.setup_choose_license()
        if options.argument_list is not None:
            self._info['arglist'] = options.argument_list
        else:
            self._info['arglist'] = raw_input('Enter valid argument list, including default arguments: ')

        if not (self._info['blocktype'] in ('noblock') or self._skip_subdirs['python']):
            self._add_py_qa = options.add_python_qa
            if self._add_py_qa is None:
                self._add_py_qa = ask_yes_no('Add Python QA code?', True)
        if self._info['lang'] == 'cpp':
            self._add_cc_qa = options.add_cpp_qa
            if self._add_cc_qa is None:
                self._add_cc_qa = ask_yes_no('Add C++ QA code?', not self._add_py_qa)
        self._skip_cmakefiles = options.skip_cmakefiles
        if self._info['version'] == 'autofoo' and not self._skip_cmakefiles:
            print "Warning: Autotools modules are not supported. ",
            print "Files will be created, but Makefiles will not be edited."
            self._skip_cmakefiles = True
示例#4
0
 def __init__(self):
     ModTool.__init__(self)
     self._add_cc_qa = False
     self._add_py_qa = False
     self._skip_cmakefiles = False
     self._skip_block_ctrl = False
     self._skip_block_interface = False
     self._license_file = None
示例#5
0
    def setup(self):
        ModTool.setup(self)
        options = self.options
        self._info['blocktype'] = options.block_type
        if self._info['blocktype'] is None:
            while self._info['blocktype'] not in self._block_types:
                self._info['blocktype'] = raw_input("Enter code type: ")
                if self._info['blocktype'] not in self._block_types:
                    print 'Must be one of ' + str(self._block_types)
        self._info['lang'] = options.lang
        if self._info['lang'] == 'c++':
            self._info['lang'] = 'cpp'
        print "Language: %s" % {
            'cpp': 'C++',
            'python': 'Python'
        }[self._info['lang']]

        if ((self._skip_subdirs['lib'] and self._info['lang'] == 'cpp') or
            (self._skip_subdirs['python'] and self._info['lang'] == 'python')):
            print "Missing or skipping relevant subdir."
            exit(1)

        if self._info['blockname'] is None:
            if len(self.args) >= 2:
                self._info['blockname'] = self.args[1]
            else:
                self._info['blockname'] = raw_input(
                    "Enter name of block/code (without module name prefix): ")
        if not re.match('[a-zA-Z0-9_]+', self._info['blockname']):
            print 'Invalid block name.'
            exit(2)
        print "Block/code identifier: " + self._info['blockname']
        self._info['fullblockname'] = self._info['modname'] + '_' + self._info[
            'blockname']
        self._info['license'] = self.setup_choose_license()

        if options.argument_list is not None:
            self._info['arglist'] = options.argument_list
        else:
            self._info['arglist'] = raw_input(
                'Enter valid argument list, including default arguments: ')

        if not (self._info['blocktype'] in ('noblock')
                or self._skip_subdirs['python']):
            self._add_py_qa = options.add_python_qa
            if self._add_py_qa is None:
                self._add_py_qa = ask_yes_no('Add Python QA code?', True)
        if self._info['lang'] == 'cpp':
            self._add_cc_qa = options.add_cpp_qa
            if self._add_cc_qa is None:
                self._add_cc_qa = ask_yes_no('Add C++ QA code?',
                                             not self._add_py_qa)
        if self._info[
                'version'] == 'autofoo' and not self.options.skip_cmakefiles:
            print "Warning: Autotools modules are not supported. ",
            print "Files will be created, but Makefiles will not be edited."
            self.options.skip_cmakefiles = True
示例#6
0
 def setup(self):
     ModTool.setup(self)
     options = self.options
     if options.block_name is not None:
         self._info['pattern'] = options.block_name
     elif len(self.args) >= 2:
         self._info['pattern'] = self.args[1]
     else:
         self._info['pattern'] = raw_input('Which blocks do you want to disable? (Regex): ')
     if len(self._info['pattern']) == 0:
         self._info['pattern'] = '.'
示例#7
0
    def setup(self, options, args):
        ModTool.setup(self, options, args)

        if options.block_name is not None:
            self._info['pattern'] = options.block_name
        elif len(args) >= 2:
            self._info['pattern'] = args[1]
        else:
            self._info['pattern'] = raw_input('Which blocks do you want to parse? (Regex): ')
        if not self._info['pattern'] or self._info['pattern'].isspace():
            self._info['pattern'] = '.'
示例#8
0
    def setup(self, options, args):
        ModTool.setup(self, options, args)

        if options.block_name is not None:
            self._info["pattern"] = options.block_name
        elif len(args) >= 2:
            self._info["pattern"] = args[1]
        else:
            self._info["pattern"] = raw_input("Which blocks do you want to disable? (Regex): ")
        if len(self._info["pattern"]) == 0:
            self._info["pattern"] = "."
示例#9
0
    def setup(self):
        ModTool.setup(self)
        options = self.options
        self._info['blocktype'] = options.block_type
        if self._info['blocktype'] is None:
            while self._info['blocktype'] not in self._block_types:
                self._info['blocktype'] = raw_input("Enter code type: ")
                if self._info['blocktype'] not in self._block_types:
                    print 'Must be one of ' + str(self._block_types)
        print "Code is of type: " + self._info['blocktype']

        if (not self._has_subdirs['lib'] and self._info['blocktype'] != 'hierpython') or \
           (not self._has_subdirs['python'] and self._info['blocktype'] == 'hierpython'):
            print "Can't do anything if the relevant subdir is missing. See ya."
            sys.exit(1)

        if self._info['blockname'] is None:
            if len(self.args) >= 2:
                self._info['blockname'] = self.args[1]
            else:
                self._info['blockname'] = raw_input("Enter name of block/code (without module name prefix): ")
        if not re.match('[a-zA-Z0-9_]+', self._info['blockname']):
            print 'Invalid block name.'
            sys.exit(2)
        print "Block/code identifier: " + self._info['blockname']

        self._info['prefix'] = self._info['modname']
        if self._info['blocktype'] == 'impl':
            self._info['prefix'] += 'i'
        self._info['fullblockname'] = self._info['prefix'] + '_' + self._info['blockname']
        print "Full block/code identifier is: " + self._info['fullblockname']

        self._info['license'] = self.setup_choose_license()

        if options.argument_list is not None:
            self._info['arglist'] = options.argument_list
        else:
            self._info['arglist'] = raw_input('Enter valid argument list, including default arguments: ')

        if not (self._info['blocktype'] in ('impl') or self._skip_subdirs['python']):
            self._add_py_qa = options.add_python_qa
            if self._add_py_qa is None:
                self._add_py_qa = (raw_input('Add Python QA code? [Y/n] ').lower() != 'n')
        if not (self._info['blocktype'] in ('hierpython') or self._skip_subdirs['lib']):
            self._add_cc_qa = options.add_cpp_qa
            if self._add_cc_qa is None:
                self._add_cc_qa = (raw_input('Add C++ QA code? [Y/n] ').lower() != 'n')

        if self._info['blocktype'] == 'source':
            self._info['inputsig'] = "0, 0, 0"
            self._info['blocktype'] = "sync"
        if self._info['blocktype'] == 'sink':
            self._info['outputsig'] = "0, 0, 0"
            self._info['blocktype'] = "sync"
示例#10
0
    def setup(self, options, args):
        ModTool.setup(self, options, args)

        if options.block_name is not None:
            self._info['pattern'] = options.block_name
        elif len(args) >= 2:
            self._info['pattern'] = args[1]
        else:
            self._info['pattern'] = raw_input('Which blocks do you want to delete? (Regex): ')
        if len(self._info['pattern']) == 0:
            self._info['pattern'] = '.'
示例#11
0
    def setup(self, options, args):
        ModTool.setup(self, options, args)

        if options.block_name is not None:
            self._info['pattern'] = options.block_name
        elif len(args) >= 2:
            self._info['pattern'] = args[1]
        else:
            self._info['pattern'] = raw_input('Which blocks do you want to parse? (Regex): ')
        if len(self._info['pattern']) == 0:
            self._info['pattern'] = '.'
示例#12
0
 def setup(self):
     ModTool.setup(self)
     options = self.options
     if options.block_name is not None:
         self._info['pattern'] = options.block_name
     elif len(self.args) >= 2:
         self._info['pattern'] = self.args[1]
     else:
         self._info['pattern'] = raw_input(
             'Which blocks do you want to delete? (Regex): ')
     if len(self._info['pattern']) == 0:
         self._info['pattern'] = '.'
示例#13
0
    def setup(self, options, args):
        ModTool.setup(self, options, args)

        if options.block_name is not None:
            self._info['pattern'] = options.block_name
        elif len(args) >= 2:
            self._info['pattern'] = args[1]
        else:
            with SequenceCompleter():
                self._info['pattern'] = raw_input('Which blocks do you want to delete? (Regex): ')
        if not self._info['pattern'] or self._info['pattern'].isspace():
            self._info['pattern'] = '.'
示例#14
0
    def setup(self, options, args):
        ModTool.setup(self, options, args)
        self._info['blocktype'] = 'rfnoc'
        self._info['lang'] = 'cpp'
        if (self._skip_subdirs['lib']) or (self._skip_subdirs['python']):
            raise ModToolException('Missing or skipping relevant subdir.')
        if self._info['blockname'] is None:
            if len(args) >= 2:
                self._info['blockname'] = args[1]
            else:
                self._info['blockname'] = raw_input("Enter name of block/code (without module name prefix): ")
        if not re.match('^([a-zA-Z]+[0-9a-zA-Z]*)$', self._info['blockname']):
            raise ModToolException('Invalid block name.')
        print("Block/code identifier: " + self._info['blockname'])
        self._info['fullblockname'] = self._info['modname'] + '_' + self._info['blockname']
        if not options.license_file:
            self._info['copyrightholder'] = options.copyright
            if self._info['copyrightholder'] is None:
                self._info['copyrightholder'] = '<+YOU OR YOUR COMPANY+>'
            elif self._info['is_component']:
                print("For GNU Radio components the FSF is added as copyright holder")
        self._license_file = options.license_file
        self._info['license'] = self.setup_choose_license()
        if options.argument_list is not None:
            self._info['arglist'] = options.argument_list
        else:
            self._info['arglist'] = raw_input('Enter valid argument list, including default arguments: ')

        if not (self._info['blocktype'] in ('noblock') or self._skip_subdirs['python']):
            self._add_py_qa = options.add_python_qa
            if self._add_py_qa is None:
                self._add_py_qa = ask_yes_no('Add Python QA code?', True)
        self._add_cc_qa = options.add_cpp_qa
        if self._add_cc_qa is None:
            self._add_cc_qa = ask_yes_no('Add C++ QA code?', not self._add_py_qa)
        self._skip_cmakefiles = options.skip_cmakefiles
        if self._info['version'] == 'autofoo' and not self._skip_cmakefiles:
            print("Warning: Autotools modules are not supported. ",)
            print("Files will be created, but Makefiles will not be edited.")
            self._skip_cmakefiles = True
        #NOC ID parse
        self._info['noc_id'] = options.noc_id
        if self._info['noc_id'] is None:
            self._info['noc_id'] = id_process(raw_input("Block NoC ID (Hexadecimal): "))
        if not re.match(r'\A[0-9A-F]+\Z', self._info['noc_id']):
            raise ModToolException('Invalid NoC ID - Only Hexadecimal Values accepted.')
        self._skip_block_ctrl = options.skip_block_ctrl
        if self._skip_block_ctrl is None:
            self._skip_block_ctrl = ask_yes_no('Skip Block Controllers Generation? [UHD block ctrl files]', False)
        self._skip_block_interface = options.skip_block_interface
        if self._skip_block_interface is None:
            self._skip_block_interface = ask_yes_no('Skip Block interface files Generation? [GRC block ctrl files]', False)
示例#15
0
    def setup(self, options, args):
        ModTool.setup(self, options, args)

        if options.block_name is not None:
            self._info['pattern'] = options.block_name
        elif len(args) >= 2:
            self._info['pattern'] = args[1]
        else:
            block_candidates = self.get_block_candidates()
            with SequenceCompleter(block_candidates):
                self._info['pattern'] = raw_input('Which blocks do you want to delete? (Regex): ')
        if not self._info['pattern'] or self._info['pattern'].isspace():
            self._info['pattern'] = '.'
示例#16
0
    def setup(self):
        ModTool.setup(self)
        options = self.options
        self._info['blocktype'] = options.block_type
        if self._info['blocktype'] is None:
            while self._info['blocktype'] not in self._block_types:
                self._info['blocktype'] = raw_input("Enter code type: ")
                if self._info['blocktype'] not in self._block_types:
                    print 'Must be one of ' + str(self._block_types)
        self._info['lang'] = options.lang
        if self._info['lang'] == 'c++':
            self._info['lang'] = 'cpp'
        print "Language: %s" % {'cpp': 'C++', 'python': 'Python'}[self._info['lang']]

        if ((self._skip_subdirs['lib'] and self._info['lang'] == 'cpp')
             or (self._skip_subdirs['python'] and self._info['lang'] == 'python')):
            print "Missing or skipping relevant subdir."
            exit(1)

        if self._info['blockname'] is None:
            if len(self.args) >= 2:
                self._info['blockname'] = self.args[1]
            else:
                self._info['blockname'] = raw_input("Enter name of block/code (without module name prefix): ")
        if not re.match('[a-zA-Z0-9_]+', self._info['blockname']):
            print 'Invalid block name.'
            exit(2)
        print "Block/code identifier: " + self._info['blockname']
        self._info['fullblockname'] = self._info['modname'] + '_' + self._info['blockname']
        self._info['license'] = self.setup_choose_license()

        if options.argument_list is not None:
            self._info['arglist'] = options.argument_list
        else:
            self._info['arglist'] = raw_input('Enter valid argument list, including default arguments: ')

        if not (self._info['blocktype'] in ('noblock') or self._skip_subdirs['python']):
            self._add_py_qa = options.add_python_qa
            if self._add_py_qa is None:
                self._add_py_qa = ask_yes_no('Add Python QA code?', True)
        if self._info['lang'] == 'cpp':
            self._add_cc_qa = options.add_cpp_qa
            if self._add_cc_qa is None:
                self._add_cc_qa = ask_yes_no('Add C++ QA code?', not self._add_py_qa)
        if self._info['version'] == 'autofoo' and not self.options.skip_cmakefiles:
            print "Warning: Autotools modules are not supported. ",
            print "Files will be created, but Makefiles will not be edited."
            self.options.skip_cmakefiles = True
示例#17
0
 def setup_parser(self):
     parser = ModTool.setup_parser(self)
     ogroup = OptionGroup(parser, "Rename module options")
     ogroup.add_option("-o", "--old-name", type="string", default=None, help="Current name of the block to rename.")
     ogroup.add_option("-u", "--new-name", type="string", default=None, help="New name of the block.")
     parser.add_option_group(ogroup)
     return parser
示例#18
0
 def setup_parser(self):
     parser = ModTool.setup_parser(self)
     ogroup = OptionGroup(parser, "Rename module options")
     ogroup.add_option("-o", "--old-name", type="string", default=None, help="Current name of the block to rename.")
     ogroup.add_option("-u", "--new-name", type="string", default=None, help="New name of the block.")
     parser.add_option_group(ogroup)
     return parser
示例#19
0
 def setup_parser(self):
     " Initialise the option parser for 'gr_modtool.py newmod' "
     parser = ModTool.setup_parser(self)
     #parser.usage = '%prog rm [options]. \n Call %prog without any options to run it interactively.'
     #ogroup = OptionGroup(parser, "New out-of-tree module options")
     #parser.add_option_group(ogroup)
     return parser
示例#20
0
    def setup_parser(self):
        """ Initialise the option parser for 'gr_modtool makexml' """
        parser = ModTool.setup_parser(self)
        parser.usage = """%prog info [options]. \n Call %prog without any options to run it interactively.

        Note: This does not work on Python blocks!
        """
        return parser
示例#21
0
    def setup_parser(self):
        """ Initialise the option parser for 'gr_modtool makexml' """
        parser = ModTool.setup_parser(self)
        parser.usage = """%prog info [options]. \n Call %prog without any options to run it interactively.

        Note: This does not work on Python blocks!
        """
        return parser
示例#22
0
 def setup_parser(self):
     " Initialise the option parser for 'gr_modtool newmod' "
     parser = ModTool.setup_parser(self)
     parser.usage = '%prog nm [options]. \n Call %prog without any options to run it interactively.'
     ogroup = OptionGroup(parser, "New out-of-tree module options")
     ogroup.add_option("--srcdir", type="string",
             help="Source directory for the module template.")
     parser.add_option_group(ogroup)
     return parser
示例#23
0
 def setup_parser(self):
     " Initialise the option parser for 'gr_modtool newmod' "
     parser = ModTool.setup_parser(self)
     parser.usage = '%prog nm [options]. \n Call %prog without any options to run it interactively.'
     ogroup = OptionGroup(parser, "New out-of-tree module options")
     ogroup.add_option("--srcdir",
                       type="string",
                       help="Source directory for the module template.")
     parser.add_option_group(ogroup)
     return parser
示例#24
0
 def setup_parser(self):
     " Initialise the option parser for 'gr_modtool.py rm' "
     parser = ModTool.setup_parser(self)
     parser.usage = '%prog rm [options]. \n Call %prog without any options to run it interactively.'
     ogroup = OptionGroup(parser, "Remove module options")
     ogroup.add_option("-p", "--pattern", type="string", default=None,
             help="Filter possible choices for blocks to be deleted.")
     ogroup.add_option("-y", "--yes", action="store_true", default=False,
             help="Answer all questions with 'yes'.")
     parser.add_option_group(ogroup)
     return parser
示例#25
0
 def setup_parser(self):
     " Initialise the option parser for 'gr_modtool.py rm' "
     parser = ModTool.setup_parser(self)
     parser.usage = '%prog disable [options]. \n Call %prog without any options to run it interactively.'
     ogroup = OptionGroup(parser, "Disable module options")
     ogroup.add_option("-p", "--pattern", type="string", default=None,
             help="Filter possible choices for blocks to be disabled.")
     ogroup.add_option("-y", "--yes", action="store_true", default=False,
             help="Answer all questions with 'yes'.")
     parser.add_option_group(ogroup)
     return parser
示例#26
0
 def setup_parser(self):
     """ Initialise the option parser for 'gr_modtool info' """
     parser = ModTool.setup_parser(self)
     parser.usage = '%prog info [options]. \n Call %prog without any options to run it interactively.'
     ogroup = OptionGroup(parser, "Info options")
     ogroup.add_option("--python-readable", action="store_true", default=None,
             help="Return the output in a format that's easier to read for Python scripts.")
     ogroup.add_option("--suggested-dirs", default=None, type="string",
             help="Suggest typical include dirs if nothing better can be detected.")
     parser.add_option_group(ogroup)
     return parser
示例#27
0
 def setup_parser(self):
     parser = ModTool.setup_parser(self)
     ogroup = OptionGroup(parser, "Add module options")
     ogroup.add_option("-t",
                       "--block-type",
                       type="choice",
                       choices=self._block_types,
                       default=None,
                       help="One of %s." % ', '.join(self._block_types))
     ogroup.add_option(
         "--license-file",
         type="string",
         default=None,
         help=
         "File containing the license header for every source code file.")
     ogroup.add_option(
         "--copyright",
         type="string",
         default=None,
         help=
         "Name of the copyright holder (you or your company) MUST be a quoted string."
     )
     ogroup.add_option(
         "--argument-list",
         type="string",
         default=None,
         help="The argument list for the constructor and make functions.")
     ogroup.add_option(
         "--add-python-qa",
         action="store_true",
         default=None,
         help="If given, Python QA code is automatically added if possible."
     )
     ogroup.add_option(
         "--add-cpp-qa",
         action="store_true",
         default=None,
         help="If given, C++ QA code is automatically added if possible.")
     ogroup.add_option(
         "--skip-cmakefiles",
         action="store_true",
         default=False,
         help=
         "If given, only source files are written, but CMakeLists.txt files are left unchanged."
     )
     ogroup.add_option("-l",
                       "--lang",
                       type="choice",
                       choices=('cpp', 'c++', 'python'),
                       default=None,
                       help="Language (cpp or python)")
     parser.add_option_group(ogroup)
     return parser
示例#28
0
 def setup_parser(self):
     parser = ModTool.setup_parser(self)
     parser.usage = '%prog add [options]. \n Call %prog without any options to run it interactively.'
     ogroup = OptionGroup(parser, "Add module options")
     ogroup.add_option("-t", "--block-type", type="choice",
             choices=self._block_types, default=None, help="One of %s." % ', '.join(self._block_types))
     ogroup.add_option("--license-file", type="string", default=None,
             help="File containing the license header for every source code file.")
     ogroup.add_option("--argument-list", type="string", default=None,
             help="The argument list for the constructor and make functions.")
     ogroup.add_option("--add-python-qa", action="store_true", default=None,
             help="If given, Python QA code is automatically added if possible.")
     ogroup.add_option("--add-cpp-qa", action="store_true", default=None,
             help="If given, C++ QA code is automatically added if possible.")
     ogroup.add_option("--skip-cmakefiles", action="store_true", default=False,
             help="If given, only source files are written, but CMakeLists.txt files are left unchanged.")
     parser.add_option_group(ogroup)
     return parser
示例#29
0
 def setup_parser(self):
     " Initialise the option parser for 'gr_modtool info' "
     parser = ModTool.setup_parser(self)
     parser.usage = '%prog info [options]. \n Call %prog without any options to run it interactively.'
     ogroup = OptionGroup(parser, "Info options")
     ogroup.add_option(
         "--python-readable",
         action="store_true",
         default=None,
         help=
         "Return the output in a format that's easier to read for Python scripts."
     )
     ogroup.add_option(
         "--suggested-dirs",
         default=None,
         type="string",
         help=
         "Suggest typical include dirs if nothing better can be detected.")
     parser.add_option_group(ogroup)
     return parser
示例#30
0
 def setup_parser(self):
     parser = ModTool.setup_parser(self)
     ogroup = OptionGroup(parser, "Add module options")
     ogroup.add_option("-t", "--block-type", type="choice",
             choices=self._block_types, default=None, help="One of %s." % ', '.join(self._block_types))
     ogroup.add_option("--license-file", type="string", default=None,
             help="File containing the license header for every source code file.")
     ogroup.add_option("--copyright", type="string", default=None,
             help="Name of the copyright holder (you or your company) MUST be a quoted string.")
     ogroup.add_option("--argument-list", type="string", default=None,
             help="The argument list for the constructor and make functions.")
     ogroup.add_option("--add-python-qa", action="store_true", default=None,
             help="If given, Python QA code is automatically added if possible.")
     ogroup.add_option("--add-cpp-qa", action="store_true", default=None,
             help="If given, C++ QA code is automatically added if possible.")
     ogroup.add_option("--skip-cmakefiles", action="store_true", default=False,
             help="If given, only source files are written, but CMakeLists.txt files are left unchanged.")
     ogroup.add_option("-l", "--lang", type="choice", choices=('cpp', 'c++', 'python'),
             default=None, help="Language (cpp or python)")
     parser.add_option_group(ogroup)
     return parser
示例#31
0
 def setup_parser(self):
     parser = ModTool.setup_parser(self)
     ogroup = OptionGroup(parser, "Add module options")
     ogroup.add_option("--license-file", type="string", default=None,
                       help="File containing the license header for every source code file.")
     ogroup.add_option("--noc_id", type="string", default=None,
             help="The ID number with which the RFNoC block will identify itself at the SW/Hw interface")
     ogroup.add_option("--copyright", type="string", default=None,
             help="Name of the copyright holder (you or your company) MUST be a quoted string.")
     ogroup.add_option("--argument-list", type="string", default=None,
             help="The argument list for the constructor and make functions.")
     ogroup.add_option("--add-python-qa", action="store_true", default=None,
             help="If given, Python QA code is automatically added if possible.")
     ogroup.add_option("--add-cpp-qa", action="store_true", default=None,
             help="If given, C++ QA code is automatically added if possible.")
     ogroup.add_option("--skip-cmakefiles", action="store_true", default=False,
             help="If given, only source files are written, but CMakeLists.txt files are left unchanged.")
     ogroup.add_option("--skip-block-ctrl", action="store_true", default=None,
             help="If given, skips the generation of the RFNoC Block Controllers.")
     ogroup.add_option("--skip-block-interface", action="store_true", default=None,
             help="If given, skips the generation of the RFNoC interface files.")
     parser.add_option_group(ogroup)
     return parser
示例#32
0
 def __init__(self):
     ModTool.__init__(self)
示例#33
0
 def __init__(self):
     ModTool.__init__(self)
     self._add_cc_qa = False
     self._add_py_qa = False
示例#34
0
    def setup(self, options, args):
        ModTool.setup(self, options, args)

        self._info['blocktype'] = options.block_type
        if self._info['blocktype'] is None:
            # Print list out of blocktypes to user for reference
            print str(self._block_types)
            while self._info['blocktype'] not in self._block_types:
                self._info['blocktype'] = raw_input("Enter block type: ")
                if self._info['blocktype'] not in self._block_types:
                    print 'Must be one of ' + str(self._block_types)
        # Allow user to specify language interactively if not set
        self._info['lang'] = options.lang
        if self._info['lang'] is None:
            while self._info['lang'] not in ['cpp', 'python']:
                self._info['lang'] = raw_input("Language (python/cpp): ")

                if self._info['lang'] == 'c++':
                    self._info['lang'] = 'cpp'

        print "Language: %s" % {'cpp': 'C++', 'python': 'Python'}[self._info['lang']]

        if ((self._skip_subdirs['lib'] and self._info['lang'] == 'cpp')
             or (self._skip_subdirs['python'] and self._info['lang'] == 'python')):
            raise ModToolException('Missing or skipping relevant subdir.')

        if self._info['blockname'] is None:
            if len(args) >= 2:
                self._info['blockname'] = args[1]
            else:
                self._info['blockname'] = raw_input("Enter name of block/code (without module name prefix): ")
        if not re.match('[a-zA-Z0-9_]+', self._info['blockname']):
            raise ModToolException('Invalid block name.')
        print "Block/code identifier: " + self._info['blockname']
        self._info['fullblockname'] = self._info['modname'] + '_' + self._info['blockname']
        if not options.license_file:
            self._info['copyrightholder'] = options.copyright
            if self._info['copyrightholder'] is None:
                self._info['copyrightholder'] = '<+YOU OR YOUR COMPANY+>'
            elif self._info['is_component']:
                print "For GNU Radio components the FSF is added as copyright holder"
        self._license_file = options.license_file
        self._info['license'] = self.setup_choose_license()
        if options.argument_list is not None:
            self._info['arglist'] = options.argument_list
        else:
            self._info['arglist'] = raw_input('Enter valid argument list, including default arguments: ')

        if not (self._info['blocktype'] in ('noblock') or self._skip_subdirs['python']):
            self._add_py_qa = options.add_python_qa
            if self._add_py_qa is None:
                self._add_py_qa = ask_yes_no('Add Python QA code?', True)
        if self._info['lang'] == 'cpp':
            self._add_cc_qa = options.add_cpp_qa
            if self._add_cc_qa is None:
                self._add_cc_qa = ask_yes_no('Add C++ QA code?', not self._add_py_qa)
        self._skip_cmakefiles = options.skip_cmakefiles
        if self._info['version'] == 'autofoo' and not self._skip_cmakefiles:
            print "Warning: Autotools modules are not supported. ",
            print "Files will be created, but Makefiles will not be edited."
            self._skip_cmakefiles = True
示例#35
0
 def __init__(self):
     ModTool.__init__(self)
     self._add_cc_qa = False
     self._add_py_qa = False
     self._skip_cmakefiles = False
     self._license_file = None
示例#36
0
    def setup(self, options, args):
        ModTool.setup(self, options, args)

        if self._info['blockname'] is None:
            if len(args) >= 2:
                self._info['blockname'] = args[1]
            else:
                self._info['blockname'] = raw_input("Enter name of block/code (without module name prefix): ")
        if os.path.isfile("./lib/"+self._info['blockname']+"_impl.cc") or os.path.isfile("./python/"+self._info['blockname']+".py"):
            raise ModToolException('The given blockname already exists!')
        if not re.match('[a-zA-Z0-9_]+', self._info['blockname']):
            raise ModToolException('Invalid block name.')
        print "Block/code identifier: " + self._info['blockname']
        self._info['fullblockname'] = self._info['modname'] + '_' + self._info['blockname']

        self._info['blocktype'] = options.block_type
        if self._info['blocktype'] is None:
            # Print list out of blocktypes to user for reference
            print str(self._block_types)
            with SequenceCompleter(sorted(self._block_types)):
                while self._info['blocktype'] not in self._block_types:
                    self._info['blocktype'] = raw_input("Enter block type: ")
                    if self._info['blocktype'] not in self._block_types:
                        print 'Must be one of ' + str(self._block_types)

        # Allow user to specify language interactively if not set
        self._info['lang'] = options.lang
        if self._info['lang'] is None:
            language_candidates = ('cpp', 'python')
            with SequenceCompleter(language_candidates):
                while self._info['lang'] not in language_candidates:
                    self._info['lang'] = raw_input("Language (python/cpp): ")
        if self._info['lang'] == 'c++':
            self._info['lang'] = 'cpp'

        print "Language: %s" % {'cpp': 'C++', 'python': 'Python'}[self._info['lang']]

        if ((self._skip_subdirs['lib'] and self._info['lang'] == 'cpp')
                or (self._skip_subdirs['python'] and self._info['lang'] == 'python')):
            raise ModToolException('Missing or skipping relevant subdir.')

        if not options.license_file:
            self._info['copyrightholder'] = options.copyright
            if self._info['copyrightholder'] is None:
                user = getpass.getuser()
                git_user = self.scm.get_gituser()
                if git_user:
                    copyright_candidates = (user, git_user, 'GNU Radio')
                else:
                    copyright_candidates = (user, 'GNU Radio')
                with SequenceCompleter(copyright_candidates):
                    self._info['copyrightholder'] = raw_input("Please specify the copyright holder: ")
                    if not self._info['copyrightholder'] or self._info['copyrightholder'].isspace():
                        self._info['copyrightholder'] = "gr-"+self._info['modname']+" author"
            elif self._info['is_component']:
                print "For GNU Radio components the FSF is added as copyright holder"
        self._license_file = options.license_file
        self._info['license'] = self.setup_choose_license()
        if options.argument_list is not None:
            self._info['arglist'] = options.argument_list
        else:
            self._info['arglist'] = raw_input('Enter valid argument list, including default arguments: ')

        if not (self._info['blocktype'] in ('noblock') or self._skip_subdirs['python']):
            self._add_py_qa = options.add_python_qa
            if self._add_py_qa is None:
                self._add_py_qa = ask_yes_no('Add Python QA code?', True)
        if self._info['lang'] == 'cpp':
            self._add_cc_qa = options.add_cpp_qa
            if self._add_cc_qa is None:
                self._add_cc_qa = ask_yes_no('Add C++ QA code?', not self._add_py_qa)
        self._skip_cmakefiles = options.skip_cmakefiles
        if self._info['version'] == 'autofoo' and not self._skip_cmakefiles:
            print "Warning: Autotools modules are not supported. ",
            print "Files will be created, but Makefiles will not be edited."
            self._skip_cmakefiles = True
示例#37
0
 def __init__(self):
     ModTool.__init__(self)
示例#38
0
    def setup(self, options, args):
        ModTool.setup(self, options, args)

        if self._info['blockname'] is None:
            if len(args) >= 2:
                self._info['blockname'] = args[1]
            else:
                self._info['blockname'] = raw_input(
                    "Enter name of block/code (without module name prefix): ")
        if os.path.isfile("./lib/" + self._info['blockname'] +
                          "_impl.cc") or os.path.isfile(
                              "./python/" + self._info['blockname'] + ".py"):
            raise ModToolException('The given blockname already exists!')
        if not re.match('[a-zA-Z0-9_]+', self._info['blockname']):
            raise ModToolException('Invalid block name.')
        print "Block/code identifier: " + self._info['blockname']
        self._info['fullblockname'] = self._info['modname'] + '_' + self._info[
            'blockname']

        self._info['blocktype'] = options.block_type
        if self._info['blocktype'] is None:
            # Print list out of blocktypes to user for reference
            print str(self._block_types)
            with SequenceCompleter(sorted(self._block_types)):
                while self._info['blocktype'] not in self._block_types:
                    self._info['blocktype'] = raw_input("Enter block type: ")
                    if self._info['blocktype'] not in self._block_types:
                        print 'Must be one of ' + str(self._block_types)

        # Allow user to specify language interactively if not set
        self._info['lang'] = options.lang
        if self._info['lang'] is None:
            language_candidates = ('cpp', 'python')
            with SequenceCompleter(language_candidates):
                while self._info['lang'] not in language_candidates:
                    self._info['lang'] = raw_input("Language (python/cpp): ")
        if self._info['lang'] == 'c++':
            self._info['lang'] = 'cpp'

        print "Language: %s" % {
            'cpp': 'C++',
            'python': 'Python'
        }[self._info['lang']]

        if ((self._skip_subdirs['lib'] and self._info['lang'] == 'cpp') or
            (self._skip_subdirs['python'] and self._info['lang'] == 'python')):
            raise ModToolException('Missing or skipping relevant subdir.')

        if not options.license_file:
            self._info['copyrightholder'] = options.copyright
            if self._info['copyrightholder'] is None:
                user = getpass.getuser()
                git_user = self.scm.get_gituser()
                if git_user:
                    copyright_candidates = (user, git_user, 'GNU Radio')
                else:
                    copyright_candidates = (user, 'GNU Radio')
                with SequenceCompleter(copyright_candidates):
                    self._info['copyrightholder'] = raw_input(
                        "Please specify the copyright holder: ")
                    if not self._info['copyrightholder'] or self._info[
                            'copyrightholder'].isspace():
                        self._info['copyrightholder'] = "gr-" + self._info[
                            'modname'] + " author"
            elif self._info['is_component']:
                print "For GNU Radio components the FSF is added as copyright holder"
        self._license_file = options.license_file
        self._info['license'] = self.setup_choose_license()
        if options.argument_list is not None:
            self._info['arglist'] = options.argument_list
        else:
            self._info['arglist'] = raw_input(
                'Enter valid argument list, including default arguments: ')

        if not (self._info['blocktype'] in ('noblock')
                or self._skip_subdirs['python']):
            self._add_py_qa = options.add_python_qa
            if self._add_py_qa is None:
                self._add_py_qa = ask_yes_no('Add Python QA code?', True)
        if self._info['lang'] == 'cpp':
            self._add_cc_qa = options.add_cpp_qa
            if self._add_cc_qa is None:
                self._add_cc_qa = ask_yes_no('Add C++ QA code?',
                                             not self._add_py_qa)
        self._skip_cmakefiles = options.skip_cmakefiles
        if self._info['version'] == 'autofoo' and not self._skip_cmakefiles:
            print "Warning: Autotools modules are not supported. ",
            print "Files will be created, but Makefiles will not be edited."
            self._skip_cmakefiles = True
示例#39
0
 def __init__(self):
     ModTool.__init__(self)
     self._directory = None
     self._python_readable = False
     self._suggested_dirs = None
示例#40
0
 def __init__(self):
     ModTool.__init__(self)
     self._directory = None
     self._python_readable = False
     self._suggested_dirs = None
示例#41
0
 def __init__(self):
     ModTool.__init__(self)
     self._info['inputsig'] = "<+MIN_IN+>, <+MAX_IN+>, sizeof (<+float+>)"
     self._info['outputsig'] = "<+MIN_OUT+>, <+MAX_OUT+>, sizeof (<+float+>)"
     self._add_cc_qa = False
     self._add_py_qa = False