summaryrefslogtreecommitdiff
path: root/morphlib/morphologyfactory.py
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2013-02-07 15:58:50 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2013-02-08 11:08:07 +0000
commitd284a233c46611daa4bea6fd195426cf3d1cb118 (patch)
treea318ba26b1c6785953168dcfe32aeb3b5f729fd1 /morphlib/morphologyfactory.py
parent876a11cebfe4821c34dd451789aaf4f55f409c41 (diff)
downloadmorph-d284a233c46611daa4bea6fd195426cf3d1cb118.tar.gz
Require morphology name to match filename
Allowing differences causes only confusion. Whether or not the 'name' field should surive at all is up for debate: it's very useful when seeing the contents of the morphology out of context (e.g. in documentation or pastebins), but is that worth the extra effort?
Diffstat (limited to 'morphlib/morphologyfactory.py')
-rw-r--r--morphlib/morphologyfactory.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/morphlib/morphologyfactory.py b/morphlib/morphologyfactory.py
index 6625d375..d23f55a4 100644
--- a/morphlib/morphologyfactory.py
+++ b/morphlib/morphologyfactory.py
@@ -86,6 +86,11 @@ class MorphologyFactory(object):
raise morphlib.Error("Error parsing %s: %s" %
(filename, str(e)))
+ if filename != morphology['name'] + '.morph':
+ raise morphlib.Error(
+ "Name %s does not match basename of morphology file %s" %
+ (morphology['name'], filename))
+
method_name = '_check_and_tweak_%s' % morphology['kind']
if hasattr(self, method_name):
method = getattr(self, method_name)