From c8a68279c2043d7b3d3789a881826d52074af04e Mon Sep 17 00:00:00 2001 From: simonklb Date: Mon, 3 Apr 2017 18:21:22 +0200 Subject: [PATCH] Allow underscore to dash translation when accessing model attributes (#101) --- juju/model.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/juju/model.py b/juju/model.py index 55ad086..0278ae6 100644 --- a/juju/model.py +++ b/juju/model.py @@ -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) -- 2.25.1