summaryrefslogtreecommitdiff
path: root/morphlib/morphologyfactory.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2012-07-10 15:43:26 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2012-07-11 12:11:23 +0100
commitc95302b925922ca0b900421fe9ecf7842d1949cc (patch)
treea11f2a4526d8466a6e689ff81ebdf52535a7e5cb /morphlib/morphologyfactory.py
parentf653e5fc67c521668d07896ca164c5615c2f9dae (diff)
downloadmorph-c95302b925922ca0b900421fe9ecf7842d1949cc.tar.gz
Move stratum verification to morphologyfactory
I think morphologies should be verified closer to where they are created, not when they are traversed, since this verification would be useful in more code paths. This is in morphologyfactory, rather than Morphology itself, since it may be useful to be able to create morphologies without checking, such as in unit tests.
Diffstat (limited to 'morphlib/morphologyfactory.py')
-rw-r--r--morphlib/morphologyfactory.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/morphlib/morphologyfactory.py b/morphlib/morphologyfactory.py
index 6f9915fb..c84acd52 100644
--- a/morphlib/morphologyfactory.py
+++ b/morphlib/morphologyfactory.py
@@ -45,7 +45,18 @@ class MorphologyFactory(object):
text = self._cat_text(reponame, sha1, filename)
except:
text = self._autodetect_text(reponame, sha1, filename)
- return morphlib.morph2.Morphology(text)
+
+ morphology = morphlib.morph2.Morphology(text)
+ if morphology['kind'] == 'stratum': #pragma: no cover
+ for source in morphology['sources']:
+ if source.get('build-depends', None) is None:
+ name = source.get('name', source.get('repo', 'unknown'))
+ raise morphlib.Error('No build dependencies '
+ 'stratum %s for chunk %s '
+ '(build-depends is a mandatory '
+ 'field)' %
+ (filename, name))
+ return morphology
def _cat_text(self, reponame, sha1, filename):
if self._lrc.has_repo(reponame):