当前位置: 首页>>代码示例>>Python>>正文


Python Target.get方法代码示例

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


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

示例1: test_sibling_references

# 需要导入模块: from twitter.pants.base import Target [as 别名]
# 或者: from twitter.pants.base.Target import get [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))
开发者ID:alfss,项目名称:commons,代码行数:32,代码来源:test_parse_context.py

示例2: __init__

# 需要导入模块: from twitter.pants.base import Target [as 别名]
# 或者: from twitter.pants.base.Target import get [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!')
开发者ID:adamsxu,项目名称:commons,代码行数:36,代码来源:py.py

示例3: add_targets

# 需要导入模块: from twitter.pants.base import Target [as 别名]
# 或者: from twitter.pants.base.Target import get [as 别名]
 def add_targets(self, error, dir, buildfile):
   try:
     self.targets.extend(Target.get(addr) for addr in Target.get_all_addresses(buildfile))
   except (TypeError, ImportError):
     error(dir, include_traceback=True)
   except (IOError, SyntaxError):
     error(dir)
开发者ID:soheilhy,项目名称:commons,代码行数:9,代码来源:goal.py

示例4: execute

# 需要导入模块: from twitter.pants.base import Target [as 别名]
# 或者: from twitter.pants.base.Target import get [as 别名]
 def execute(self):
   for buildfile in BuildFile.scan_buildfiles(self.root_dir):
     for address in Target.get_all_addresses(buildfile):
       target = Target.get(address)
       if hasattr(target, 'sources') and target.sources is not None:
         for sourcefile in target.sources:
           print sourcefile, address
开发者ID:DikangGu,项目名称:commons,代码行数:9,代码来源:filemap.py

示例5: _parse_targets

# 需要导入模块: from twitter.pants.base import Target [as 别名]
# 或者: from twitter.pants.base.Target import get [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
开发者ID:adamsxu,项目名称:commons,代码行数:33,代码来源:ivy_resolve.py

示例6: resolve

# 需要导入模块: from twitter.pants.base import Target [as 别名]
# 或者: from twitter.pants.base.Target import get [as 别名]
 def resolve(self):
   # De-reference this pants pointer to an actual parsed target.
   resolved = Target.get(self.address)
   if not resolved:
     raise KeyError("Failed to find target for: %s" % self.address)
   for dep in resolved.resolve():
     yield dep
开发者ID:JoeEnnever,项目名称:commons,代码行数:9,代码来源:pants_target.py

示例7: _find_path

# 需要导入模块: from twitter.pants.base import Target [as 别名]
# 或者: from twitter.pants.base.Target import get [as 别名]
  def _find_path(cls, from_target, to_target, log):
    from_target, to_target = cls._coerce_to_targets(from_target, to_target)

    log.debug('Looking for path from %s to %s' % (from_target.address.reference(), to_target.address.reference()))

    queue = [([from_target], 0)]
    while True:
      if not queue:
        print('no path found from %s to %s!' % (from_target.address.reference(), to_target.address.reference()))
        break

      path, indent = queue.pop(0)
      next_target = path[-1]
      if next_target in cls.examined_targets:
        continue
      cls.examined_targets.add(next_target)

      log.debug('%sexamining %s' % ('  ' * indent, next_target))

      if next_target == to_target:
        print('')
        for target in path:
          print('%s' % target.address.reference())
        break

      if hasattr(next_target, 'dependency_addresses'):
        for address in next_target.dependency_addresses:
          dep = Target.get(address)
          queue.append((path + [dep], indent + 1))
开发者ID:alfss,项目名称:commons,代码行数:31,代码来源:paths.py

示例8: __init__

# 需要导入模块: from twitter.pants.base import Target [as 别名]
# 或者: from twitter.pants.base.Target import get [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))
开发者ID:steliokontos,项目名称:commons,代码行数:33,代码来源:build.py

示例9: configure_target

