diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-09-10 11:37:45 +0100 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-09-10 20:03:34 +0100 |
commit | 02f4c93a143b7121c5bd84ec2e20c665149db4c8 (patch) | |
tree | 4e26cceaa1e8274cdd13285653d3dbfd7908420d /morphlib/morph2.py | |
parent | 5986caa568d9d8649dcd1a7015306235f1f0781d (diff) | |
download | morph-02f4c93a143b7121c5bd84ec2e20c665149db4c8.tar.gz |
Morphology: Only set defaults specific to the morphology kind
This helps us avoid writing out meaningless fields when we want to
edit a morphology and write it back to disk.
Diffstat (limited to 'morphlib/morph2.py')
-rw-r--r-- | morphlib/morph2.py | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/morphlib/morph2.py b/morphlib/morph2.py index 801b6c3a..d99e4a9e 100644 --- a/morphlib/morph2.py +++ b/morphlib/morph2.py @@ -26,20 +26,29 @@ class Morphology(object): ''' - static_defaults = [ - ('configure-commands', None), - ('build-commands', None), - ('test-commands', None), - ('install-commands', None), - ('chunks', []), - ('strata', []), - ('max-jobs', None), - ('description', ''), - ('build-depends', None), - ('build-system', 'manual'), - ('arch', None), - ('system-kind', None), - ] + static_defaults = { + 'chunk': [ + ('description', ''), + ('configure-commands', None), + ('build-commands', None), + ('test-commands', None), + ('install-commands', None), + ('chunks', []), + ('max-jobs', None), + ('build-system', 'manual') + ], + 'stratum': [ + ('chunks', []), + ('description', ''), + ('build-depends', None) + ], + 'system': [ + ('strata', []), + ('description', ''), + ('arch', None), + ('system-kind', None) + ] + } def __init__(self, text): self._dict = json.loads(text) @@ -110,7 +119,7 @@ class Morphology(object): size = int(size) self._dict['disk-size'] = size - for name, value in self.static_defaults: + for name, value in self.static_defaults[self['kind']]: if name not in self._dict: self._dict[name] = value |