summaryrefslogtreecommitdiff
path: root/morphlib/morphloader.py
diff options
context:
space:
mode:
Diffstat (limited to 'morphlib/morphloader.py')
-rw-r--r--morphlib/morphloader.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/morphlib/morphloader.py b/morphlib/morphloader.py
index 637544be..32b5b40b 100644
--- a/morphlib/morphloader.py
+++ b/morphlib/morphloader.py
@@ -120,6 +120,27 @@ class DuplicateChunkError(morphlib.Error):
'in stratum %(stratum_name)s' % locals())
+class EmptyRefError(morphlib.Error):
+
+ def __init__(self, ref_location, morphology):
+ self.ref_location = ref_location
+ self.morphology = morphology
+ morphlib.Error.__init__(
+ self, 'Empty ref found for %(ref_location)s '\
+ 'in %(morphology)s' % locals())
+
+
+class ChunkSpecRefNotStringError(morphlib.Error):
+
+ def __init__(self, ref_value, chunk_name, stratum_name):
+ self.ref_value = ref_value
+ self.chunk_name = chunk_name
+ self.stratum_name = stratum_name
+ morphlib.Error.__init__(
+ self, 'Ref %(ref_value)s for %(chunk_name)s '\
+ 'in stratum %(stratum_name)s is not a string' % locals())
+
+
class SystemStrataNotListError(morphlib.Error):
def __init__(self, system_name, strata_type):
@@ -130,6 +151,7 @@ class SystemStrataNotListError(morphlib.Error):
self, 'System %(system_name)s has the wrong type for its strata: '\
'%(typename)s, expected list' % locals())
+
class DuplicateStratumError(morphlib.Error):
def __init__(self, system_name, stratum_name):
@@ -366,6 +388,17 @@ class MorphologyLoader(object):
raise DuplicateChunkError(morph['name'], name)
names.add(name)
+ # All chunk refs must be strings.
+ for spec in morph['chunks']:
+ if 'ref' in spec:
+ ref = spec['ref']
+ if ref == None:
+ raise EmptyRefError(
+ spec.get('alias', spec['name']), morph.filename)
+ elif not isinstance(ref, basestring):
+ raise ChunkSpecRefNotStringError(
+ ref, spec.get('alias', spec['name']), morph.filename)
+
# Require build-dependencies for the stratum itself, unless
# it has chunks built in bootstrap mode.
if 'build-depends' not in morph: