summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2016-02-13 16:54:10 +0000
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2016-02-19 00:08:26 +0000
commita88aa98d34ace2f3bab236e7acfffee73584b228 (patch)
tree0aaef11d0be84623672d476a2666a96e76de7d30
parentfc0b420549a7e0cff0df0b62ba975325bbf9b6c2 (diff)
downloadmorph-a88aa98d34ace2f3bab236e7acfffee73584b228.tar.gz
Warning when different names in system/strata
Now is an warning when the name of a stratum in a system is different from the name of the stratum in the stratum file. Example of the warning message: WARNING: Name 'build-essential-name' doesn't match 'build-essential' in morphology: strata/build-essential.morph https://storyboard.baserock.org/#!/story/15 Change-Id: Ifbe8d98e64a768e4e238d2213ffaf575789dd9e2
-rw-r--r--morphlib/sourceresolver.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/morphlib/sourceresolver.py b/morphlib/sourceresolver.py
index 80f8e25b..3d4dd478 100644
--- a/morphlib/sourceresolver.py
+++ b/morphlib/sourceresolver.py
@@ -300,15 +300,19 @@ class SourceResolver(object):
system_filenames,
visit,
predefined_split_rules):
- definitions_queue = collections.deque(system_filenames)
+ # Initialise definitions_queue with tuples (name, filename).
+ # We don't need system's filename, so use 'None'
+ definitions_queue = collections.deque((None, f)
+ for f in system_filenames)
chunk_queue = set()
def get_morphology(filename):
return self._get_morphology(resolved_morphologies,
definitions_checkout_dir, morph_loader,
filename)
+
while definitions_queue:
- filename = definitions_queue.popleft()
+ name, filename = definitions_queue.popleft()
morphology = get_morphology(filename)
@@ -323,13 +327,21 @@ class SourceResolver(object):
raise cliapp.AppException(
"Cannot build a morphology of type 'cluster'.")
elif morphology['kind'] == 'system':
- definitions_queue.extend(
- sanitise_morphology_path(s['morph'])
+ # name is not mandatory, use 'None' if not definied.
+ definitions_queue.extend((s.get('name'),
+ sanitise_morphology_path(s['morph']))
for s in morphology['strata'])
elif morphology['kind'] == 'stratum':
+ # If we have the name of the stratum, fail if it doesn't
+ # match with the one set in the stratum file.
+ if name and name != morphology.get('name'):
+ warnings.warn("Name '%s' doesn't match '%s' in "
+ "morpholgy: %s" % (morphology['name'], name,
+ filename))
if morphology['build-depends']:
- definitions_queue.extend(
- sanitise_morphology_path(s['morph'])
+ # build-depends don't have names. Use 'None' as name.
+ definitions_queue.extend((None,
+ sanitise_morphology_path(s['morph']))
for s in morphology['build-depends'])
for c in morphology['chunks']:
if 'morph' in c: