From 8c19a8f81319eec2b6437d30cbcf23378daa7abc Mon Sep 17 00:00:00 2001 From: wanghui Date: Thu, 8 Nov 2018 20:27:48 +0800 Subject: [PATCH] refactor the getid method base.py Refer to a merged commit. https://review.openstack.org/#/c/588983/ Change-Id: I4d92b2637d1176bef0df6e145f3515933f5a531a --- cyborgclient/common/base.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cyborgclient/common/base.py b/cyborgclient/common/base.py index 72ecb54..61eff1f 100644 --- a/cyborgclient/common/base.py +++ b/cyborgclient/common/base.py @@ -32,10 +32,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):