本文整理汇总了Python中pants.help.build_dictionary_info_extracter.BuildDictionaryInfoExtracter.get_target_args方法的典型用法代码示例。如果您正苦于以下问题:Python BuildDictionaryInfoExtracter.get_target_args方法的具体用法?Python BuildDictionaryInfoExtracter.get_target_args怎么用?Python BuildDictionaryInfoExtracter.get_target_args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pants.help.build_dictionary_info_extracter.BuildDictionaryInfoExtracter
的用法示例。
在下文中一共展示了BuildDictionaryInfoExtracter.get_target_args方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: console_output
# 需要导入模块: from pants.help.build_dictionary_info_extracter import BuildDictionaryInfoExtracter [as 别名]
# 或者: from pants.help.build_dictionary_info_extracter.BuildDictionaryInfoExtracter import get_target_args [as 别名]
def console_output(self, targets):
buildfile_aliases = self.context.build_file_parser.registered_aliases()
extracter = BuildDictionaryInfoExtracter(buildfile_aliases)
alias = self.get_options().details
if alias:
target_types = buildfile_aliases.target_types_by_alias.get(alias)
if target_types:
tti = next(x for x in extracter.get_target_type_info() if x.build_file_alias == alias)
yield blue('\n{}\n'.format(tti.description))
yield blue('{}('.format(alias))
for arg in extracter.get_target_args(list(target_types)[0]):
default = green('(default: {})'.format(arg.default) if arg.has_default else '')
yield '{:<30} {}'.format(
cyan(' {} = ...,'.format(arg.name)),
' {}{}{}'.format(arg.description, ' ' if arg.description else '', default))
yield blue(')')
else:
yield 'No such target type: {}'.format(alias)
else:
for tti in extracter.get_target_type_info():
description = tti.description or '<Add description>'
yield '{} {}'.format(cyan('{:>30}:'.format(tti.build_file_alias)), description)
示例2: test_get_target_args
# 需要导入模块: from pants.help.build_dictionary_info_extracter import BuildDictionaryInfoExtracter [as 别名]
# 或者: from pants.help.build_dictionary_info_extracter.BuildDictionaryInfoExtracter import get_target_args [as 别名]
def test_get_target_args(self):
class Target1(Target):
def __init__(self, arg1, arg2=42, **kwargs):
"""
:param arg1: The first arg.
:param arg2: The second arg.
"""
super(Target1, self).__init__(**kwargs)
class Target2(Target1):
pass
class Target3(Target2):
def __init__(self, arg3, arg4=None, **kwargs):
super(Target1, self).__init__(**kwargs)
self.maxDiff = None
self.assertEqual(BuildDictionaryInfoExtracter.basic_target_args + [
FunctionArg('arg1', 'The first arg.', False, None),
FunctionArg('arg2', 'The second arg.', True, 42),
FunctionArg('arg3', '', False, None),
FunctionArg('arg4', '', True, None)
],
BuildDictionaryInfoExtracter.get_target_args(Target3))