From ef5e11a25c56e5f0f6f755f0f7c7be5584c4b8e5 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Tue, 7 Jan 2014 17:10:06 +0000 Subject: 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. --- morphlib/source.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/morphlib/source.py b/morphlib/source.py index 99b0a993..8673af79 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, -- cgit v1.2.1