summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2014-01-07 17:10:06 (GMT)
committerRichard Maw <richard.maw@codethink.co.uk>2014-01-15 17:43:38 (GMT)
commitef5e11a25c56e5f0f6f755f0f7c7be5584c4b8e5 (patch)
treef2b55a4e19dca2536e101476b13b3825a0ff3835
parent8c92d5783274dd3f154c1609f3e6ce18571b46a9 (diff)
downloadmorph-ef5e11a25c56e5f0f6f755f0f7c7be5584c4b8e5.tar.gz
Source: Create all Artifact objects in advance
This simplifies logic for the ArtifactResolver, since it doesn't need to have its own cache of (source, artifact_name) -> artifact and the artifacts a source produces can be iterated directly with the artifacts attribute, rather than having to iterate over the names and look up the artifact object.
-rw-r--r--morphlib/source.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/morphlib/source.py b/morphlib/source.py
index 99b0a99..8673af7 100644
--- a/morphlib/source.py
+++ b/morphlib/source.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Codethink Limited
+# Copyright (C) 2012-2014 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -30,6 +30,7 @@ class Source(object):
* ``tree`` -- the SHA1 of the tree corresponding to the commit
* ``morphology`` -- the in-memory representation of the morphology we use
* ``filename`` -- basename of the morphology filename
+ * ``artifacts`` -- the set of artifacts this source produces.
'''
@@ -42,6 +43,8 @@ class Source(object):
self.tree = tree
self.morphology = morphology
self.filename = filename
+ self.artifacts = {name: morphlib.artifact.Artifact(self, name)
+ for name in morphology.builds_artifacts}
def __str__(self): # pragma: no cover
return '%s|%s|%s' % (self.repo_name,