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


Python Address.parse方法代码示例

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


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

示例1: test_top_level

# 需要导入模块: from pants.base.address import Address [as 别名]
# 或者: from pants.base.address.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'))
开发者ID:govindkabra,项目名称:pants,代码行数:9,代码来源:test_address.py

示例2: parse_address

# 需要导入模块: from pants.base.address import Address [as 别名]
# 或者: from pants.base.address.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)
开发者ID:govindkabra,项目名称:pants,代码行数:9,代码来源:pants_target.py

示例3: test_sibling_references

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

示例4: make_target

# 需要导入模块: from pants.base.address import Address [as 别名]
# 或者: from pants.base.address.Address import parse [as 别名]
    def make_target(self, spec="", target_type=Target, dependencies=None, derived_from=None, **kwargs):
        """Creates a target and injects it into the test's build graph.

    :param string spec: The target address spec that locates this target.
    :param type target_type: The concrete target subclass to create this new target from.
    :param list dependencies: A list of target instances this new target depends on.
    :param derived_from: The target this new target was derived from.
    :type derived_from: :class:`pants.base.target.Target`
    """
        address = Address.parse(spec)
        target = target_type(name=address.target_name, address=address, build_graph=self.build_graph, **kwargs)
        dependencies = dependencies or []

        self.build_graph.inject_target(
            target, dependencies=[dep.address for dep in dependencies], derived_from=derived_from
        )

        # TODO(John Sirois): This re-creates a little bit too much work done by the BuildGraph.
        # Fixup the BuildGraph to deal with non BuildFileAddresses better and just leverage it.
        for traversable_dependency_spec in target.traversable_dependency_specs:
            traversable_dependency_address = Address.parse(traversable_dependency_spec, relative_to=address.spec_path)
            traversable_dependency_target = self.build_graph.get_target(traversable_dependency_address)
            if not traversable_dependency_target:
                raise ValueError(
                    "Tests must make targets for traversable dependency specs ahead of them "
                    "being traversed, {} tried to traverse {} which does not exist.".format(
                        target, traversable_dependency_address
                    )
                )
            if traversable_dependency_target not in target.dependencies:
                self.build_graph.inject_dependency(dependent=target.address, dependency=traversable_dependency_address)
                target.mark_transitive_invalidation_hash_dirty()

        return target
开发者ID:Gabriel439,项目名称:pants,代码行数:36,代码来源:base_test.py

示例5: test_parse_from_sub_dir

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

示例6: test_target_invalid

# 需要导入模块: from pants.base.address import Address [as 别名]
# 或者: from pants.base.address.Address import parse [as 别名]
  def test_target_invalid(self):
    self.add_to_build_file('a/BUILD', 'target(name="a")')
    with self.assertRaises(AddressLookupError):
      self.build_graph.inject_address_closure(Address.parse('a:nope'))

    self.add_to_build_file('b/BUILD', 'target(name="a")')
    with self.assertRaises(AddressLookupError):
      self.build_graph.inject_address_closure(Address.parse('b'))
    with self.assertRaises(AddressLookupError):
      self.build_graph.inject_address_closure(Address.parse('b:b'))
开发者ID:tsdeng,项目名称:pants,代码行数:12,代码来源:test_build_graph.py

示例7: test_create_single

# 需要导入模块: from pants.base.address import Address [as 别名]
# 或者: from pants.base.address.Address import parse [as 别名]
 def test_create_single(self):
   address_family = AddressFamily.create('/dev/null',
                                         [AddressMap('/dev/null/0', {
                                           'one': Thing(name='one', age=42),
                                           'two': Thing(name='two', age=37)
                                         })])
   self.assertEqual('', address_family.namespace)
   self.assertEqual({Address.parse('//:one'): Thing(name='one', age=42),
                     Address.parse('//:two'): Thing(name='two', age=37)},
                    address_family.addressables)
开发者ID:priyakoth,项目名称:pants,代码行数:12,代码来源:test_mapper.py

示例8: test_resolve_cache

# 需要导入模块: from pants.base.address import Address [as 别名]
# 或者: from pants.base.address.Address import parse [as 别名]
  def test_resolve_cache(self):
    graph = self.create_json_graph()

    nonstrict_address = Address.parse('examples/graph_test:nonstrict')
    nonstrict = graph.resolve(nonstrict_address)
    self.assertIs(nonstrict, graph.resolve(nonstrict_address))

    # The already resolved `nonstrict` interior node should be re-used by `java1`.
    java1_address = Address.parse('examples/graph_test:java1')
    java1 = graph.resolve(java1_address)
    self.assertIs(nonstrict, java1.configurations[1])

    self.assertIs(java1, graph.resolve(java1_address))
开发者ID:priyakoth,项目名称:pants,代码行数:15,代码来源:test_graph.py

示例9: _synthesize_resources_target

# 需要导入模块: from pants.base.address import Address [as 别名]
# 或者: from pants.base.address.Address import parse [as 别名]
  def _synthesize_resources_target(self):
    # Create an address for the synthetic target.
    spec = self.address.spec + '_synthetic_resources'
    synthetic_address = Address.parse(spec=spec)
    # For safety, ensure an address that's not used already, even though that's highly unlikely.
    while self._build_graph.contains_address(synthetic_address):
      spec += '_'
      synthetic_address = Address.parse(spec=spec)

    self._build_graph.inject_synthetic_target(synthetic_address, Resources,
                                              sources=self.payload.resources.source_paths,
                                              derived_from=self)
    return self._build_graph.get_target(synthetic_address)
开发者ID:Gabriel439,项目名称:pants,代码行数:15,代码来源:python_target.py

示例10: test_invalidation_relative

# 需要导入模块: from pants.base.address import Address [as 别名]
# 或者: from pants.base.address.Address import parse [as 别名]
  def test_invalidation_relative(self):
    resolved = self.address_mapper.resolve(Address.parse('a/b'))
    a_b_target = Target(name='b',
                        dependencies=['//d:e'],
                        configurations=['//a', Configuration(embedded='yes')])
    self.assertEqual(a_b_target, resolved)

    build_file = os.path.join(self.build_root, 'a/b/b.BUILD.json')
    os.unlink(build_file)
    self.assertIs(resolved, self.address_mapper.resolve(Address.parse('a/b')))

    self.address_mapper.invalidate_build_file('a/b/b.BUILD.json')
    with self.assertRaises(ResolveError):
      self.address_mapper.resolve(Address.parse('a/b'))
开发者ID:priyakoth,项目名称:pants,代码行数:16,代码来源:test_mapper.py

示例11: create_sources_field

# 需要导入模块: from pants.base.address import Address [as 别名]
# 或者: from pants.base.address.Address import parse [as 别名]
  def create_sources_field(self, sources, sources_rel_path, address=None, key_arg=None):
    """Factory method to create a SourcesField appropriate for the type of the sources object.

    Note that this method is called before the call to Target.__init__ so don't expect fields to
    be populated!
    :return: a payload field object representing the sources parameter
    :rtype: SourcesField
    """

    if isinstance(sources, Addresses):
      # Currently, this is only created by the result of from_target() which takes a single argument
      if len(sources.addresses) != 1:
        raise self.WrongNumberOfAddresses(
          "Expected a single address to from_target() as argument to {spec}"
          .format(spec=address.spec))
      referenced_address = Address.parse(sources.addresses[0], relative_to=sources.rel_path)
      return DeferredSourcesField(ref_address=referenced_address)
    elif isinstance(sources, FilesetWithSpec):
      filespec = sources.filespec
    else:
      sources = sources or []
      assert_list(sources, key_arg=key_arg)
      filespec = {'globs': [os.path.join(sources_rel_path, src) for src in (sources or [])]}

    return SourcesField(sources=sources, sources_rel_path=sources_rel_path, filespec=filespec)
开发者ID:priyakoth,项目名称:pants,代码行数:27,代码来源:target.py

示例12: test_cycle_self

# 需要导入模块: from pants.base.address import Address [as 别名]
# 或者: from pants.base.address.Address import parse [as 别名]
 def test_cycle_self(self):
   graph = self.create_json_graph()
   with self.assertRaises(CycleError) as exc:
     graph.resolve(Address.parse('examples/graph_test:self_cycle'))
   self.assertEqual(['* examples/graph_test:self_cycle',
                     '* examples/graph_test:self_cycle'],
                    self.extract_path_tail(exc.exception, 2))
开发者ID:priyakoth,项目名称:pants,代码行数:9,代码来源:test_graph.py

示例13: test_create_bad_targets

# 需要导入模块: from pants.base.address import Address [as 别名]
# 或者: from pants.base.address.Address import parse [as 别名]
  def test_create_bad_targets(self):
    with self.assertRaises(TypeError):
      BuildFileAliases(targets={'fred': object()})

    target = Target('fred', Address.parse('a:b'), BuildGraph(address_mapper=None))
    with self.assertRaises(TypeError):
      BuildFileAliases(targets={'fred': target})
开发者ID:Gabriel439,项目名称:pants,代码行数:9,代码来源:test_build_file_aliases.py

示例14: test_raises_address_not_in_build_file

# 需要导入模块: from pants.base.address import Address [as 别名]
# 或者: from pants.base.address.Address import parse [as 别名]
  def test_raises_address_not_in_build_file(self):
    self.add_to_build_file('BUILD', 'target(name="foo")')

    # Create an address that doesn't exist in an existing BUILD file
    address = Address.parse(':bar')
    with self.assertRaises(BuildFileAddressMapper.AddressNotInBuildFile):
      self.address_mapper.resolve(address)
开发者ID:irfnhm,项目名称:pants,代码行数:9,代码来源:test_build_file_address_mapper.py

示例15: test_invalidation_un_normalized

# 需要导入模块: from pants.base.address import Address [as 别名]
# 或者: from pants.base.address.Address import parse [as 别名]
  def test_invalidation_un_normalized(self):
    resolved = self.address_mapper.resolve(Address.parse('a/b'))
    a_b_target = Target(name='b',
                        dependencies=['//d:e'],
                        configurations=['//a', Configuration(embedded='yes')])
    self.assertEqual(a_b_target, resolved)

    os.unlink(os.path.join(self.build_root, 'a/b/b.BUILD.json'))
    self.assertIs(resolved, self.address_mapper.resolve(Address.parse('a/b')))

    un_normalized_build_root = os.path.join(self.work_dir, 'build_root_linked')
    os.symlink(self.build_root, un_normalized_build_root)
    un_normalized_build_file = os.path.join(un_normalized_build_root, 'a/b/b.BUILD.json')
    self.address_mapper.invalidate_build_file(un_normalized_build_file)
    with self.assertRaises(ResolveError):
      self.address_mapper.resolve(Address.parse('a/b'))
开发者ID:priyakoth,项目名称:pants,代码行数:18,代码来源:test_mapper.py


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