async def parse_address_family(address_mapper: AddressMapper, directory: Dir) -> AddressFamily: """Given an AddressMapper and a directory, return an AddressFamily. The AddressFamily may be empty, but it will not be None. """ path_globs = PathGlobs( globs=( *(os.path.join(directory.path, p) for p in address_mapper.build_patterns), *(f"!{p}" for p in address_mapper.build_ignore_patterns), ) ) snapshot = await Get[Snapshot](PathGlobs, path_globs) files_content = await Get[FilesContent](Digest, 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: address_maps.append( AddressMap.parse( filecontent_product.path, filecontent_product.content, address_mapper.parser ) ) return AddressFamily.create(directory.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.create('', 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 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. """ 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_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 = [] for filecontent_product in files_content: 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, 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_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.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