本文整理汇总了Python中twitter.pants.base.Address.parse方法的典型用法代码示例。如果您正苦于以下问题:Python Address.parse方法的具体用法?Python Address.parse怎么用?Python Address.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twitter.pants.base.Address
的用法示例。
在下文中一共展示了Address.parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_top_level
# 需要导入模块: from twitter.pants.base import Address [as 别名]
# 或者: from twitter.pants.base.Address import parse [as 别名]
def test_top_level(self):
with self.workspace('BUILD') as root_dir:
self.assertAddress(root_dir, 'BUILD', 'c', Address.parse(root_dir, ':c'))
self.assertAddress(root_dir, 'BUILD', 'c', Address.parse(root_dir, '.:c'))
self.assertAddress(root_dir, 'BUILD', 'c', Address.parse(root_dir, './:c'))
self.assertAddress(root_dir, 'BUILD', 'c', Address.parse(root_dir, './BUILD:c'))
self.assertAddress(root_dir, 'BUILD', 'c', Address.parse(root_dir, 'BUILD:c'))
示例2: parse_address
# 需要导入模块: from twitter.pants.base import Address [as 别名]
# 或者: from twitter.pants.base.Address import parse [as 别名]
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)
示例3: test_sibling_references
# 需要导入模块: from twitter.pants.base import Address [as 别名]
# 或者: from twitter.pants.base.Address import parse [as 别名]
def test_sibling_references(self):
with temporary_dir() as root_dir:
buildfile = create_buildfile(root_dir, 'a', name='BUILD',
content=dedent("""
dependencies(name='util',
dependencies=[
jar(org='com.twitter', name='util', rev='0.0.1')
]
)
""").strip()
)
sibling = create_buildfile(root_dir, 'a', name='BUILD.sibling',
content=dedent("""
dependencies(name='util-ex',
dependencies=[
pants(':util'),
jar(org='com.twitter', name='util-ex', rev='0.0.1')
]
)
""").strip()
)
ParseContext(buildfile).parse()
utilex = Target.get(Address.parse(root_dir, 'a:util-ex', is_relative=False))
utilex_deps = set(utilex.resolve())
util = Target.get(Address.parse(root_dir, 'a:util', is_relative=False))
util_deps = set(util.resolve())
self.assertEquals(util_deps, util_deps.intersection(utilex_deps))
示例4: test_parse_from_sub_dir
# 需要导入模块: from twitter.pants.base import Address [as 别名]
# 或者: from twitter.pants.base.Address import parse [as 别名]
def test_parse_from_sub_dir(self):
with self.workspace('a/b/c/BUILD') as root_dir:
with pushd(os.path.join(root_dir, 'a')):
self.assertAddress(root_dir, 'a/b/c/BUILD', 'c',
Address.parse(root_dir, 'b/c', is_relative=True))
with pytest.raises(IOError):
Address.parse(root_dir, 'b/c', is_relative=False)
示例5: _synthesize_command
# 需要导入模块: from twitter.pants.base import Address [as 别名]
# 或者: from twitter.pants.base.Address import parse [as 别名]
def _synthesize_command(root_dir, args):
command = args[0]
if command in Command.all_commands():
subcommand_args = args[1:] if len(args) > 1 else []
return command, _add_default_options(command, subcommand_args)
if command.startswith('-'):
_exit_and_fail('Invalid command: %s' % command)
# assume 'build' if a command was omitted.
try:
Address.parse(root_dir, command)
return _BUILD_COMMAND, _add_default_options(_BUILD_COMMAND, args)
except:
_exit_and_fail('Failed to execute pants build: %s' % traceback.format_exc())
示例6: _parse_targets
# 需要导入模块: from twitter.pants.base import Address [as 别名]
# 或者: from twitter.pants.base.Address import parse [as 别名]
def _parse_targets(self, targets, root_dir):
for spec in self.args:
try:
address = Address.parse(root_dir, spec)
except:
self.error("Problem parsing spec %s: %s" % (spec, traceback.format_exc()))
try:
target = Target.get(address)
except:
self.error("Problem parsing target %s: %s" % (address, traceback.format_exc()))
if address.is_meta:
print("target is meta")
target = target.do_in_context(lambda: bang.extract_target([target], None))
if not IvyResolve._is_resolvable(target):
self.error("Target: %s is not resolvable" % address)
targets.add(target)
if not self.intransitive:
def add_targets(ttarget):
if hasattr(ttarget, 'internal_dependencies'):
for dep in ttarget.internal_dependencies:
if IvyResolve._is_resolvable(dep):
targets.add(dep)
else:
print("skipping %s as it's not ivy resolvable" % dep.name)
target.walk(add_targets)
return targets
示例7: __init__
# 需要导入模块: from twitter.pants.base import Address [as 别名]
# 或者: from twitter.pants.base.Address import parse [as 别名]
def __init__(self, root_dir, parser, argv):
Command.__init__(self, root_dir, parser, argv)
if not self.args:
self.error("A spec argument is required")
try:
specs_end = self.args.index('--')
if len(self.args) > specs_end:
self.build_args = self.args[specs_end+1:len(self.args)+1]
else:
self.build_args = []
except ValueError:
specs_end = 1
self.build_args = self.args[1:] if len(self.args) > 1 else []
self.targets = OrderedSet()
for spec in self.args[0:specs_end]:
try:
address = Address.parse(root_dir, spec)
except:
self.error("Problem parsing spec %s: %s" % (spec, traceback.format_exc()))
try:
target = Target.get(address)
except:
self.error("Problem parsing BUILD target %s: %s" % (address, traceback.format_exc()))
if not target:
self.error("Target %s does not exist" % address)
self.targets.update(tgt for tgt in target.resolve() if is_concrete(tgt))
示例8: __init__
# 需要导入模块: from twitter.pants.base import Address [as 别名]
# 或者: from twitter.pants.base.Address import parse [as 别名]
def __init__(self, root_dir, parser, argv):
Command.__init__(self, root_dir, parser, argv)
if not self.args:
self.error("A spec argument is required")
targets = []
for k in range(len(self.args)):
arg = self.args[0]
if arg == '--':
self.args.pop(0)
break
try:
address = Address.parse(root_dir, arg)
target = Target.get(address)
except Exception as e:
break
if not target:
break
targets.append(target)
self.args.pop(0)
# stop at PythonBinary target
if isinstance(target, PythonBinary):
break
self.target = targets.pop(0) if targets else None
self.extra_targets = targets
if self.target is None:
self.error('No valid target specified!')
示例9: target
# 需要导入模块: from twitter.pants.base import Address [as 别名]
# 或者: from twitter.pants.base.Address import parse [as 别名]
def target(cls, address):
"""Resolves the given target address to a Target object.
address: The BUILD target address to resolve.
Returns the corresponding Target or else None if the address does not point to a defined Target.
"""
return Target.get(Address.parse(cls.build_root, address, is_relative=False))
示例10: __init__
# 需要导入模块: from twitter.pants.base import Address [as 别名]
# 或者: from twitter.pants.base.Address import parse [as 别名]
def __init__(self, run_tracker, root_dir, parser, argv):
Command.__init__(self, run_tracker, root_dir, parser, argv)
if not self.args:
self.error("A spec argument is required")
self.target = None
self.extra_targets = []
# We parse each arg in the context of the cli usage:
# ./pants command (options) [spec] (build args)
# ./pants command (options) [spec]... -- (build args)
# Our command token and our options are parsed out so we see args of the form:
# [spec] (build args)
# [spec]... -- (build args)
for k in range(len(self.args)):
arg = self.args.pop(0)
if arg == '--':
break
target = None
try:
address = Address.parse(root_dir, arg)
target = Target.get(address)
except Exception:
pass
if not target:
# We failed to parse the arg as a target or else it was in valid address format but did not
# correspond to a real target. Assume this is the 1st of the build args and terminate
# processing args for target addresses.
break
binaries = []
concrete_targets = [t for t in target.resolve() if t.is_concrete]
for resolved in concrete_targets:
if isinstance(resolved, PythonBinary):
binaries.append(resolved)
else:
self.extra_targets.append(resolved)
if not binaries:
# No binary encountered yet so move on to the next spec to find one or else accumulate more
# libraries for ./pants py -> interpreter mode.
pass
elif len(binaries) == 1:
# We found a binary and are done, the rest of the args get passed to it
self.target = binaries[0]
break
else:
self.error('Can only process 1 binary target, %s contains %d:\n\t%s' % (
arg, len(binaries), '\n\t'.join(str(binary.address) for binary in binaries)
))
if self.target is None:
if not self.extra_targets:
self.error('No valid target specified!')
self.target = self.extra_targets.pop(0)
示例11: get_pytest_eggs
# 需要导入模块: from twitter.pants.base import Address [as 别名]
# 或者: from twitter.pants.base.Address import parse [as 别名]
def get_pytest_eggs(root):
specs = ["3rdparty/python:pytest", "3rdparty/python:py"]
eggs = []
for spec in specs:
address = Address.parse(root, spec)
target = Target.get(address)
for dep in target.dependencies:
for egg in dep.eggs:
eggs.append(egg)
return eggs
示例12: parse_url
# 需要导入模块: from twitter.pants.base import Address [as 别名]
# 或者: from twitter.pants.base.Address import parse [as 别名]
def parse_url(spec):
match = MarkdownToHtml.PANTS_LINK.match(spec)
if match:
page = Target.get(Address.parse(get_buildroot(), match.group(1)))
if not page:
raise TaskError('Invalid link %s' % match.group(1))
alias, url = url_builder(page, config=get_config(page))
return alias, url
else:
return spec, spec
示例13: _parse_addresses
# 需要导入模块: from twitter.pants.base import Address [as 别名]
# 或者: from twitter.pants.base.Address import parse [as 别名]
def _parse_addresses(self, spec):
if spec.endswith('::'):
dir = self._get_dir(spec[:-len('::')])
for buildfile in BuildFile.scan_buildfiles(self._root_dir, os.path.join(self._root_dir, dir)):
for address in Target.get_all_addresses(buildfile):
yield address
elif spec.endswith(':'):
dir = self._get_dir(spec[:-len(':')])
for address in Target.get_all_addresses(BuildFile(self._root_dir, dir)):
yield address
else:
yield Address.parse(self._root_dir, spec)
示例14: _parse_addresses
# 需要导入模块: from twitter.pants.base import Address [as 别名]
# 或者: from twitter.pants.base.Address import parse [as 别名]
def _parse_addresses(self):
addresses = OrderedSet()
for spec in self.args:
try:
if self.options.is_directory_list:
for address in Command.scan_addresses(self.root_dir, spec):
addresses.add(address)
else:
addresses.add(Address.parse(self.root_dir, spec))
except:
self.error("Problem parsing spec %s: %s" % (spec, traceback.format_exc()))
return addresses
示例15: _parse_buildfiles
# 需要导入模块: from twitter.pants.base import Address [as 别名]
# 或者: from twitter.pants.base.Address import parse [as 别名]
def _parse_buildfiles(self):
buildfiles = OrderedSet()
for spec in self.args:
try:
if self.options.is_directory_list:
for buildfile in BuildFile.scan_buildfiles(self.root_dir, spec):
buildfiles.add(buildfile)
else:
buildfiles.add(Address.parse(self.root_dir, spec).buildfile)
except:
self.error("Problem parsing spec %s: %s" % (spec, traceback.format_exc()))
return buildfiles