summaryrefslogtreecommitdiff
path: root/morphlib/plugins/list_artifacts_plugin.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2014-06-17 16:36:07 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2014-07-10 13:50:00 +0000
commit3dc83847b8f17793bdab5e978d13d394b48987b0 (patch)
treea67c54b99b7e822ab7f49df3c9df2199435f21ff /morphlib/plugins/list_artifacts_plugin.py
parentae007688d8f1f57b138dafffdfc3683aa7c7730f (diff)
downloadmorph-3dc83847b8f17793bdab5e978d13d394b48987b0.tar.gz
Use exact filenames to refer to morphology files
Rather than repeatedly stripping and appending an optional .morph extension morphology names, instead always use the file path of the morphology relative to the definitions repository. This is an inversion of the previous logic, which would strip the .morph extension and use the "name" internally. The exception to this rule of always using the filename, is that `morph edit CHUNK` uses the name of the morphology as-defined in the stratum. This is based off Adam Coldrick's inital patch, but this version will allow the old style of providing the "name" by converting it into a path if it does not have either a / or a . in it. An unfortunate consequence of this change is that the show-dependencies command's output changed, so the test needed updating.
Diffstat (limited to 'morphlib/plugins/list_artifacts_plugin.py')
-rw-r--r--morphlib/plugins/list_artifacts_plugin.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/morphlib/plugins/list_artifacts_plugin.py b/morphlib/plugins/list_artifacts_plugin.py
index 5e64f708..ad6bc772 100644
--- a/morphlib/plugins/list_artifacts_plugin.py
+++ b/morphlib/plugins/list_artifacts_plugin.py
@@ -55,21 +55,22 @@ class ListArtifactsPlugin(cliapp.Plugin):
'(see help)')
repo, ref = args[0], args[1]
- system_names = map(morphlib.util.strip_morph_extension, args[2:])
+ system_filenames = map(morphlib.util.sanitise_morphology_path,
+ args[2:])
self.lrc, self.rrc = morphlib.util.new_repo_caches(self.app)
self.resolver = morphlib.artifactresolver.ArtifactResolver()
artifact_files = set()
- for system_name in system_names:
+ for system_filename in system_filenames:
system_artifact_files = self.list_artifacts_for_system(
- repo, ref, system_name)
+ repo, ref, system_filename)
artifact_files.update(system_artifact_files)
for artifact_file in sorted(artifact_files):
print artifact_file
- def list_artifacts_for_system(self, repo, ref, system_name):
+ def list_artifacts_for_system(self, repo, ref, system_filename):
'''List all artifact files in the build graph of a single system.'''
# Sadly, we must use a fresh source pool and a fresh list of artifacts
@@ -82,24 +83,24 @@ class ListArtifactsPlugin(cliapp.Plugin):
# different architectures right now.
self.app.status(
- msg='Creating source pool for %s' % system_name, chatty=True)
+ msg='Creating source pool for %s' % system_filename, chatty=True)
source_pool = self.app.create_source_pool(
- self.lrc, self.rrc, (repo, ref, system_name + '.morph'))
+ self.lrc, self.rrc, (repo, ref, system_filename))
self.app.status(
- msg='Resolving artifacts for %s' % system_name, chatty=True)
+ msg='Resolving artifacts for %s' % system_filename, chatty=True)
artifacts = self.resolver.resolve_artifacts(source_pool)
- def find_artifact_by_name(artifacts_list, name):
+ def find_artifact_by_name(artifacts_list, filename):
for a in artifacts_list:
- if a.source.filename == name + '.morph':
+ if a.source.filename == name:
return a
raise ValueError
- system_artifact = find_artifact_by_name(artifacts, system_name)
+ system_artifact = find_artifact_by_name(artifacts, system_filename)
self.app.status(
- msg='Computing cache keys for %s' % system_name, chatty=True)
+ msg='Computing cache keys for %s' % system_filename, chatty=True)
build_env = morphlib.buildenvironment.BuildEnvironment(
self.app.settings, system_artifact.source.morphology['arch'])
ckc = morphlib.cachekeycomputer.CacheKeyComputer(build_env)