From 94f6864bf07ab93d3ecdc8f1ff57afe2c7bae083 Mon Sep 17 00:00:00 2001 From: wanghui Date: Fri, 9 Nov 2018 20:09:58 +0800 Subject: [PATCH] Refactor the getid method base.py Refer to a merged commit. https://review.openstack.org/#/c/588983/ Change-Id: I9765543c288370cfcdaaa930b2839e28b51a9380 --- watcherclient/common/base.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/watcherclient/common/base.py b/watcherclient/common/base.py index 05a9093..fc33b45 100644 --- a/watcherclient/common/base.py +++ b/watcherclient/common/base.py @@ -31,10 +31,7 @@ def getid(obj): Abstracts the common pattern of allowing both an object or an object's ID (UUID) as a parameter when dealing with relationships. """ - try: - return obj.id - except AttributeError: - return obj + return getattr(obj, 'id', obj) class Manager(object):