You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2014/03/30 22:56:31 UTC

[3/4] git commit: Fix PEP8's E713 and E714.

Fix PEP8's E713 and E714.

Two new tests were introduced with pep8 1.5 to report when operators
'not in' and 'is not' are recommended.

Signed-off-by: Tomaz Muraus <to...@apache.org>


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

Branch: refs/heads/trunk
Commit: 51af25e74d239d30198450f44314f448ca6a6b53
Parents: e66146f
Author: Franck Cuny <fr...@gmail.com>
Authored: Sun Mar 30 11:20:04 2014 -0700
Committer: Tomaz Muraus <to...@apache.org>
Committed: Sun Mar 30 22:55:41 2014 +0200

----------------------------------------------------------------------
 libcloud/compute/base.py                   |  2 +-
 libcloud/compute/drivers/abiquo.py         |  8 ++++----
 libcloud/compute/drivers/cloudsigma.py     |  4 ++--
 libcloud/compute/drivers/ibm_sce.py        |  2 +-
 libcloud/compute/drivers/linode.py         |  2 +-
 libcloud/compute/drivers/rimuhosting.py    | 10 +++++-----
 libcloud/dns/drivers/rackspace.py          |  2 +-
 libcloud/pricing.py                        |  2 +-
 libcloud/storage/drivers/google_storage.py |  4 ++--
 libcloud/storage/drivers/s3.py             |  4 ++--
 10 files changed, 20 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/51af25e7/libcloud/compute/base.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/base.py b/libcloud/compute/base.py
index e901f34..df6d296 100644
--- a/libcloud/compute/base.py
+++ b/libcloud/compute/base.py
@@ -865,7 +865,7 @@ class NodeDriver(BaseDriver):
             pass
         elif 'create_node' in self.features:
             f = self.features['create_node']
-            if not 'generates_password' in f and not "password" in f:
+            if 'generates_password' not in f and "password" not in f:
                 raise NotImplementedError(
                     'deploy_node not implemented for this driver')
         else:

http://git-wip-us.apache.org/repos/asf/libcloud/blob/51af25e7/libcloud/compute/drivers/abiquo.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/abiquo.py b/libcloud/compute/drivers/abiquo.py
index 398087b..ab74778 100644
--- a/libcloud/compute/drivers/abiquo.py
+++ b/libcloud/compute/drivers/abiquo.py
@@ -290,7 +290,7 @@ class AbiquoNodeDriver(NodeDriver):
 
         if location is None:
             location = self.list_locations()[0]
-        elif not location in self.list_locations():
+        elif location not in self.list_locations():
             raise LibcloudError('Location does not exist')
 
         link_vdc = self.connection.cache['locations'][location]
@@ -630,7 +630,7 @@ class AbiquoNodeDriver(NodeDriver):
         location will be created.
         """
         # First, get image location
-        if not 'image' in kwargs:
+        if 'image' not in kwargs:
             error = "'image' parameter is mandatory"
             raise LibcloudError(error, self)
 
@@ -640,7 +640,7 @@ class AbiquoNodeDriver(NodeDriver):
         location = None
         if 'location' in kwargs:
             location = kwargs['location']
-            if not location in self.list_locations():
+            if location not in self.list_locations():
                 raise LibcloudError('Location does not exist')
 
         # Check if the image is compatible with any of the locations or
@@ -669,7 +669,7 @@ class AbiquoNodeDriver(NodeDriver):
 
         If we can not find any group, create it into argument 'location'
         """
-        if not 'group_name' in kwargs:
+        if 'group_name' not in kwargs:
             group_name = NodeGroup.DEFAULT_GROUP_NAME
         else:
             group_name = kwargs['group_name']

http://git-wip-us.apache.org/repos/asf/libcloud/blob/51af25e7/libcloud/compute/drivers/cloudsigma.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/cloudsigma.py b/libcloud/compute/drivers/cloudsigma.py
index 833dea2..ccad8b1 100644
--- a/libcloud/compute/drivers/cloudsigma.py
+++ b/libcloud/compute/drivers/cloudsigma.py
@@ -918,7 +918,7 @@ class CloudSigma_2_0_Response(JsonResponse):
             return None
 
         for item in body:
-            if not 'error_type' in item:
+            if 'error_type' not in item:
                 # Unrecognized error
                 continue
 
@@ -991,7 +991,7 @@ class CloudSigma_2_0_NodeDriver(CloudSigmaNodeDriver):
 
     def __init__(self, key, secret, secure=True, host=None, port=None,
                  region=DEFAULT_REGION, **kwargs):
-        if not region in API_ENDPOINTS_2_0:
+        if region not in API_ENDPOINTS_2_0:
             raise ValueError('Invalid region: %s' % (region))
 
         if not secure:

http://git-wip-us.apache.org/repos/asf/libcloud/blob/51af25e7/libcloud/compute/drivers/ibm_sce.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ibm_sce.py b/libcloud/compute/drivers/ibm_sce.py
index 830fa6a..bcf73b9 100644
--- a/libcloud/compute/drivers/ibm_sce.py
+++ b/libcloud/compute/drivers/ibm_sce.py
@@ -64,7 +64,7 @@ class IBMConnection(ConnectionUserAndKey):
         headers['Accept'] = 'text/xml'
         headers['Authorization'] = ('Basic %s' % (base64.b64encode(
             b('%s:%s' % (self.user_id, self.key))).decode('utf-8')))
-        if not 'Content-Type' in headers:
+        if 'Content-Type' not in headers:
             headers['Content-Type'] = 'text/xml'
         return headers
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/51af25e7/libcloud/compute/drivers/linode.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/linode.py b/libcloud/compute/drivers/linode.py
index c25e363..428ce3c 100644
--- a/libcloud/compute/drivers/linode.py
+++ b/libcloud/compute/drivers/linode.py
@@ -244,7 +244,7 @@ class LinodeNodeDriver(NodeDriver):
 
         if not ssh and not root:
             raise LinodeException(0xFB, "Need SSH key or root password")
-        if not root is None and len(root) < 6:
+        if root is not None and len(root) < 6:
             raise LinodeException(0xFB, "Root password is too short")
 
         # Swap size

http://git-wip-us.apache.org/repos/asf/libcloud/blob/51af25e7/libcloud/compute/drivers/rimuhosting.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/rimuhosting.py b/libcloud/compute/drivers/rimuhosting.py
index 35bd9e4..ebe6bc9 100644
--- a/libcloud/compute/drivers/rimuhosting.py
+++ b/libcloud/compute/drivers/rimuhosting.py
@@ -299,29 +299,29 @@ class RimuHostingNodeDriver(NodeDriver):
                 kwargs['ex_vps_order_oid_to_clone']
 
         if 'ex_num_ips' in kwargs and int(kwargs['ex_num_ips']) > 1:
-            if not 'ex_extra_ip_reason' in kwargs:
+            if 'ex_extra_ip_reason' not in kwargs:
                 raise RimuHostingException(
                     'Need an reason for having an extra IP')
             else:
-                if not 'ip_request' in data:
+                if 'ip_request' not in data:
                     data['ip_request'] = {}
                 data['ip_request']['num_ips'] = int(kwargs['ex_num_ips'])
                 data['ip_request']['extra_ip_reason'] = \
                     kwargs['ex_extra_ip_reason']
 
         if 'ex_memory_mb' in kwargs:
-            if not 'vps_parameters' in data:
+            if 'vps_parameters' not in data:
                 data['vps_parameters'] = {}
             data['vps_parameters']['memory_mb'] = kwargs['ex_memory_mb']
 
         if 'ex_disk_space_mb' in kwargs:
