summaryrefslogtreecommitdiff
path: root/cinderclient/exceptions.py
diff options
context:
space:
mode:
authorGorka Eguileor <geguileo@redhat.com>2016-08-05 14:45:28 +0200
committerGorka Eguileor <geguileo@redhat.com>2016-08-29 11:41:57 +0200
commit8b5a772e36fb7b7fae42a956bc844e792bec2035 (patch)
tree575cfe7f4e17455e0b483d61b249cc0b395dc303 /cinderclient/exceptions.py
parent8db4ca1d90c714c49a88a05e9cc008b3bd9f2245 (diff)
downloadpython-cinderclient-8b5a772e36fb7b7fae42a956bc844e792bec2035.tar.gz
Make APIVersion's null check more pythonic
Our current APIVersion object has an is_null method to check when the version instance is null (major=0 and minor=0). While this works it is not very pythonic, since you have to write expressions such as: if not min_version and not max_version: return True elif ((min_version and max_version) and max_version.is_null() and min_version.is_null()): return True This patch removes the is_null method and instead implements the truth value testing to simplify expressions and make code more pythonic. So previous code would just look like: if not min_version and not max_version: return True Because this will work with min_version being None or being an APIVersion instance with major=0 and minor=0. Change-Id: I7497c5dc940c1e726507117cadbad232d8c1d80d
Diffstat (limited to 'cinderclient/exceptions.py')
-rw-r--r--cinderclient/exceptions.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/cinderclient/exceptions.py b/cinderclient/exceptions.py
index 6d9e707..23b31b1 100644
--- a/cinderclient/exceptions.py
+++ b/cinderclient/exceptions.py
@@ -34,19 +34,19 @@ class UnsupportedAttribute(AttributeError):
"""
def __init__(self, argument_name, start_version, end_version):
- if not start_version.is_null() and not end_version.is_null():
+ if start_version and end_version:
self.message = (
"'%(name)s' argument is only allowed for microversions "
"%(start)s - %(end)s." % {"name": argument_name,
"start": start_version.get_string(),
"end": end_version.get_string()})
- elif not start_version.is_null():
+ elif start_version:
self.message = (
"'%(name)s' argument is only allowed since microversion "
"%(start)s." % {"name": argument_name,
"start": start_version.get_string()})
- elif not end_version.is_null():
+ elif end_version:
self.message = (
"'%(name)s' argument is not allowed after microversion "
"%(end)s." % {"name": argument_name,