async def resolve_address(address_input: AddressInput) -> Address: # Determine the type of the path_component of the input. if address_input.path_component: snapshot = await Get(Snapshot, PathGlobs(globs=(address_input.path_component, ))) is_file, is_dir = bool(snapshot.files), bool(snapshot.dirs) else: # It is an address in the root directory. is_file, is_dir = False, True if is_file: return address_input.file_to_address() elif is_dir: return address_input.dir_to_address() else: raise ResolveError( f"The file or directory '{address_input.path_component}' does not exist on disk in the " f"workspace: cannot resolve '{address_input.target_component}' relative to it." )
async def resolve_address(address_input: AddressInput) -> Address: # Determine the type of the path_component of the input. if address_input.path_component: paths = await Get(Paths, PathGlobs(globs=(address_input.path_component, ))) is_file, is_dir = bool(paths.files), bool(paths.dirs) else: # It is an address in the root directory. is_file, is_dir = False, True if is_file: return address_input.file_to_address() elif is_dir: return address_input.dir_to_address() else: spec = address_input.path_component if address_input.target_component: spec += f":{address_input.target_component}" raise ResolveError( f"The file or directory '{address_input.path_component}' does not exist on disk in the " f"workspace, so the address '{spec}' cannot be resolved.")