def hydrate_bundles(bundles_field, glob_match_error_behavior): """Given a BundlesField, request Snapshots for each of its filesets and create BundleAdaptors.""" path_globs_with_match_errors = [ pg.copy(glob_match_error_behavior=glob_match_error_behavior) for pg in bundles_field.path_globs_list ] snapshot_list = yield [Get(Snapshot, PathGlobs, pg) for pg in path_globs_with_match_errors] spec_path = bundles_field.address.spec_path bundles = [] zipped = zip(bundles_field.bundles, bundles_field.filespecs_list, snapshot_list) for bundle, filespecs, snapshot in zipped: rel_spec_path = getattr(bundle, 'rel_path', spec_path) kwargs = bundle.kwargs() # NB: We `include_dirs=True` because bundle filesets frequently specify directories in order # to trigger a (deprecated) default inclusion of their recursive contents. See the related # deprecation in `pants.backend.jvm.tasks.bundle_create`. kwargs['fileset'] = _eager_fileset_with_spec(rel_spec_path, filespecs, snapshot, include_dirs=True) bundles.append(BundleAdaptor(**kwargs)) yield HydratedField('bundles', bundles)
async def hydrate_bundles( bundles_field: BundlesField, glob_match_error_behavior: GlobMatchErrorBehavior, ) -> HydratedField: """Given a BundlesField, request Snapshots for each of its filesets and create BundleAdaptors.""" address = bundles_field.address path_globs_with_match_errors = [ dataclasses.replace( pg, glob_match_error_behavior=glob_match_error_behavior, # TODO(#9012): add line number referring to the bundles field. description_of_origin= f"{address.rel_path} for target {address.relative_spec}'s `bundles` field", ) for pg in bundles_field.path_globs_list ] snapshot_list = await MultiGet(Get[Snapshot](PathGlobs, pg) for pg in path_globs_with_match_errors) bundles = [] zipped = zip(bundles_field.bundles, bundles_field.filespecs_list, snapshot_list) for bundle, filespecs, snapshot in zipped: rel_spec_path = getattr(bundle, 'rel_path', address.spec_path) kwargs = bundle.kwargs() # NB: We `include_dirs=True` because bundle filesets frequently specify directories in order # to trigger a (deprecated) default inclusion of their recursive contents. See the related # deprecation in `pants.backend.jvm.tasks.bundle_create`. kwargs['fileset'] = _eager_fileset_with_spec(rel_spec_path, filespecs, snapshot, include_dirs=True) bundles.append(BundleAdaptor(**kwargs)) return HydratedField('bundles', bundles)
def hydrate_bundles(bundles_field, snapshot_list): """Given a BundlesField and a Snapshot for each of its filesets create a list of BundleAdaptors.""" bundles = [] zipped = zip(bundles_field.bundles, bundles_field.filespecs_list, snapshot_list) for bundle, filespecs, snapshot in zipped: spec_path = bundles_field.address.spec_path kwargs = bundle.kwargs() kwargs['fileset'] = _eager_fileset_with_spec( getattr(bundle, 'rel_path', spec_path), filespecs, snapshot) bundles.append(BundleAdaptor(**kwargs)) return HydratedField('bundles', bundles)
def hydrate_bundles(bundles_field, files_content_list, excluded_files_list): """Given a BundlesField and FilesContent for each of its filesets create a list of BundleAdaptors.""" bundles = [] zipped = zip(bundles_field.bundles, bundles_field.filespecs_list, files_content_list, excluded_files_list) for bundle, filespecs, files_content, excluded_files in zipped: spec_path = bundles_field.address.spec_path kwargs = bundle.kwargs() kwargs['fileset'] = _eager_fileset_with_spec(spec_path, filespecs, files_content, excluded_files) bundles.append(BundleAdaptor(**kwargs)) return HydratedField('bundles', bundles)
def hydrate_bundles(bundles_field, snapshot_list): """Given a BundlesField and a Snapshot for each of its filesets create a list of BundleAdaptors.""" bundles = [] zipped = zip(bundles_field.bundles, bundles_field.filespecs_list, snapshot_list) for bundle, filespecs, snapshot in zipped: spec_path = bundles_field.address.spec_path kwargs = bundle.kwargs() # NB: We `include_dirs=True` because bundle filesets frequently specify directories in order # to trigger a (deprecated) default inclusion of their recursive contents. See the related # deprecation in `pants.backend.jvm.tasks.bundle_create`. kwargs['fileset'] = _eager_fileset_with_spec(getattr( bundle, 'rel_path', spec_path), filespecs, snapshot, include_dirs=True) bundles.append(BundleAdaptor(**kwargs)) return HydratedField('bundles', bundles)