summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2013-12-13 17:01:44 (GMT)
committerRichard Maw <richard.maw@codethink.co.uk>2014-01-15 17:43:38 (GMT)
commit8c92d5783274dd3f154c1609f3e6ce18571b46a9 (patch)
tree15079c85ced22765bbbf4ad70701029a5044065b
parentb1ae48ff49dcbd34fb9a9a4eac62868b9195f9ef (diff)
downloadmorph-8c92d5783274dd3f154c1609f3e6ce18571b46a9.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 0e0d920..942322e 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: