summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2013-12-13 17:01:44 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2014-01-10 11:49:56 +0000
commitd7f9a82ee2e91c44166d39d21f611a8671c989df (patch)
tree0556a40e0d6e379a503700d87c257ef5e389dc82
parent369776bd1b32a35c85730b06e16235aa3e8b004b (diff)
downloadmorph-d7f9a82ee2e91c44166d39d21f611a8671c989df.tar.gz
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.
-rw-r--r--morphlib/morph2.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/morphlib/morph2.py b/morphlib/morph2.py
index 0e0d9201..942322ee 100644
--- a/morphlib/morph2.py
+++ b/morphlib/morph2.py
@@ -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: