Loading buildstream/_frontend/cli.py +32 −20 Original line number Diff line number Diff line Loading @@ -901,36 +901,48 @@ def workspace_list(app): ############################################################# # Artifact Commands # ############################################################# def _classify_artifacts(names, cas, project_directory): element_targets = [] artifact_refs = [] element_globs = [] artifact_globs = [] def _classify_element_targets(names, project_directory): globs = [] targets = [] unmatched = [] for name in names: if name.endswith('.bst'): if any(c in "*?[" for c in name): element_globs.append(name) else: element_targets.append(name) globs.append(name) else: if any(c in "*?[" for c in name): artifact_globs.append(name) targets.append(name) else: artifact_refs.append(name) unmatched.append(name) if element_globs: if globs: for dirpath, _, filenames in os.walk(project_directory): for filename in filenames: element_path = os.path.join(dirpath, filename).lstrip(project_directory).lstrip('/') if any(fnmatch(element_path, glob) for glob in element_globs): element_targets.append(element_path) element_path = os.path.relpath(os.path.join(dirpath, filename), start=project_directory) if any(fnmatch(element_path, glob) for glob in globs): targets.append(element_path) return targets, unmatched def _classify_artifact_refs(names, cas): globs = [] refs = [] for name in names: if any(c in "*?[" for c in name): globs.append(name) else: refs.append(name) if globs: refs.extend(ref for ref in cas.list_refs() if any(fnmatch(ref, glob) for glob in globs)) return refs def _classify_artifacts(names, cas, project_directory): targets, unmatched = _classify_element_targets(names, project_directory) refs = _classify_artifact_refs(unmatched, cas) if artifact_globs: artifact_refs.extend(ref for ref in cas.list_refs() if any(fnmatch(ref, glob) for glob in artifact_globs)) return targets, refs return element_targets, artifact_refs @cli.group(short_help="Manipulate cached artifacts") Loading Loading
buildstream/_frontend/cli.py +32 −20 Original line number Diff line number Diff line Loading @@ -901,36 +901,48 @@ def workspace_list(app): ############################################################# # Artifact Commands # ############################################################# def _classify_artifacts(names, cas, project_directory): element_targets = [] artifact_refs = [] element_globs = [] artifact_globs = [] def _classify_element_targets(names, project_directory): globs = [] targets = [] unmatched = [] for name in names: if name.endswith('.bst'): if any(c in "*?[" for c in name): element_globs.append(name) else: element_targets.append(name) globs.append(name) else: if any(c in "*?[" for c in name): artifact_globs.append(name) targets.append(name) else: artifact_refs.append(name) unmatched.append(name) if element_globs: if globs: for dirpath, _, filenames in os.walk(project_directory): for filename in filenames: element_path = os.path.join(dirpath, filename).lstrip(project_directory).lstrip('/') if any(fnmatch(element_path, glob) for glob in element_globs): element_targets.append(element_path) element_path = os.path.relpath(os.path.join(dirpath, filename), start=project_directory) if any(fnmatch(element_path, glob) for glob in globs): targets.append(element_path) return targets, unmatched def _classify_artifact_refs(names, cas): globs = [] refs = [] for name in names: if any(c in "*?[" for c in name): globs.append(name) else: refs.append(name) if globs: refs.extend(ref for ref in cas.list_refs() if any(fnmatch(ref, glob) for glob in globs)) return refs def _classify_artifacts(names, cas, project_directory): targets, unmatched = _classify_element_targets(names, project_directory) refs = _classify_artifact_refs(unmatched, cas) if artifact_globs: artifact_refs.extend(ref for ref in cas.list_refs() if any(fnmatch(ref, glob) for glob in artifact_globs)) return targets, refs return element_targets, artifact_refs @cli.group(short_help="Manipulate cached artifacts") Loading