summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2015-06-08 10:52:41 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2015-06-12 08:54:20 +0000
commit600f2642ffd3bbc343d3b32190eeb3204b598127 (patch)
tree0a46f504cb341b766b9063131dc2150bf5aac8ba
parentde977c00b90885a66a9aa089ef70519a2c0ce432 (diff)
downloadmorph-600f2642ffd3bbc343d3b32190eeb3204b598127.tar.gz
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
-rw-r--r--morphlib/morphloader.py8
1 files 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']: