summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Coldrick <adam.coldrick@codethink.co.uk>2014-08-08 08:32:46 +0000
committerAdam Coldrick <adam.coldrick@codethink.co.uk>2014-08-08 15:22:50 +0000
commit68f9fa2f0748540a27773160e1526600d7ee855b (patch)
tree141ea20943c2a07b5b3bd096909335c7ce0a0e27
parentea68fab0fb80c7e666e01c85d3b19acd09e36273 (diff)
downloadmorph-68f9fa2f0748540a27773160e1526600d7ee855b.tar.gz
morphset: Don't expect to be able to find `morph` or `name`
Currently, morphloader sets the morph field in chunk specs by default. A later commit will remove this behaviour, so morphset needs to stop expecting the `morph` field to exist in morphology specs. However, stratum specs don't have a `name` field so we can't expect to be able to find that either.
-rw-r--r--morphlib/morphset.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/morphlib/morphset.py b/morphlib/morphset.py
index 590ac51e..ccfdaa53 100644
--- a/morphlib/morphset.py
+++ b/morphlib/morphset.py
@@ -127,7 +127,8 @@ class MorphologySet(object):
specs = m[kind]
for spec in specs:
if cb_filter(m, kind, spec):
- fn = morphlib.util.sanitise_morphology_path(spec['morph'])
+ fn = morphlib.util.sanitise_morphology_path(
+ spec.get('morph', spec.get('name')))
orig_spec = (spec.get('repo'), spec.get('ref'), fn)
dirtied = cb_process(m, kind, spec)
if dirtied:
@@ -148,7 +149,8 @@ class MorphologySet(object):
if m.ref != spec.get('ref'):
m.ref = spec.get('ref')
m.dirty = True
- file = morphlib.util.sanitise_morphology_path(spec['morph'])
+ file = morphlib.util.sanitise_morphology_path(
+ spec.get('morph', spec.get('name')))
assert (m.filename == file
or m.repo_url == spec.get('repo')), \
'Moving morphologies is not supported.'
@@ -162,7 +164,7 @@ class MorphologySet(object):
'''
def wanted_spec(m, kind, spec):
- spec_name = spec.get('name', spec['morph'])
+ spec_name = spec.get('name', spec.get('morph'))
return (spec.get('repo') == repo_url and
spec.get('ref') == orig_ref and
spec_name == morph_name)