# 需要导入模块: from twitter.pants.base import Target [as 别名]
# 或者: from twitter.pants.base.Target import get [as 别名]
    def configure_target(target):
      if target not in analyzed:
        analyzed.add(target)

        self.has_scala = self.has_scala or is_scala(target)

        if isinstance(target, JavaLibrary) or isinstance(target, ScalaLibrary):
          # TODO(John Sirois): this does not handle test resources, make test resources 1st class
          # in ant build and punch this through to pants model
          resources = set()
          if target.resources:
            resources.update(target.resources)
          if target.binary_resources:
            resources.update(target.binary_resources)
          if resources:
            self.resource_extensions.update(Project.extract_resource_extensions(resources))
            configure_source_sets(ExportableJvmLibrary.RESOURCES_BASE_DIR, resources, is_test = False)

        if target.sources:
          test = is_test(target)
          self.has_tests = self.has_tests or test
          configure_source_sets(target.target_base, target.sources, is_test = test)

        siblings = Target.get_all_addresses(target.address.buildfile)
        return filter(accept_target, [ Target.get(a) for a in siblings if a != target.address ])
开发者ID:DikangGu,项目名称:commons,代码行数:27,代码来源:ide.py

示例10: _find_paths

# 需要导入模块: from twitter.pants.base import Target [as 别名]
# 或者: from twitter.pants.base.Target import get [as 别名]
  def _find_paths(cls, from_target, to_target, log, find_all):
    from_target, to_target = cls._coerce_to_targets(from_target, to_target)

    log.debug('Looking for path from %s to %s' % (from_target.address.reference(), to_target.address.reference()))

    paths_found = False

    queue = [([from_target], 0)]
    while True:
      if not queue:
        if not paths_found:
          print 'no path found from %s to %s!' % (from_target.address.reference(), to_target.address.reference())
        break

      path, indent = queue.pop(0)
      next_target = path[-1]
      log.debug('%sexamining %s' % ('  ' * indent, next_target))

      if next_target == to_target:
        if paths_found:
          print ''
        else:
          paths_found = True
        for target in path:
          print '%s' % target.address.reference()
        if find_all:
          continue
        else:
          break

      if hasattr(next_target, 'dependency_addresses'):
        for address in next_target.dependency_addresses:
          dep = Target.get(address)
          queue.append((path + [dep], indent + 1))
开发者ID:BabyDuncan,项目名称:commons,代码行数:36,代码来源:paths.py

示例11: target

# 需要导入模块: from twitter.pants.base import Target [as 别名]
# 或者: from twitter.pants.base.Target import get [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))
开发者ID:alfss,项目名称:commons,代码行数:10,代码来源:build_root_test.py

示例12: __init__

# 需要导入模块: from twitter.pants.base import Target [as 别名]
# 或者: from twitter.pants.base.Target import get [as 别名]
  def __init__(self, root_dir, parser, argv):
    Command.__init__(self, root_dir, parser, argv)

    self.project_name = self.options.project_name
    self.scala_compiler_profile = self.scala_compiler_profile_by_version[self.options.scala_version]

    addresses = self._parse_addresses() if self.args else Command.scan_addresses(root_dir)
    self.targets = [ Target.get(address) for address in addresses ]
开发者ID:adamsxu,项目名称:commons,代码行数:10,代码来源:ide.py

示例13: __init__

# 需要导入模块: from twitter.pants.base import Target [as 别名]
# 或者: from twitter.pants.base.Target import get [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)
开发者ID:dynamicguy,项目名称:commons,代码行数:60,代码来源:py.py

示例14: parse

# 需要导入模块: from twitter.pants.base import Target [as 别名]
# 或者: from twitter.pants.base.Target import get [as 别名]
  def parse(self, spec):
    """Parses the given target spec into one or more targets.

    Returns a generator of target, address pairs in which the target may be None if the address
    points to a non-existent target.
    """
    for address in self._parse_addresses(spec):
      target = Target.get(address)
      yield target, address
开发者ID:patricklaw,项目名称:twitter-commons,代码行数:11,代码来源:goal.py

示例15: _find_targets

# 需要导入模块: from twitter.pants.base import Target [as 别名]
# 或者: from twitter.pants.base.Target import get [as 别名]
 def _find_targets(self):
   if len(self.context.target_roots) > 0:
     for target in self.context.target_roots:
       yield target
   else:
     for buildfile in BuildFile.scan_buildfiles(get_buildroot()):
       target_addresses = Target.get_all_addresses(buildfile)
       for target_address in target_addresses:
         yield Target.get(target_address)
开发者ID:CodeWarltz,项目名称:commons,代码行数:11,代码来源:filemap.py


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