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


Python Target.get方法代码示例

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


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

示例1: test_sibling_references

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

示例2: _owning_targets

# 需要导入模块: from twitter.pants.base.target import Target [as 别名]
# 或者: from twitter.pants.base.target.Target import get [as 别名]
 def _owning_targets(self, path):
   for build_file in self._candidate_owners(path):
     is_build_file = (build_file.full_path == os.path.join(get_buildroot(), path))
     for address in Target.get_all_addresses(build_file):
       target = Target.get(address)
       if target and (is_build_file or (target.has_sources() and self._owns(target, path))):
         yield target
开发者ID:alfss,项目名称:commons,代码行数:9,代码来源:what_changed.py

示例3: _find_path

# 需要导入模块: from twitter.pants.base.target import Target [as 别名]
# 或者: from twitter.pants.base.target.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:CodeWarltz,项目名称:commons,代码行数:31,代码来源:paths.py

示例4: resolve

# 需要导入模块: from twitter.pants.base.target import Target [as 别名]
# 或者: from twitter.pants.base.target.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 TargetDefinitionException(self, '%s%s' % (self._DEFINITION_ERROR_MSG, self.address))
   for dep in resolved.resolve():
     yield dep
开发者ID:CodeWarltz,项目名称:commons,代码行数:9,代码来源:pants_target.py

示例5: target

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

示例6: _get_target

# 需要导入模块: from twitter.pants.base.target import Target [as 别名]
# 或者: from twitter.pants.base.target.Target import get [as 别名]
def _get_target(address):
  try:
    address = Address.parse(get_buildroot(), address, is_relative=False)
  except IOError as e:
    raise TaskError('Failed to parse address: %s: %s' % (address, e))
  match = Target.get(address)
  if not match:
    raise TaskError('Invalid target address: %s' % address)
  return match
开发者ID:dynamicguy,项目名称:commons,代码行数:11,代码来源:filter.py

示例7: _find_targets

# 需要导入模块: from twitter.pants.base.target import Target [as 别名]
# 或者: from twitter.pants.base.target.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:FernandoG26,项目名称:commons,代码行数:11,代码来源:filemap.py

示例8: parse

# 需要导入模块: from twitter.pants.base.target import Target [as 别名]
# 或者: from twitter.pants.base.target.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:alandge,项目名称:twitter-commons,代码行数:11,代码来源:goal.py

示例9: parse_url

# 需要导入模块: from twitter.pants.base.target import Target [as 别名]
# 或者: from twitter.pants.base.target.Target import get [as 别名]
 def parse_url(spec):
   match = MarkdownToHtml.PANTS_LINK.match(spec)
   if match:
     page = Target.get(Address.parse(get_buildroot(), match.group(1)))
     anchor = match.group(2) or ''
     if not page:
       raise TaskError('Invalid link %s' % match.group(1))
     alias, url = url_builder(page, config=get_config(page))
     return alias, url + anchor
   else:
     return spec, spec
开发者ID:CodeWarltz,项目名称:commons,代码行数:13,代码来源:markdown_to_html.py

示例10: _coerce_to_targets

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

示例11: _owning_targets

# 需要导入模块: from twitter.pants.base.target import Target [as 别名]
# 或者: from twitter.pants.base.target.Target import get [as 别名]
  def _owning_targets(self, path):
    for build_file in self._candidate_owners(path):
      is_build_file = (build_file.full_path == os.path.join(get_buildroot(), path))
      for address in Target.get_all_addresses(build_file):
        target = Target.get(address)

        # A synthesized target can never own permanent files on disk
        if target != target.derived_from:
          # TODO(John Sirois): tighten up the notion of targets written down in a BUILD by a user
          # vs. targets created by pants at runtime.
          continue

        if target and (is_build_file or ((target.has_sources() or target.has_resources)
                                         and self._owns(target, path))):
          yield target
开发者ID:FernandoG26,项目名称:commons,代码行数:17,代码来源:what_changed.py

示例12: __init__

