本文整理汇总了Python中pants.engine.mapper.AddressFamily类的典型用法代码示例。如果您正苦于以下问题:Python AddressFamily类的具体用法?Python AddressFamily怎么用?Python AddressFamily使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AddressFamily类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_duplicate_names
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)})])
示例2: test_create_single
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)
示例3: test_create_multiple
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)
示例4: parse_address_family
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)
示例5: parse_address_family
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)
示例6: parse_address_family
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)
示例7: parse_address_family
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)
示例8: test_mismatching_paths
def test_mismatching_paths(self):
with self.assertRaises(DifferingFamiliesError):
AddressFamily.create('one',
[AddressMap('/dev/null/one/0', {}),
AddressMap('/dev/null/two/0', {})])
示例9: test_create_empty
def test_create_empty(self):
# Case where directory exists but is empty.
address_family = AddressFamily.create('name/space', [])
self.assertEquals(dict(), address_family.addressables)