diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2018-11-01 15:23:20 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2018-12-12 16:32:41 +0000 |
commit | b3dceb16cc56bd8d1c43a7d14e2c0e98d39769c4 (patch) | |
tree | 04ad44e0ab24758dc28fe43952d05deb8ce01c9d /buildstream | |
parent | 3697a61107ea484f6a119ab0275441b75292acce (diff) | |
download | buildstream-b3dceb16cc56bd8d1c43a7d14e2c0e98d39769c4.tar.gz |
cli: Add artifact command group
Diffstat (limited to 'buildstream')
-rw-r--r-- | buildstream/_frontend/cli.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py index 7673a2d71..67958385c 100644 --- a/buildstream/_frontend/cli.py +++ b/buildstream/_frontend/cli.py @@ -1,5 +1,6 @@ import os import sys +from fnmatch import fnmatch import click from .. import _yaml @@ -934,3 +935,44 @@ def workspace_list(app): with app.initialized(): app.stream.workspace_list() + + +############################################################# +# Artifact Commands # +############################################################# +def _classify_artifacts(names, cas, project_directory): + element_targets = [] + artifact_refs = [] + element_globs = [] + artifact_globs = [] + + 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) + else: + if any(c in "*?[" for c in name): + artifact_globs.append(name) + else: + artifact_refs.append(name) + + if element_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) + + if artifact_globs: + artifact_refs.extend(ref for ref in cas.list_refs() + if any(fnmatch(ref, glob) for glob in artifact_globs)) + + return element_targets, artifact_refs + + +@cli.group(short_help="Manipulate cached artifacts") +def artifact(): + """Manipulate cached artifacts""" + pass |