本文整理汇总了Python中modtool_base.ModTool类的典型用法代码示例。如果您正苦于以下问题:Python ModTool类的具体用法?Python ModTool怎么用?Python ModTool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ModTool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup
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
示例2: setup
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: setup
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'] = '.'
示例4: setup
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'] = '.'
示例5: setup
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"
示例6: setup
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'] = '.'
示例7: setup
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'] = '.'
示例8: setup
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
示例9: setup_parser
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
示例10: setup_parser
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
示例11: setup_parser
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
示例12: setup_parser
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
示例13: setup_parser
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
示例14: setup_parser
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
示例15: setup_parser
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