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)
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)
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)
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)
def parse_address_map(self, json): path = '/dev/null' address_map = AddressMap.parse(path, json, self._symbol_table_cls, self._parser_cls) self.assertEqual(path, address_map.path) yield address_map
def parse_address_map(self, json): path = '/dev/null' address_map = AddressMap.parse(path, json, self._parser) self.assertEqual(path, address_map.path) yield address_map
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)}) ])
def test_mismatching_paths(self): with self.assertRaises(DifferingFamiliesError): AddressFamily.create('one', [ AddressMap('/dev/null/one/0', {}), AddressMap('/dev/null/two/0', {}) ])
def parse_address_map(self, json, exclude_patterns=None): path = '/dev/null' address_map = AddressMap.parse(path, json, self._symbol_table_cls, self._parser_cls, exclude_patterns) self.assertEqual(path, address_map.path) yield address_map
def test_mismatching_paths(self) -> None: with self.assertRaises(DifferingFamiliesError): AddressFamily.create( "one", [AddressMap("/dev/null/one/0", {}), AddressMap("/dev/null/two/0", {})] )