diff options
author | zhubx007 <zhu.boxiang@99cloud.net> | 2018-08-08 10:25:10 +0800 |
---|---|---|
committer | zhubx007 <zhu.boxiang@99cloud.net> | 2018-08-08 10:35:12 +0800 |
commit | 31a7ce67fe62a2b2b4dde9813d6035a98ab07386 (patch) | |
tree | 9cd909e9c23800332d9ea880385a0d2039b0fd63 /keystoneclient | |
parent | 783655f546364c519b0df557a2cc0af3bd10969c (diff) | |
download | python-keystoneclient-31a7ce67fe62a2b2b4dde9813d6035a98ab07386.tar.gz |
refactor the getid method in keystoneclient/base.py
Refer to a merged commit.
https://review.openstack.org/#/c/588983/
TrivialFix
Change-Id: Ie3a02843e35382dd24230e91534b6ed72846957d
Diffstat (limited to 'keystoneclient')
-rw-r--r-- | keystoneclient/base.py | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/keystoneclient/base.py b/keystoneclient/base.py index c466b1b..67edfb4 100644 --- a/keystoneclient/base.py +++ b/keystoneclient/base.py @@ -38,16 +38,10 @@ 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: - if obj.uuid: - return obj.uuid - except AttributeError: # nosec(cjschaef): 'obj' doesn't contain attribute - # 'uuid', return attribute 'id' or the 'obj' - pass - try: - return obj.id - except AttributeError: - return obj + if getattr(obj, 'uuid', None): + return obj.uuid + else: + return getattr(obj, 'id', obj) def filter_none(**kwargs): |