# 需要导入模块: from twitter.pants.base.target import Target [as 别名]
# 或者: from twitter.pants.base.target.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._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:alandge,项目名称:twitter-commons,代码行数:18,代码来源:setup_py.py

示例13: console_output

# 需要导入模块: from twitter.pants.base.target import Target [as 别名]
# 或者: from twitter.pants.base.target.Target import get [as 别名]
  def console_output(self, _):
    buildfiles = OrderedSet()
    if self._dependees_type:
      base_paths = OrderedSet()
      for dependees_type in self._dependees_type:
        try:
          # Try to do a fully qualified import 1st for filtering on custom types.
          from_list, module, type_name = dependees_type.rsplit('.', 2)
          __import__('%s.%s' % (from_list, module), fromlist=[from_list])
        except (ImportError, ValueError):
          # Fall back on pants provided target types.
          if hasattr(twitter.pants.base.build_file_context, dependees_type):
            type_name = getattr(twitter.pants.base.build_file_context, dependees_type)
          else:
            raise TaskError('Invalid type name: %s' % dependees_type)
        # Find the SourceRoot for the given input type
        base_paths.update(SourceRoot.roots(type_name))
      if not base_paths:
        raise TaskError('No SourceRoot set for any target type in %s.' % self._dependees_type +
                        '\nPlease define a source root in BUILD file as:' +
                        '\n\tsource_root(\'<src-folder>\', %s)' % ', '.join(self._dependees_type))
      for base_path in base_paths:
        buildfiles.update(BuildFile.scan_buildfiles(get_buildroot(), base_path))
    else:
      buildfiles = BuildFile.scan_buildfiles(get_buildroot())

    dependees_by_target = defaultdict(set)
    for buildfile in buildfiles:
      for address in Target.get_all_addresses(buildfile):
        for target in Target.get(address).resolve():
          # TODO(John Sirois): tighten up the notion of targets written down in a BUILD by a
          # user vs. targets created by pants at runtime.
          target = self.get_concrete_target(target)
          if hasattr(target, 'dependencies'):
            for dependencies in target.dependencies:
              for dependency in dependencies.resolve():
                dependency = self.get_concrete_target(dependency)
                dependees_by_target[dependency].add(target)

    roots = set(self.context.target_roots)
    if self._closed:
      for root in roots:
        yield str(root.address)

    for dependant in self.get_dependants(dependees_by_target, roots):
      yield str(dependant.address)
开发者ID:CodeWarltz,项目名称:commons,代码行数:48,代码来源:dependees.py

示例14: _find_paths_rec

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

    if from_target not in cls.all_paths or to_target not in cls.all_paths[from_target]:
      paths = []
      if hasattr(from_target, 'dependency_addresses'):
        for address in from_target.dependency_addresses:
          dep = Target.get(address)
          for path in cls._find_paths_rec(dep, to_target):
            new_path = copy.copy(path)
            new_path.insert(0, from_target)
            paths.append(new_path)

      cls.all_paths[from_target][to_target] = paths

    return cls.all_paths[from_target][to_target]
开发者ID:CodeWarltz,项目名称:commons,代码行数:19,代码来源:paths.py

示例15: console_output

# 需要导入模块: from twitter.pants.base.target import Target [as 别名]
# 或者: from twitter.pants.base.target.Target import get [as 别名]
  def console_output(self, _):
    dependees_by_target = defaultdict(set)
    for buildfile in BuildFile.scan_buildfiles(get_buildroot()):
      for address in Target.get_all_addresses(buildfile):
        for target in Target.get(address).resolve():
          if hasattr(target, 'dependencies'):
            for dependencies in target.dependencies:
              for dependency in dependencies.resolve():
                dependees_by_target[dependency].add(target)

    roots = set(self.context.target_roots)
    if self._closed:
      for root in roots:
        yield str(root.address)

    for dependant in self.get_dependants(dependees_by_target, roots):
      yield str(dependant.address)
开发者ID:alfss,项目名称:commons,代码行数:19,代码来源:dependees.py


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