From f412433e6d6c53376ba27dadcc4fb7bed7e2f064 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Thu, 2 Jul 2015 15:09:07 +0100 Subject: schema: Link to build-dep strata correctly, and check chunk names Change-Id: Ibd0a7e2d42e6ac968c8c7076f8b35474bc1eab88 --- schema/parse.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/schema/parse.py b/schema/parse.py index 02f022fe..22f88645 100644 --- a/schema/parse.py +++ b/schema/parse.py @@ -85,7 +85,9 @@ def load_all_morphologies(session, store, path='.'): stratum_build_deps = [] for entry in contents.get('build-depends', []): - build_dep_uri = base_uri + 'strata/' + entry['morph'] + build_dep_file = os.path.join(toplevel_path, entry['morph']) + build_dep_name = get_name_from_morph_file(build_dep_file) + build_dep_uri = base_uri + 'strata/' + build_dep_name stratum_build_deps.append(rdflib.URIRef(build_dep_uri)) stratum.baserock_hasBuildDependency = stratum_build_deps @@ -104,9 +106,18 @@ def load_all_morphologies(session, store, path='.'): chunk_ref_uri = stratum_uri + '/chunk-refs/' + entry['name'] chunk_ref = ChunkReference(chunk_ref_uri) - # FIXME: this ignores the 'morph' field, and assumes 'name' is - # usable as-is. - chunk_uri = base_uri + 'chunks/' + entry['name'] + if 'morph' in entry: + chunk_file = os.path.join(toplevel_path, entry['morph']) + chunk_name = get_name_from_morph_file(chunk_file) + if chunk_name != entry['name']: + warnings.warn( + "Chunk name %s in stratum %s doesn't match " + "name from %s" % (entry['name'], stratum_uri, + entry['morph'])) + else: + chunk_name = entry['name'] + + chunk_uri = base_uri + 'chunks/' + chunk_name chunk_ref.baserock_refersToChunk = rdflib.URIRef(chunk_uri) chunk_ref.baserock_repo = entry['repo'] @@ -202,7 +213,11 @@ def load_all_morphologies(session, store, path='.'): dirnames.remove('.git') for filename in sorted(filenames): if filename.endswith('.morph'): - load_morph(toplevel_path, os.path.join(dirname, filename)) + try: + load_morph(toplevel_path, os.path.join(dirname, filename)) + except Exception as e: + print '%s: %r' % (filename, e) + raise print 'Committing to database...' try: -- cgit v1.2.1