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


Python AddressFamily.create方法代码示例

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


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

示例1: test_duplicate_names

# 需要导入模块: from pants.engine.mapper import AddressFamily [as 别名]
# 或者: from pants.engine.mapper.AddressFamily import create [as 别名]
 def test_duplicate_names(self):
   with self.assertRaises(DuplicateNameError):
     AddressFamily.create('name/space',
                          [AddressMap('name/space/0',
                                      {'one': Thing(name='one', age=42)}),
                           AddressMap('name/space/1',
                                      {'one': Thing(name='one', age=37)})])
开发者ID:RobinTec,项目名称:pants,代码行数:9,代码来源:test_mapper.py

示例2: test_create_single

# 需要导入模块: from pants.engine.mapper import AddressFamily [as 别名]
# 或者: from pants.engine.mapper.AddressFamily import create [as 别名]
 def test_create_single(self):
   address_family = AddressFamily.create('',
                                         [AddressMap('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:RobinTec,项目名称:pants,代码行数:12,代码来源:test_mapper.py

示例3: test_create_multiple

# 需要导入模块: from pants.engine.mapper import AddressFamily [as 别名]
# 或者: from pants.engine.mapper.AddressFamily import create [as 别名]
  def test_create_multiple(self):
    address_family = AddressFamily.create('name/space',
                                          [AddressMap('name/space/0',
                                                      {'one': Thing(name='one', age=42)}),
                                           AddressMap('name/space/1',
                                                      {'two': Thing(name='two', age=37)})])

    self.assertEqual('name/space', address_family.namespace)
    self.assertEqual({Address.parse('name/space:one'): Thing(name='one', age=42),
                      Address.parse('name/space:two'): Thing(name='two', age=37)},
                     address_family.addressables)
开发者ID:RobinTec,项目名称:pants,代码行数:13,代码来源:test_mapper.py

示例4: parse_address_family

# 需要导入模块: from pants.engine.mapper import AddressFamily [as 别名]
# 或者: from pants.engine.mapper.AddressFamily import create [as 别名]
def parse_address_family(address_mapper, path, build_files_content):
  """Given the contents of the build files in one directory, return an AddressFamily.

  The AddressFamily may be empty, but it will not be None.
  """
  address_maps = []
  for filepath, filecontent in build_files_content.dependencies:
    address_maps.append(AddressMap.parse(filepath,
                                         filecontent,
                                         address_mapper.symbol_table_cls,
                                         address_mapper.parser_cls))
  return AddressFamily.create(path.path, address_maps)
开发者ID:anubnair,项目名称:pants,代码行数:14,代码来源:graph.py

示例5: parse_address_family

# 需要导入模块: from pants.engine.mapper import AddressFamily [as 别名]
# 或者: from pants.engine.mapper.AddressFamily import create [as 别名]
def parse_address_family(address_mapper, path, build_files):
  """Given the contents of the build files in one directory, return an AddressFamily.

  The AddressFamily may be empty, but it will not be None.
  """
  files_content = build_files.files_content.dependencies
  if not files_content:
    raise ResolveError('Directory "{}" does not contain build files.'.format(path))
  address_maps = []
  paths = (f.path for f in files_content)
  ignored_paths = set(address_mapper.build_ignore_patterns.match_files(paths))
  for filecontent_product in files_content:
    if filecontent_product.path in ignored_paths:
      continue
    address_maps.append(AddressMap.parse(filecontent_product.path,
                                         filecontent_product.content,
                                         address_mapper.parser))
  return AddressFamily.create(path.path, address_maps)
开发者ID:benjyw,项目名称:pants,代码行数:20,代码来源:build_files.py

示例6: parse_address_family

# 需要导入模块: from pants.engine.mapper import AddressFamily [as 别名]
# 或者: from pants.engine.mapper.AddressFamily import create [as 别名]
def parse_address_family(address_mapper, directory):
  """Given an AddressMapper and a directory, return an AddressFamily.

  The AddressFamily may be empty, but it will not be None.
  """
  patterns = tuple(join(directory.path, p) for p in address_mapper.build_patterns)
  path_globs = PathGlobs(include=patterns,
                         exclude=address_mapper.build_ignore_patterns)
  snapshot = yield Get(Snapshot, PathGlobs, path_globs)
  files_content = yield Get(FilesContent, DirectoryDigest, snapshot.directory_digest)

  if not files_content:
    raise ResolveError('Directory "{}" does not contain any BUILD files.'.format(directory.path))
  address_maps = []
  for filecontent_product in files_content.dependencies:
    address_maps.append(AddressMap.parse(filecontent_product.path,
                                         filecontent_product.content,
                                         address_mapper.parser))
  yield AddressFamily.create(directory.path, address_maps)
开发者ID:foursquare,项目名称:pants,代码行数:21,代码来源:build_files.py

示例7: parse_address_family

# 需要导入模块: from pants.engine.mapper import AddressFamily [as 别名]
# 或者: from pants.engine.mapper.AddressFamily import create [as 别名]
def parse_address_family(address_mapper, path, build_files_content):
    """Given the contents of the build files in one directory, return an AddressFamily.

  The AddressFamily may be empty, but it will not be None.
  """
    if not build_files_content.dependencies:
        raise ResolveError('Directory "{}" does not contain build files.'.format(path))
    address_maps = []
    for filecontent_product in build_files_content.dependencies:
        address_maps.append(
            AddressMap.parse(
                filecontent_product.path,
                filecontent_product.content,
                address_mapper.symbol_table_cls,
                address_mapper.parser_cls,
                address_mapper.exclude_patterns,
            )
        )
    return AddressFamily.create(path.path, address_maps)
开发者ID:pantsbuild-osx,项目名称:pants,代码行数:21,代码来源:build_files.py

示例8: test_mismatching_paths

# 需要导入模块: from pants.engine.mapper import AddressFamily [as 别名]
# 或者: from pants.engine.mapper.AddressFamily import create [as 别名]
 def test_mismatching_paths(self):
   with self.assertRaises(DifferingFamiliesError):
     AddressFamily.create('one',
                          [AddressMap('/dev/null/one/0', {}),
                           AddressMap('/dev/null/two/0', {})])
开发者ID:RobinTec,项目名称:pants,代码行数:7,代码来源:test_mapper.py

示例9: test_create_empty

# 需要导入模块: from pants.engine.mapper import AddressFamily [as 别名]
# 或者: from pants.engine.mapper.AddressFamily import create [as 别名]
 def test_create_empty(self):
   # Case where directory exists but is empty.
   address_family = AddressFamily.create('name/space', [])
   self.assertEquals(dict(), address_family.addressables)
开发者ID:RobinTec,项目名称:pants,代码行数:6,代码来源:test_mapper.py


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