Exemple #1
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
    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']
    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']
Exemple #4
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
Exemple #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)
        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"
    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'] = '.'
Exemple #7
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'] = '.'
    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"] = "."
Exemple #9
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'] = '.'
Exemple #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 parse? (Regex): ')
        if not self._info['pattern'] or self._info['pattern'].isspace():
            self._info['pattern'] = '.'
Exemple #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:
            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'] = '.'
Exemple #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'] = '.'
Exemple #13
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)
Exemple #14
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'] = '.'
Exemple #15
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
Exemple #16
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
Exemple #17
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
Exemple #18
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