Allow underscore to dash translation when accessing model attributes (#101)
authorsimonklb <simonkollberg@gmail.com>
Mon, 3 Apr 2017 16:21:22 +0000 (18:21 +0200)
committerCory Johns <johnsca@gmail.com>
Mon, 3 Apr 2017 16:21:22 +0000 (12:21 -0400)
juju/model.py

index 55ad086..0278ae6 100644 (file)
@@ -230,7 +230,14 @@ class ModelEntity(object):
         model.
 
         """
-        return self.safe_data[name]
+        try:
+            return self.safe_data[name]
+        except KeyError:
+            name = name.replace('_', '-')
+            if name in self.safe_data:
+                return self.safe_data[name]
+            else:
+                raise
 
     def __bool__(self):
         return bool(self.data)