You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by qu...@apache.org on 2018/03/16 15:26:04 UTC

[2/7] libcloud git commit: Simplify chained comparisons

Simplify chained comparisons

Signed-off-by: Quentin Pradet <qu...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/ee1f0fa3
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/ee1f0fa3
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/ee1f0fa3

Branch: refs/heads/trunk
Commit: ee1f0fa3e3c33205166d79c13e250db9d295570d
Parents: 24d8709
Author: Rémy Léone <rl...@online.net>
Authored: Fri Mar 16 09:45:59 2018 +0100
Committer: Quentin Pradet <qu...@apache.org>
Committed: Fri Mar 16 19:21:55 2018 +0400

----------------------------------------------------------------------
 libcloud/common/aliyun.py                | 2 +-
 libcloud/common/brightbox.py             | 2 +-
 libcloud/common/openstack.py             | 2 +-
 libcloud/compute/drivers/cloudsigma.py   | 2 +-
 libcloud/compute/drivers/elasticstack.py | 2 +-
 libcloud/compute/drivers/opennebula.py   | 2 +-
 libcloud/dns/drivers/powerdns.py         | 2 +-
 libcloud/storage/drivers/cloudfiles.py   | 2 +-
 libcloud/storage/drivers/oss.py          | 2 +-
 libcloud/storage/drivers/s3.py           | 2 +-
 libcloud/utils/py3.py                    | 4 ++--
 11 files changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/ee1f0fa3/libcloud/common/aliyun.py
----------------------------------------------------------------------
diff --git a/libcloud/common/aliyun.py b/libcloud/common/aliyun.py
index 634ec44..ea2dfbe 100644
--- a/libcloud/common/aliyun.py
+++ b/libcloud/common/aliyun.py
@@ -45,7 +45,7 @@ class AliyunXmlResponse(XmlResponse):
     namespace = None
 
     def success(self):
-        return self.status >= 200 and self.status < 300
+        return 200 <= self.status < 300
 
     def parse_body(self):
         """

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ee1f0fa3/libcloud/common/brightbox.py
----------------------------------------------------------------------
diff --git a/libcloud/common/brightbox.py b/libcloud/common/brightbox.py
index 77270c0..e3e4dd2 100644
--- a/libcloud/common/brightbox.py
+++ b/libcloud/common/brightbox.py
@@ -29,7 +29,7 @@ except ImportError:
 
 class BrightboxResponse(JsonResponse):
     def success(self):
-        return self.status >= httplib.OK and self.status < httplib.BAD_REQUEST
+        return httplib.OK <= self.status < httplib.BAD_REQUEST
 
     def parse_body(self):
         if self.headers['content-type'].split(';')[0] == 'application/json':

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ee1f0fa3/libcloud/common/openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/common/openstack.py b/libcloud/common/openstack.py
index b4367c6..954a15d 100644
--- a/libcloud/common/openstack.py
+++ b/libcloud/common/openstack.py
@@ -345,7 +345,7 @@ class OpenStackResponse(Response):
 
     def success(self):
         i = int(self.status)
-        return i >= 200 and i <= 299
+        return 200 <= i <= 299
 
     def has_content_type(self, content_type):
         content_type_value = self.headers.get('content-type') or ''

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ee1f0fa3/libcloud/compute/drivers/cloudsigma.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/cloudsigma.py b/libcloud/compute/drivers/cloudsigma.py
index 02818b3..03845d4 100644
--- a/libcloud/compute/drivers/cloudsigma.py
+++ b/libcloud/compute/drivers/cloudsigma.py
@@ -113,7 +113,7 @@ class CloudSigma_1_0_Response(Response):
         if self.status == httplib.UNAUTHORIZED:
             raise InvalidCredsError()
 
-        return self.status >= 200 and self.status <= 299
+        return 200 <= self.status <= 299
 
     def parse_body(self):
         if not self.body:

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ee1f0fa3/libcloud/compute/drivers/elasticstack.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/elasticstack.py b/libcloud/compute/drivers/elasticstack.py
index 18b581b..5f14663 100644
--- a/libcloud/compute/drivers/elasticstack.py
+++ b/libcloud/compute/drivers/elasticstack.py
@@ -118,7 +118,7 @@ class ElasticStackResponse(JsonResponse):
         if self.status == 401:
             raise InvalidCredsError()
 
-        return self.status >= 200 and self.status <= 299
+        return 200 <= self.status <= 299
 
     def parse_error(self):
         error_header = self.headers.get('x-elastic-error', '')

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ee1f0fa3/libcloud/compute/drivers/opennebula.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/opennebula.py b/libcloud/compute/drivers/opennebula.py
index 6b94a32..89ee25d 100644
--- a/libcloud/compute/drivers/opennebula.py
+++ b/libcloud/compute/drivers/opennebula.py
@@ -129,7 +129,7 @@ class OpenNebulaResponse(XmlResponse):
         :return: True is success, else False.
         """
         i = int(self.status)
