本文整理汇总了Python中twitter.pants.base.parse_context.ParseContext.locate方法的典型用法代码示例。如果您正苦于以下问题:Python ParseContext.locate方法的具体用法?Python ParseContext.locate怎么用?Python ParseContext.locate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twitter.pants.base.parse_context.ParseContext
的用法示例。
在下文中一共展示了ParseContext.locate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_locate
# 需要导入模块: from twitter.pants.base.parse_context import ParseContext [as 别名]
# 或者: from twitter.pants.base.parse_context.ParseContext import locate [as 别名]
def test_locate(self):
with pytest.raises(ParseContext.ContextError):
ParseContext.locate()
with temporary_dir() as root_dir:
a_context = ParseContext(create_buildfile(root_dir, 'a'))
b_context = ParseContext(create_buildfile(root_dir, 'b'))
def test_in_a():
self.assertEquals(a_context, ParseContext.locate())
return b_context.do_in_context(lambda: ParseContext.locate())
self.assertEquals(b_context, a_context.do_in_context(test_in_a))
示例2: __init__
# 需要导入模块: from twitter.pants.base.parse_context import ParseContext [as 别名]
# 或者: from twitter.pants.base.parse_context.ParseContext import locate [as 别名]
def __init__(self, spec, exclusives=None):
"""
:param string spec: target address. E.g., `src/java/com/twitter/common/util/BUILD\:util`
"""
# it's critical the spec is parsed 1st, the results are needed elsewhere in constructor flow
parse_context = ParseContext.locate()
def parse_address():
if spec.startswith(':'):
# the :[target] could be in a sibling BUILD - so parse using the canonical address
pathish = "%s:%s" % (parse_context.buildfile.canonical_relpath,
spec[1:])
return Address.parse(parse_context.buildfile.root_dir, pathish,
False)
else:
return Address.parse(parse_context.buildfile.root_dir, spec,
False)
try:
self.address = parse_address()
except IOError as e:
self.address = parse_context.buildfile.relpath
raise TargetDefinitionException(
self, '%s%s' % (self._DEFINITION_ERROR_MSG, e))
# We must disable the re-init check, because our funky __getattr__ breaks it.
# We're not involved in any multiple inheritance, so it's OK to disable it here.
super(Pants, self).__init__(
self.address.target_name,
reinit_check=False,
exclusives=exclusives)
示例3: __init__
# 需要导入模块: from twitter.pants.base.parse_context import ParseContext [as 别名]
# 或者: from twitter.pants.base.parse_context.ParseContext import locate [as 别名]
def __init__(self, target, msg):
address = getattr(target, 'address', None)
if address is None:
try:
location = ParseContext.locate().current_buildfile
except ParseContext.ContextError:
location = 'unknown location'
address = 'unknown target of type %s in %s' % (target.__class__.__name__, location)
super(Exception, self).__init__('Error with %s: %s' % (address, msg))
示例4: test_in_a
# 需要导入模块: from twitter.pants.base.parse_context import ParseContext [as 别名]
# 或者: from twitter.pants.base.parse_context.ParseContext import locate [as 别名]
def test_in_a():
self.assertEquals(a_context, ParseContext.locate())
return b_context.do_in_context(lambda: ParseContext.locate())
示例5: _locate
# 需要导入模块: from twitter.pants.base.parse_context import ParseContext [as 别名]
# 或者: from twitter.pants.base.parse_context.ParseContext import locate [as 别名]
def _locate(self):
parse_context = ParseContext.locate()
return Address(parse_context.current_buildfile, self.name)
示例6: _post_construct
# 需要导入模块: from twitter.pants.base.parse_context import ParseContext [as 别名]
# 或者: from twitter.pants.base.parse_context.ParseContext import locate [as 别名]
def _post_construct(self, func, *args, **kwargs):
"""Registers a command to invoke after this target's BUILD file is parsed."""
ParseContext.locate().on_context_exit(func, *args, **kwargs)
示例7: locate
# 需要导入模块: from twitter.pants.base.parse_context import ParseContext [as 别名]
# 或者: from twitter.pants.base.parse_context.ParseContext import locate [as 别名]
def locate(self):
parse_context = ParseContext.locate()
return Address(parse_context.buildfile, self.name, self.is_meta)