-            if not 'ex_vps_parameters' in data:
+            if 'ex_vps_parameters' not in data:
                 data['vps_parameters'] = {}
             data['vps_parameters']['disk_space_mb'] = \
                 kwargs['ex_disk_space_mb']
 
         if 'ex_disk_space_2_mb' in kwargs:
-            if not 'vps_parameters' in data:
+            if 'vps_parameters' not in data:
                 data['vps_parameters'] = {}
             data['vps_parameters']['disk_space_2_mb'] =\
                 kwargs['ex_disk_space_2_mb']

http://git-wip-us.apache.org/repos/asf/libcloud/blob/51af25e7/libcloud/dns/drivers/rackspace.py
----------------------------------------------------------------------
diff --git a/libcloud/dns/drivers/rackspace.py b/libcloud/dns/drivers/rackspace.py
index fc7da74..55f834f 100644
--- a/libcloud/dns/drivers/rackspace.py
+++ b/libcloud/dns/drivers/rackspace.py
@@ -210,7 +210,7 @@ class RackspaceDNSDriver(DNSDriver, OpenStackDriverMixin):
         extra = extra if extra else {}
 
         # Email address is required
-        if not 'email' in extra:
+        if 'email' not in extra:
             raise ValueError('"email" key must be present in extra dictionary')
 
         payload = {'name': domain, 'emailAddress': extra['email'],

http://git-wip-us.apache.org/repos/asf/libcloud/blob/51af25e7/libcloud/pricing.py
----------------------------------------------------------------------
diff --git a/libcloud/pricing.py b/libcloud/pricing.py
index dd8de96..abf71e6 100644
--- a/libcloud/pricing.py
+++ b/libcloud/pricing.py
@@ -79,7 +79,7 @@ def get_pricing(driver_type, driver_name, pricing_file_path=None):
     :return: Dictionary with pricing where a key name is size ID and
              the value is a price.
     """
-    if not driver_type in VALID_PRICING_DRIVER_TYPES:
+    if driver_type not in VALID_PRICING_DRIVER_TYPES:
         raise AttributeError('Invalid driver type: %s', driver_type)
 
     if driver_name in PRICING_DATA[driver_type]:

http://git-wip-us.apache.org/repos/asf/libcloud/blob/51af25e7/libcloud/storage/drivers/google_storage.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/drivers/google_storage.py b/libcloud/storage/drivers/google_storage.py
index 6dd6054..9caca9b 100644
--- a/libcloud/storage/drivers/google_storage.py
+++ b/libcloud/storage/drivers/google_storage.py
@@ -90,10 +90,10 @@ class GoogleStorageConnection(ConnectionUserAndKey):
             elif key.lower().startswith('x-goog-'):
                 extension_header_values[key.lower()] = value.strip()
 
-        if not 'content-md5' in special_header_values:
+        if 'content-md5' not in special_header_values:
             special_header_values['content-md5'] = ''
 
-        if not 'content-type' in special_header_values:
+        if 'content-type' not in special_header_values:
             special_header_values['content-type'] = ''
 
         keys_sorted = list(special_header_values.keys())

http://git-wip-us.apache.org/repos/asf/libcloud/blob/51af25e7/libcloud/storage/drivers/s3.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/drivers/s3.py b/libcloud/storage/drivers/s3.py
index 8164939..9577f98 100644
--- a/libcloud/storage/drivers/s3.py
+++ b/libcloud/storage/drivers/s3.py
@@ -137,10 +137,10 @@ class BaseS3Connection(ConnectionUserAndKey):
             elif key_lower.startswith('x-amz-'):
                 amz_header_values[key.lower()] = value.strip()
 
-        if not 'content-md5' in special_header_values:
+        if 'content-md5' not in special_header_values:
             special_header_values['content-md5'] = ''
 
-        if not 'content-type' in special_header_values:
+        if 'content-type' not in special_header_values:
             special_header_values['content-type'] = ''
 
         if expires: