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


Python InternalTarget.sort_targets方法代码示例

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


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

示例1: testSort

# 需要导入模块: from twitter.pants.targets import InternalTarget [as 别名]
# 或者: from twitter.pants.targets.InternalTarget import sort_targets [as 别名]
  def testSort(self):
    a = MockTarget('a', [])
    b = MockTarget('b', [a])
    c = MockTarget('c', [b])
    d = MockTarget('d', [c, a])
    e = MockTarget('e', [d])

    self.assertEquals(InternalTarget.sort_targets([a,b,c,d,e]), [e,d,c,b,a])
    self.assertEquals(InternalTarget.sort_targets([b,d,a,e,c]), [e,d,c,b,a])
    self.assertEquals(InternalTarget.sort_targets([e,d,c,b,a]), [e,d,c,b,a])
开发者ID:BabyDuncan,项目名称:commons,代码行数:12,代码来源:test_internal.py

示例2: testDetectCycleDirect

# 需要导入模块: from twitter.pants.targets import InternalTarget [as 别名]
# 或者: from twitter.pants.targets.InternalTarget import sort_targets [as 别名]
  def testDetectCycleDirect(self):
    a = MockTarget('a')

    # no cycles yet
    InternalTarget.sort_targets([a])
    a.internal_dependencies = [a]
    try:
      InternalTarget.sort_targets([a])
      self.fail("Expected a cycle to be detected")
    except InternalTarget.CycleException:
      # expected
      pass
开发者ID:bonifaido,项目名称:commons,代码行数:14,代码来源:test-internal.py

示例3: test_detect_cycle_direct

# 需要导入模块: from twitter.pants.targets import InternalTarget [as 别名]
# 或者: from twitter.pants.targets.InternalTarget import sort_targets [as 别名]
  def test_detect_cycle_direct(self):
    a = MockTarget('a')

    # no cycles yet
    InternalTarget.sort_targets([a])
    a.update_dependencies([a])
    try:
      InternalTarget.sort_targets([a])
      self.fail("Expected a cycle to be detected")
    except InternalTarget.CycleException:
      # expected
      pass
开发者ID:CodeWarltz,项目名称:commons,代码行数:14,代码来源:test_internal.py

示例4: testDetectIndirect

# 需要导入模块: from twitter.pants.targets import InternalTarget [as 别名]
# 或者: from twitter.pants.targets.InternalTarget import sort_targets [as 别名]
  def testDetectIndirect(self):
    c = MockTarget('c')
    b = MockTarget('b', c)
    a = MockTarget('a', c, b)

    # no cycles yet
    InternalTarget.sort_targets([a])

    c.internal_dependencies = [a]
    try:
      InternalTarget.sort_targets([a])
      self.fail("Expected a cycle to be detected")
    except InternalTarget.CycleException:
      # expected
      pass
开发者ID:bonifaido,项目名称:commons,代码行数:17,代码来源:test-internal.py

示例5: exported_targets

# 需要导入模块: from twitter.pants.targets import InternalTarget [as 别名]
# 或者: from twitter.pants.targets.InternalTarget import sort_targets [as 别名]
  def exported_targets(self):
    candidates = set()
    if self.transitive:
      candidates.update(self.context.targets())
    else:
      candidates.update(self.context.target_roots)

      def get_synthetic(lang, target):
        mappings = self.context.products.get(lang).get(target)
        if mappings:
          for generated in mappings.itervalues():
            for synthetic in generated:
              yield synthetic

      # Handle the case where a code gen target is in the listed roots and the thus the publishable
      # target is a synthetic twin generated by a code gen task upstream.
      for candidate in self.context.target_roots:
        candidates.update(get_synthetic('java', candidate))
        candidates.update(get_synthetic('scala', candidate))

    def exportable(tgt):
      return tgt in candidates and tgt.is_exported

    return OrderedSet(filter(exportable,
                             reversed(InternalTarget.sort_targets(filter(exportable, candidates)))))
开发者ID:CodeWarltz,项目名称:commons,代码行数:27,代码来源:jar_publish.py

示例6: _compute_transitive_deps_by_target

# 需要导入模块: from twitter.pants.targets import InternalTarget [as 别名]
# 或者: from twitter.pants.targets.InternalTarget import sort_targets [as 别名]
 def _compute_transitive_deps_by_target(self):
   # Sort from least to most dependent.
   sorted_targets = reversed(InternalTarget.sort_targets(self._context.targets()))
   transitive_deps_by_target = defaultdict(set)
   # Iterate in dep order, to accumulate the transitive deps for each target.
   for target in sorted_targets:
     transitive_deps = set()
     if hasattr(target, 'dependencies'):
       for dep in target.dependencies:
         transitive_deps.update(transitive_deps_by_target.get(dep, []))
         transitive_deps.add(dep)
       transitive_deps_by_target[target] = transitive_deps
   return transitive_deps_by_target
