• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python base.Address类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中twitter.pants.base.Address的典型用法代码示例。如果您正苦于以下问题:Python Address类的具体用法?Python Address怎么用?Python Address使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Address类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_top_level

 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'))
开发者ID:BabyDuncan,项目名称:commons,代码行数:7,代码来源:test_address.py


示例2: parse_address

 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)
开发者ID:JoeEnnever,项目名称:commons,代码行数:7,代码来源:pants_target.py


示例3: test_sibling_references

  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))
开发者ID:alfss,项目名称:commons,代码行数:30,代码来源:test_parse_context.py


示例4: test_parse_from_sub_dir

  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)
开发者ID:BabyDuncan,项目名称:commons,代码行数:8,代码来源:test_address.py


示例5: _synthesize_command

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())
开发者ID:bollwang,项目名称:commons,代码行数:16,代码来源:pants_exe.py


示例6: _parse_targets

  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
开发者ID:adamsxu,项目名称:commons,代码行数:31,代码来源:ivy_resolve.py


示例7: __init__

  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))
开发者ID:steliokontos,项目名称:commons,代码行数:31,代码来源:build.py


示例8: __init__

  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!')
开发者ID:adamsxu,项目名称:commons,代码行数:34,代码来源:py.py


示例9: target

  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))
开发者ID:alfss,项目名称:commons,代码行数:8,代码来源:build_root_test.py


示例10: __init__

  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)
开发者ID:dynamicguy,项目名称:commons,代码行数:58,代码来源:py.py


示例11: get_pytest_eggs

 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
开发者ID:DikangGu,项目名称:commons,代码行数:10,代码来源:test_builder.py


示例12: parse_url

 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
开发者ID:adamsxu,项目名称:commons,代码行数:10,代码来源:markdown_to_html.py


示例13: _parse_addresses

 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)
开发者ID:patricklaw,项目名称:twitter-commons,代码行数:12,代码来源:goal.py


示例14: _parse_addresses

 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
开发者ID:adamsxu,项目名称:commons,代码行数:12,代码来源:ide.py


示例15: _parse_buildfiles

 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
开发者ID:DikangGu,项目名称:commons,代码行数:12,代码来源:list.py


示例16: _coerce_to_targets

  def _coerce_to_targets(cls, from_str, to_str):
    if isinstance(from_str, Compatibility.string):
      if not isinstance(to_str, Compatibility.string):
        raise TaskError('Finding paths from string %s to non-string %s' % (from_str, str(to_str)))

      from_address = Address.parse(get_buildroot(), from_str)
      to_address = Address.parse(get_buildroot(), to_str)

      from_target = Target.get(from_address)
      to_target = Target.get(to_address)

      if not from_target:
        raise TaskError('Target %s doesn\'t exist' % from_address.reference())
      if not to_target:
        raise TaskError('Target %s doesn\'t exist' % to_address.reference())

      return from_target, to_target

    elif isinstance(to_str, Compatibility.string):
      raise TaskError('Finding paths from string %s to non-string %s' % (to_str, str(from_str)))
    return from_str, to_str
开发者ID:alfss,项目名称:commons,代码行数:21,代码来源:paths.py


示例17: _run_lint

  def _run_lint(self, target, args):
    chroot = PythonChroot(target, self.root_dir, extra_targets=[
      Target.get(Address.parse(self.root_dir, '3rdparty/python:pylint'))])
    builder = chroot.dump()
    builder.info().entry_point = 'pylint.lint'
    builder.freeze()

    interpreter_args = [
      '--rcfile=%s' % os.path.join(self.root_dir, 'build-support', 'pylint', 'pylint.rc')]
    interpreter_args.extend(args or [])
    sources = OrderedSet([])
    target.walk(lambda trg: sources.update(
      trg.sources if hasattr(trg, 'sources') and trg.sources is not None else []))
    pex = PEX(builder.path())
    pex.run(args=interpreter_args + list(sources), with_chroot=True)
开发者ID:JoeEnnever,项目名称:commons,代码行数:15,代码来源:lint_builder.py


示例18: __init__

  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:
      address = Address.parse(root_dir, self.args[0])
      target = Target.get(address)
    except:
      self.error("Invalid target in %s" % self.args[0])

    if not target:
      self.error("Target %s does not exist" % address)
    self.target = target
    self.args.pop(0)
开发者ID:DikangGu,项目名称:commons,代码行数:16,代码来源:py.py


示例19: __init__

  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._config = Config.load()
    self._root = root_dir

    address = Address.parse(root_dir, self.args[0])
    self.target = Target.get(address)
    if self.target is None:
      self.error('%s is not a valid target!' % self.args[0])

    if not self.target.provides:
      self.error('Target must provide an artifact.')
开发者ID:CodeWarltz,项目名称:commons,代码行数:16,代码来源:setup_py.py


示例20: __init__

  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")

    address = Address.parse(root_dir, self.args[0])
    self.target = Target.get(address)

    if self.target is None:
      self.error('%s is not a valid target!' % self.args[0])

    if not self.target.provides:
      self.error('Target must provide an artifact.')

    self.dependencies = self.minified_dependencies(self.target)
开发者ID:steliokontos,项目名称:commons,代码行数:16,代码来源:setup_py.py



注:本文中的twitter.pants.base.Address类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python base.BuildFile类代码示例发布时间:2022-05-27
下一篇:
Python pants.get_buildroot函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap