Beispiel #1
0
async def hydrate_sources(
        sources_field: SourcesField,
        glob_match_error_behavior: GlobMatchErrorBehavior) -> HydratedField:
    """Given a SourcesField, request a Snapshot for its path_globs and create an EagerFilesetWithSpec.
  """
    # TODO(#5864): merge the target's selection of --glob-expansion-failure (which doesn't exist yet)
    # with the global default!
    path_globs = dataclasses.replace(
        sources_field.path_globs,
        glob_match_error_behavior=glob_match_error_behavior)
    snapshot = await Get(Snapshot, PathGlobs, path_globs)
    fileset_with_spec = _eager_fileset_with_spec(
        sources_field.address.spec_path, sources_field.filespecs, snapshot)
    sources_field.validate_fn(fileset_with_spec)
    return HydratedField(sources_field.arg, fileset_with_spec)
Beispiel #2
0
async def hydrate_sources(
    sources_field: SourcesField,
    glob_match_error_behavior: GlobMatchErrorBehavior,
) -> HydratedField:
    """Given a SourcesField, request a Snapshot for its path_globs and create an EagerFilesetWithSpec.
  """
    address = sources_field.address
    path_globs = dataclasses.replace(
        sources_field.path_globs,
        glob_match_error_behavior=glob_match_error_behavior,
        # TODO(#9012): add line number referring to the sources field.
        description_of_origin=
        (f"{address.rel_path} for target {address.relative_spec}'s `{sources_field.arg}` field"
         ),
    )
    snapshot = await Get[Snapshot](PathGlobs, path_globs)
    fileset_with_spec = _eager_fileset_with_spec(
        spec_path=address.spec_path,
        filespec=sources_field.filespecs,
        snapshot=snapshot,
    )
    sources_field.validate_fn(fileset_with_spec)
    return HydratedField(sources_field.arg, fileset_with_spec)
Beispiel #3
0
async def hydrate_sources(
    sources_field: SourcesField,
    glob_match_error_behavior: GlobMatchErrorBehavior,
) -> HydratedField:
    """Given a SourcesField, request a Snapshot for its path_globs and create an
    EagerFilesetWithSpec."""
    address = sources_field.address
    path_globs = dataclasses.replace(
        sources_field.path_globs,
        glob_match_error_behavior=glob_match_error_behavior,
        # TODO(#9012): add line number referring to the sources field. When doing this, we'll likely
        # need to `await Get[BuildFileAddress](Address)`.
        description_of_origin=(f"{address}'s `{sources_field.arg}` field"
                               if glob_match_error_behavior !=
                               GlobMatchErrorBehavior.ignore else None),
    )
    snapshot = await Get[Snapshot](PathGlobs, path_globs)
    fileset_with_spec = _eager_fileset_with_spec(
        spec_path=address.spec_path,
        filespec=sources_field.source_globs.filespecs,
        snapshot=snapshot,
    )
    sources_field.validate_fn(fileset_with_spec)
    return HydratedField(sources_field.arg, fileset_with_spec)