diff options
authorRichard Maw <>2013-12-13 17:01:44 (GMT)
committerRichard Maw <>2014-01-15 17:43:38 (GMT)
commit8c92d5783274dd3f154c1609f3e6ce18571b46a9 (patch)
parentb1ae48ff49dcbd34fb9a9a4eac62868b9195f9ef (diff)
morph2.Morphology: add trivial .get method
This it convenient, as it allows the new validation code to validate the old morphology class during the transition period.
1 files changed, 9 insertions, 1 deletions
diff --git a/morphlib/ b/morphlib/
index 0e0d920..942322e 100644
--- a/morphlib/
+++ b/morphlib/
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Codethink Limited
+# Copyright (C) 2012-2014 Codethink Limited
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -87,6 +87,14 @@ class Morphology(object):
def __contains__(self, key):
return key in self._dict
+ # Not covered by tests, since it's trivial, morph2 is going away
+ # and only exists so the new morphology validation code can use it.
+ def get(self, key, default=None): # pragma: no cover
+ try:
+ return self[key]
+ except KeyError:
+ return default
def get_commands(self, which):
'''Return the commands to run from a morphology or the build system'''
if self[which] is None: