From 600f2642ffd3bbc343d3b32190eeb3204b598127 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Mon, 8 Jun 2015 10:52:41 +0000 Subject: morphloader: Allow build-system lookup to be customised This defaults to the default, and only useful behaviour at this point. It is there so that tests may mock it out. Change-Id: I17499fc1bb0a1ad39da2ac836a2946b1a0ed5abe --- morphlib/morphloader.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/morphlib/morphloader.py b/morphlib/morphloader.py index 24c13d2e..171954f9 100644 --- a/morphlib/morphloader.py +++ b/morphlib/morphloader.py @@ -378,13 +378,15 @@ class MorphologyLoader(object): }, } - def __init__(self, definitions_version=0): + def __init__(self, definitions_version=0, + lookup_build_system=morphlib.buildsystem.lookup_build_system): if definitions_version >= 5: # pragma: no cover self._static_defaults = copy.deepcopy(self._static_defaults) self._static_defaults['chunk'].update({ 'pre-strip-commands': None, 'strip-commands': None, 'post-strip-commands': None}) + self._lookup_build_system = lookup_build_system def parse_morphology_text(self, text, morph_filename): '''Parse a textual morphology. @@ -783,7 +785,7 @@ class MorphologyLoader(object): def _unset_chunk_defaults(self, morph): # pragma: no cover default_bs = self._static_defaults['chunk']['build-system'] - bs = morphlib.buildsystem.lookup_build_system( + bs = self._lookup_build_system( morph.get('build-system', default_bs)) for key in self._static_defaults['chunk']: if key not in morph: continue @@ -795,7 +797,7 @@ class MorphologyLoader(object): def set_commands(self, morph): default = self._static_defaults['chunk']['build-system'] - bs = morphlib.buildsystem.lookup_build_system( + bs = self._lookup_build_system( morph.get('build-system', default)) if morph['kind'] == 'chunk': for key in self._static_defaults['chunk']: -- cgit v1.2.1