summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Coldrick <adam.coldrick@codethink.co.uk>2014-08-13 08:56:31 +0000
committerAdam Coldrick <adam.coldrick@codethink.co.uk>2014-08-13 08:56:31 +0000
commitd1ed75e03849f378af32a7613be9c877536b4587 (patch)
tree292f374b6c6fe6d572b092cbe2ed4321900ea954
parent24758c077bedd764e15ce186fc12949e468f8fb6 (diff)
downloadmorph-d1ed75e03849f378af32a7613be9c877536b4587.tar.gz
fixup: no need for get_commands
-rw-r--r--morphlib/morphloader.py5
-rw-r--r--morphlib/morphology.py9
-rw-r--r--morphlib/morphology_tests.py35
3 files changed, 4 insertions, 45 deletions
diff --git a/morphlib/morphloader.py b/morphlib/morphloader.py
index 351977c4..da6835b8 100644
--- a/morphlib/morphloader.py
+++ b/morphlib/morphloader.py
@@ -761,4 +761,7 @@ class MorphologyLoader(object):
if 'commands' in key]
for key in steps:
if morph[key] == self._static_defaults['chunk'][key]:
- morph[key] = morph.get_commands(key)
+ attr = '_'.join(key.split('-'))
+ bs = morphlib.buildsystem.lookup_build_system(
+ morph['build-system'])
+ morph[key] = getattr(bs, attr)
diff --git a/morphlib/morphology.py b/morphlib/morphology.py
index a91ff390..9f41f347 100644
--- a/morphlib/morphology.py
+++ b/morphlib/morphology.py
@@ -44,12 +44,3 @@ class Morphology(UserDict.IterableUserDict):
self.ref = None
self.filename = None
self.dirty = None
-
- def get_commands(self, which):
- '''Return the commands to run from a morphology or the build system'''
- if self.get(which, None) is None:
- attr = '_'.join(which.split('-'))
- bs = morphlib.buildsystem.lookup_build_system(self['build-system'])
- return getattr(bs, attr)
- else:
- return self[which]
diff --git a/morphlib/morphology_tests.py b/morphlib/morphology_tests.py
index 2184db0c..e8eb217f 100644
--- a/morphlib/morphology_tests.py
+++ b/morphlib/morphology_tests.py
@@ -45,38 +45,3 @@ class MorphologyTests(unittest.TestCase):
self.assertEqual(self.morph.dirty, None)
self.morph.dirty = True
self.assertEqual(self.morph.dirty, True)
-
- def test_uses_morphology_commands_when_given(self):
- m = morphlib.morphology.Morphology(
- {
- 'name': 'foo',
- 'kind': 'chunk',
- 'build-system': 'dummy',
- 'build-commands': ['build-it']
- }
- )
- cmds = m.get_commands('build-commands')
- self.assertEqual(cmds, ['build-it'])
-
- def test_uses_build_system_commands_when_morphology_doesnt(self):
- m = morphlib.morphology.Morphology(
- {
- 'name': 'foo',
- 'kind': 'chunk',
- 'build-system': 'dummy',
- }
- )
- cmds = m.get_commands('build-commands')
- self.assertEqual(cmds, ['echo dummy build'])
-
- def test_uses_morphology_commands_when_morphology_has_empty_list(self):
- m = morphlib.morphology.Morphology(
- {
- 'name': 'foo',
- 'kind': 'chunk',
- 'build-system': 'dummy',
- 'build-commands': []
- }
- )
- cmds = m.get_commands('build-commands')
- self.assertEqual(cmds, [])