From c521d6fa5a8a18ce3ed420d475ef0a3cc7b51ee5 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Thu, 30 Jul 2015 18:47:43 +0100 Subject: Change how MorphologyLoader instances are created Loading .morph files is becoming a bit more complicated, as we need to deal with the VERSION file, and possibly soon with a DEFAULTS file as well. The logic of loading and parsing .morph files is done either in the sourceresolver module, or the morphloader module. This change means that all users of the latter module can use the get hold of a MorphologyLoader instance with VERSION already parsed. If DEFAULTS is added then it is also simple to parse DEFAULTS. Change-Id: Ib33756e9dbd078e38f12dd7f776c89584b178959 --- morphlib/plugins/branch_and_merge_plugin.py | 4 ++-- morphlib/plugins/diff_plugin.py | 2 +- morphlib/plugins/get_chunk_details_plugin.py | 3 +-- morphlib/plugins/get_repo_plugin.py | 3 +-- 4 files changed, 5 insertions(+), 7 deletions(-) (limited to 'morphlib/plugins') diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py index 9421e4e5..ba4fab55 100644 --- a/morphlib/plugins/branch_and_merge_plugin.py +++ b/morphlib/plugins/branch_and_merge_plugin.py @@ -333,7 +333,7 @@ class BranchAndMergePlugin(cliapp.Plugin): '''Read in all the morphologies in the root repository.''' self.app.status(msg='Loading in all morphologies') morphs = morphlib.morphset.MorphologySet() - for morph in sb.load_all_morphologies(loader): + for morph in sb.load_all_morphologies(): morphs.add_morphology(morph) return morphs @@ -453,7 +453,7 @@ class BranchAndMergePlugin(cliapp.Plugin): gd.branch(system_branch, base_ref) gd.checkout(system_branch) - loader = morphlib.morphloader.MorphologyLoader() + loader = sb.get_morphology_loader() morphs = self._load_all_sysbranch_morphologies(sb, loader) morphs.repoint_refs(sb.root_repository_url, diff --git a/morphlib/plugins/diff_plugin.py b/morphlib/plugins/diff_plugin.py index 06566438..9855c39f 100644 --- a/morphlib/plugins/diff_plugin.py +++ b/morphlib/plugins/diff_plugin.py @@ -108,7 +108,7 @@ class DiffPlugin(cliapp.Plugin): definitions = mf.list_morphologies() system_paths = set() for definition in definitions: - m = ml.parse_morphology_text(mf.read_morphology(definition), + m = ml.parse_morphology_text(mf.read_file(definition), definition) if m.get('kind') == 'system' or 'strata' in m: system_paths.add(definition) diff --git a/morphlib/plugins/get_chunk_details_plugin.py b/morphlib/plugins/get_chunk_details_plugin.py index e58ed6c5..90e71c52 100644 --- a/morphlib/plugins/get_chunk_details_plugin.py +++ b/morphlib/plugins/get_chunk_details_plugin.py @@ -49,13 +49,12 @@ class GetChunkDetailsPlugin(cliapp.Plugin): definitions_repo = morphlib.definitions_repo.open( '.', search_for_root=True, search_workspace=True, app=self.app) - loader = morphlib.morphloader.MorphologyLoader() aliases = self.app.settings['repo-alias'] self.resolver = morphlib.repoaliasresolver.RepoAliasResolver(aliases) found = 0 - for morph in definitions_repo.load_all_morphologies(loader): + for morph in definitions_repo.load_all_morphologies(): if morph['kind'] == 'stratum': if (stratum_name == None or morph['name'] == stratum_name): diff --git a/morphlib/plugins/get_repo_plugin.py b/morphlib/plugins/get_repo_plugin.py index 38039406..9c1c19f1 100644 --- a/morphlib/plugins/get_repo_plugin.py +++ b/morphlib/plugins/get_repo_plugin.py @@ -122,10 +122,9 @@ class GetRepoPlugin(cliapp.Plugin): definitions_repo = morphlib.definitions_repo.open( '.', search_for_root=True, search_workspace=True, app=self.app) - loader = morphlib.morphloader.MorphologyLoader() self.app.status(msg='Loading in all morphologies') - for morph in definitions_repo.load_all_morphologies(loader): + for morph in definitions_repo.load_all_morphologies(): if morph['kind'] == 'stratum': for chunk in morph['chunks']: if chunk['name'] == chunk_name: -- cgit v1.2.1