diff options
author | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2014-08-08 07:59:02 +0000 |
---|---|---|
committer | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2014-08-14 13:28:50 +0000 |
commit | 9e35ea90a1f2c41c3808633e76930f86da6336e5 (patch) | |
tree | 4089e408578baabc6f7e3d167107fa7db659e42a /morphlib/morphloader.py | |
parent | 95c5f93d554883fdedaeb3e111e1be9f88e0045c (diff) | |
download | morph-9e35ea90a1f2c41c3808633e76930f86da6336e5.tar.gz |
morphloader: Get commands when loading morphology
Rather than having a `get_commands` method to obtain missing commands
from the build system when they are needed, get the commands when
loading a morphology.
Diffstat (limited to 'morphlib/morphloader.py')
-rw-r--r-- | morphlib/morphloader.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/morphlib/morphloader.py b/morphlib/morphloader.py index 0249bbae..d06c06dc 100644 --- a/morphlib/morphloader.py +++ b/morphlib/morphloader.py @@ -406,6 +406,7 @@ class MorphologyLoader(object): m = self.parse_morphology_text(string, filename) m.filename = filename self.validate(m) + self.set_commands(m) self.set_defaults(m) return m @@ -754,3 +755,13 @@ class MorphologyLoader(object): if morph['max-jobs'] is not None: morph['max-jobs'] = int(morph['max-jobs']) + def set_commands(self, morph): + if morph['kind'] == 'chunk': + for key in self._static_defaults['chunk']: + if 'commands' not in key: continue + if key not in morph: + attr = '_'.join(key.split('-')) + default = self._static_defaults['chunk']['build-system'] + bs = morphlib.buildsystem.lookup_build_system( + morph.get('build-system', default)) + morph[key] = getattr(bs, attr) |