diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2015-07-02 15:09:07 +0100 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2015-07-02 15:09:07 +0100 |
commit | f412433e6d6c53376ba27dadcc4fb7bed7e2f064 (patch) | |
tree | 386a41bd295b43353f9f36288dd53158d8b832f2 | |
parent | 5174d4dd33ef2670cb294883d55cbe6f0d977324 (diff) | |
download | definitions-f412433e6d6c53376ba27dadcc4fb7bed7e2f064.tar.gz |
schema: Link to build-dep strata correctly, and check chunk names
Change-Id: Ibd0a7e2d42e6ac968c8c7076f8b35474bc1eab88
-rw-r--r-- | schema/parse.py | 25 |
1 files 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: |