开发者ID:theyelllowdart,项目名称:commons,代码行数:15,代码来源:jvm_dependency_analyzer.py

示例7: exported_targets

# 需要导入模块: from twitter.pants.targets import InternalTarget [as 别名]
# 或者: from twitter.pants.targets.InternalTarget import sort_targets [as 别名]
 def exported_targets(self):
   candidates = set(self.context.targets() if self.transitive else self.context.target_roots)
   def exportable(target):
     return target in candidates and is_exported(target) and is_internal(target)
   return OrderedSet(filter(exportable,
                            reversed(InternalTarget.sort_targets(filter(exportable, candidates)))))
开发者ID:steliokontos,项目名称:commons,代码行数:8,代码来源:jar_publish.py

示例8: extract_target

# 需要导入模块: from twitter.pants.targets import InternalTarget [as 别名]
# 或者: from twitter.pants.targets.InternalTarget import sort_targets [as 别名]

#.........这里部分代码省略.........
          dependencies[key] = jar
    return target

  # chunk up our targets by type & custom build xml
  coalesced = InternalTarget.coalesce_targets(java_targets, discriminator)
  coalesced = list(reversed(coalesced))

  start_type = discriminator(coalesced[0])
  start = 0
  descriptors = []

  for current in range(0, len(coalesced)):
    current_target = coalesced[current]
    current_type = discriminator(current_target)

    if current_target.custom_antxml_path:
      if start < current:
        # if we have a type chunk to our left, record it
        descriptors.append((start_type, coalesced[start:current]))

      # record a chunk containing just the target that has the custom build xml to be conservative
      descriptors.append((current_type, [current_target]))
      start = current + 1
      if current < (len(coalesced) - 1):
        start_type = discriminator(coalesced[start])

    elif start_type != current_type:
      # record the type chunk we just left
      descriptors.append((start_type, coalesced[start:current]))
      start = current
      start_type = current_type

  if start < len(coalesced):
    # record the tail chunk
    descriptors.append((start_type, coalesced[start:]))

  # build meta targets aggregated from the chunks and keep track of which targets end up in which
  # meta targets
  meta_targets_by_target_id = dict()
  targets_by_meta_target = []
  for (ttype, targets), index in zip(descriptors, reversed(range(0, len(descriptors)))):
    meta_target = resolve_conflicts(create_target(ttype, meta_target_base_name, index, targets))
    targets_by_meta_target.append((meta_target, targets))
    for target in targets:
      meta_targets_by_target_id[target._id] = meta_target

  # calculate the other meta-targets (if any) each meta-target depends on
  extra_targets_by_meta_target = []
  for meta_target, targets in targets_by_meta_target:
    meta_deps = set()
    custom_antxml_path = None
    for target in targets:
      if target.custom_antxml_path:
        custom_antxml_path = target.custom_antxml_path
      for dep in target.resolved_dependencies:
        if is_jvm(dep):
          meta = meta_targets_by_target_id[dep._id]
          if meta != meta_target:
            meta_deps.add(meta)
    extra_targets_by_meta_target.append((meta_target, meta_deps, custom_antxml_path))

  def lift_excludes(meta_target):
    excludes = set()
    def lift(target):
      if target.excludes:
        excludes.update(target.excludes)
      for jar_dep in target.jar_dependencies:
        excludes.update(jar_dep.excludes)
      for internal_dep in target.internal_dependencies:
        lift(internal_dep)
    lift(meta_target)
    return excludes

  # link in the extra inter-meta deps
  meta_targets = []
  for meta_target, extra_deps, custom_antxml_path in extra_targets_by_meta_target:
    meta_targets.append(meta_target)
    meta_target.update_dependencies(extra_deps)
    meta_target.excludes = lift_excludes(meta_target)
    meta_target.custom_antxml_path = custom_antxml_path

  sorted_meta_targets = InternalTarget.sort_targets(meta_targets)
  def prune_metas(target):
    if sorted_meta_targets:
      try:
        sorted_meta_targets.remove(target)
      except ValueError:
        # we've already removed target in the current walk
        pass

  # link any disconnected meta_target graphs so we can return 1 root target
  root = None
  while sorted_meta_targets:
    new_root = sorted_meta_targets[0]
    new_root.walk(prune_metas, is_jvm)
    if root:
      new_root.update_dependencies([root])
    root = new_root

  return root
开发者ID:crnt,项目名称:commons,代码行数:104,代码来源:bang.py


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