-        return i >= 200 and i <= 299
+        return 200 <= i <= 299
 
     def parse_error(self):
         """

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ee1f0fa3/libcloud/dns/drivers/powerdns.py
----------------------------------------------------------------------
diff --git a/libcloud/dns/drivers/powerdns.py b/libcloud/dns/drivers/powerdns.py
index 37bd37c..813bf7a 100644
--- a/libcloud/dns/drivers/powerdns.py
+++ b/libcloud/dns/drivers/powerdns.py
@@ -34,7 +34,7 @@ class PowerDNSResponse(JsonResponse):
 
     def success(self):
         i = int(self.status)
-        return i >= 200 and i <= 299
+        return 200 <= i <= 299
 
     def parse_error(self):
         if self.status == httplib.UNAUTHORIZED:

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ee1f0fa3/libcloud/storage/drivers/cloudfiles.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/drivers/cloudfiles.py b/libcloud/storage/drivers/cloudfiles.py
index 195570a..42af93c 100644
--- a/libcloud/storage/drivers/cloudfiles.py
+++ b/libcloud/storage/drivers/cloudfiles.py
@@ -63,7 +63,7 @@ class CloudFilesResponse(Response):
 
     def success(self):
         i = int(self.status)
-        return i >= 200 and i <= 299 or i in self.valid_response_codes
+        return 200 <= i <= 299 or i in self.valid_response_codes
 
     def parse_body(self):
         if not self.body:

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ee1f0fa3/libcloud/storage/drivers/oss.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/drivers/oss.py b/libcloud/storage/drivers/oss.py
index 820b8b3..004bd4f 100644
--- a/libcloud/storage/drivers/oss.py
+++ b/libcloud/storage/drivers/oss.py
@@ -76,7 +76,7 @@ class OSSResponse(XmlResponse):
 
     def success(self):
         i = int(self.status)
-        return i >= 200 and i <= 299 or i in self.valid_response_codes
+        return 200 <= i <= 299 or i in self.valid_response_codes
 
     def parse_body(self):
         """

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ee1f0fa3/libcloud/storage/drivers/s3.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/drivers/s3.py b/libcloud/storage/drivers/s3.py
index f9f4b6c..e4d48a4 100644
--- a/libcloud/storage/drivers/s3.py
+++ b/libcloud/storage/drivers/s3.py
@@ -89,7 +89,7 @@ class S3Response(AWSBaseResponse):
 
     def success(self):
         i = int(self.status)
-        return i >= 200 and i <= 299 or i in self.valid_response_codes
+        return 200 <= i <= 299 or i in self.valid_response_codes
 
     def parse_error(self):
         if self.status in [httplib.UNAUTHORIZED, httplib.FORBIDDEN]:

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ee1f0fa3/libcloud/utils/py3.py
----------------------------------------------------------------------
diff --git a/libcloud/utils/py3.py b/libcloud/utils/py3.py
index 955cb6e..9914c18 100644
--- a/libcloud/utils/py3.py
+++ b/libcloud/utils/py3.py
@@ -43,10 +43,10 @@ PY2 = False
 PY27 = False
 PY3 = False
 
-if sys.version_info >= (2, 0) and sys.version_info < (3, 0):
+if (2, 0) <= sys.version_info < (3, 0):
     PY2 = True
 
-if sys.version_info >= (2, 7) and sys.version_info < (2, 8):
+if (2, 7) <= sys.version_info < (2, 8):
     PY27 = True
 
 if sys.version_info >= (3, 0):