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/09/13 18:46:18 UTC
[1/2] git commit: Fix some pylint violations.
Repository: libcloud
Updated Branches:
refs/heads/trunk 49a1b016d -> 688ec7550
Fix some pylint violations.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/ad43fc47
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/ad43fc47
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/ad43fc47
Branch: refs/heads/trunk
Commit: ad43fc476c5d2c11963696400a1c7d7aa958e56b
Parents: 49a1b01
Author: Tomaz Muraus <to...@apache.org>
Authored: Thu Sep 11 19:02:56 2014 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Sat Sep 13 17:45:15 2014 +0200
----------------------------------------------------------------------
libcloud/common/linode.py | 6 +++++-
libcloud/dns/base.py | 3 +++
libcloud/httplib_ssl.py | 6 ++++--
libcloud/pricing.py | 6 +++++-
libcloud/storage/drivers/cloudfiles.py | 8 ++++++++
libcloud/storage/drivers/local.py | 6 +++---
libcloud/storage/drivers/nimbus.py | 6 +++---
libcloud/storage/drivers/s3.py | 3 +++
libcloud/utils/py3.py | 2 ++
9 files changed, 36 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/ad43fc47/libcloud/common/linode.py
----------------------------------------------------------------------
diff --git a/libcloud/common/linode.py b/libcloud/common/linode.py
index c547514..2d60500 100644
--- a/libcloud/common/linode.py
+++ b/libcloud/common/linode.py
@@ -75,7 +75,11 @@ class LinodeResponse(JsonResponse):
}
libcloud does not take advantage of batching, so a response will always
- reflect the above format. A few weird quirks are caught here as well."""
+ reflect the above format. A few weird quirks are caught here as well.
+ """
+
+ objects = None
+
def __init__(self, response, connection):
"""Instantiate a LinodeResponse from the HTTP response
http://git-wip-us.apache.org/repos/asf/libcloud/blob/ad43fc47/libcloud/dns/base.py
----------------------------------------------------------------------
diff --git a/libcloud/dns/base.py b/libcloud/dns/base.py
index 0e3ac6f..f09ccc1 100644
--- a/libcloud/dns/base.py
+++ b/libcloud/dns/base.py
@@ -154,6 +154,9 @@ class DNSDriver(BaseDriver):
name = None
website = None
+ # Map libcloud record type enum to provider record type name
+ RECORD_TYPE_MAP = {}
+
def __init__(self, key, secret=None, secure=True, host=None, port=None,
**kwargs):
"""
http://git-wip-us.apache.org/repos/asf/libcloud/blob/ad43fc47/libcloud/httplib_ssl.py
----------------------------------------------------------------------
diff --git a/libcloud/httplib_ssl.py b/libcloud/httplib_ssl.py
index 104bf34..7787e7b 100644
--- a/libcloud/httplib_ssl.py
+++ b/libcloud/httplib_ssl.py
@@ -136,9 +136,11 @@ class LibcloudBaseConnection(object):
if hasattr(self, 'set_tunnel'):
# Python 2.7 and higher
+ # pylint: disable=no-member
self.set_tunnel(host=self.host, port=self.port, headers=headers)
elif hasattr(self, '_set_tunnel'):
# Python 2.6
+ # pylint: disable=no-member
self._set_tunnel(host=self.host, port=self.port, headers=headers)
else:
raise ValueError('Unsupported Python version')
@@ -147,7 +149,7 @@ class LibcloudBaseConnection(object):
def _activate_http_proxy(self, sock):
self.sock = sock
- self._tunnel()
+ self._tunnel() # pylint: disable=no-member
def _set_hostport(self, host, port):
"""
@@ -165,7 +167,7 @@ class LibcloudBaseConnection(object):
raise httplib.InvalidURL(msg)
host = host[:i]
else:
- port = self.default_port
+ port = self.default_port # pylint: disable=no-member
if host and host[0] == '[' and host[-1] == ']':
host = host[1:-1]
self.host = host
http://git-wip-us.apache.org/repos/asf/libcloud/blob/ad43fc47/libcloud/pricing.py
----------------------------------------------------------------------
diff --git a/libcloud/pricing.py b/libcloud/pricing.py
index ebe99a8..1dbdf20 100644
--- a/libcloud/pricing.py
+++ b/libcloud/pricing.py
@@ -23,8 +23,10 @@ from os.path import join as pjoin
try:
import simplejson as json
+ JSONDecodeError = json.JSONDecodeError
except ImportError:
import json
+ JSONDecodeError = ValueError
from libcloud.utils.connection import get_response_object
@@ -95,6 +97,7 @@ def get_pricing(driver_type, driver_name, pricing_file_path=None):
size_pricing = pricing_data[driver_type][driver_name]
for driver_type in VALID_PRICING_DRIVER_TYPES:
+ # pylint: disable=maybe-no-member
pricing = pricing_data.get(driver_type, None)
if pricing:
PRICING_DATA[driver_type] = pricing
@@ -203,10 +206,11 @@ def download_pricing_file(file_url=DEFAULT_FILE_URL,
# Verify pricing file is valid
try:
data = json.loads(body)
- except json.decoder.JSONDecodeError:
+ except JSONDecodeError:
msg = 'Provided URL doesn\'t contain valid pricing data'
raise Exception(msg)
+ # pylint: disable=maybe-no-member
if not data.get('updated', None):
msg = 'Provided URL doesn\'t contain valid pricing data'
raise Exception(msg)
http://git-wip-us.apache.org/repos/asf/libcloud/blob/ad43fc47/libcloud/storage/drivers/cloudfiles.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/drivers/cloudfiles.py b/libcloud/storage/drivers/cloudfiles.py
index b0694ac..a2189c1 100644
--- a/libcloud/storage/drivers/cloudfiles.py
+++ b/libcloud/storage/drivers/cloudfiles.py
@@ -307,6 +307,7 @@ class CloudFilesStorageDriver(StorageDriver, OpenStackDriverMixin):
raise LibcloudError('Unexpected status code: %s' % (response.status))
def get_container_cdn_url(self, container):
+ # pylint: disable=unexpected-keyword-arg
container_name_encoded = self._encode_container_name(container.name)
response = self.connection.request('/%s' % (container_name_encoded),
method='HEAD',
@@ -339,6 +340,7 @@ class CloudFilesStorageDriver(StorageDriver, OpenStackDriverMixin):
if ex_ttl:
headers['X-TTL'] = ex_ttl
+ # pylint: disable=unexpected-keyword-arg
response = self.connection.request('/%s' % (container_name),
method='PUT',
headers=headers,
@@ -467,6 +469,7 @@ class CloudFilesStorageDriver(StorageDriver, OpenStackDriverMixin):
object_name = self._encode_object_name(obj.name)
headers = {'X-Purge-Email': email} if email else {}
+ # pylint: disable=unexpected-keyword-arg
response = self.connection.request('/%s/%s' % (container_name,
object_name),
method='DELETE',
@@ -538,6 +541,7 @@ class CloudFilesStorageDriver(StorageDriver, OpenStackDriverMixin):
container_name = container.name
headers = {'X-Container-Meta-Web-Index': index_file}
+ # pylint: disable=unexpected-keyword-arg
response = self.connection.request('/%s' % (container_name),
method='POST',
headers=headers,
@@ -561,6 +565,7 @@ class CloudFilesStorageDriver(StorageDriver, OpenStackDriverMixin):
container_name = container.name
headers = {'X-Container-Meta-Web-Error': file_name}
+ # pylint: disable=unexpected-keyword-arg
response = self.connection.request('/%s' % (container_name),
method='POST',
headers=headers,
@@ -580,6 +585,7 @@ class CloudFilesStorageDriver(StorageDriver, OpenStackDriverMixin):
"""
headers = {'X-Account-Meta-Temp-URL-Key': key}
+ # pylint: disable=unexpected-keyword-arg
response = self.connection.request('',
method='POST',
headers=headers,
@@ -607,6 +613,7 @@ class CloudFilesStorageDriver(StorageDriver, OpenStackDriverMixin):
:rtype: ``bool``
"""
+ # pylint: disable=no-member
self.connection._populate_hosts_and_request_paths()
expires = int(time() + timeout)
path = '%s/%s/%s' % (self.connection.request_path,
@@ -654,6 +661,7 @@ class CloudFilesStorageDriver(StorageDriver, OpenStackDriverMixin):
object_name_encoded = self._encode_object_name(object_name)
request_path = '/%s/%s' % (container_name_encoded, object_name_encoded)
+ # pylint: disable=no-member
headers = {'X-Auth-Token': self.connection.auth_token,
'X-Object-Manifest': '%s/%s/' %
(container_name_encoded,
http://git-wip-us.apache.org/repos/asf/libcloud/blob/ad43fc47/libcloud/storage/drivers/local.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/drivers/local.py b/libcloud/storage/drivers/local.py
index 5e326f9..985243d 100644
--- a/libcloud/storage/drivers/local.py
+++ b/libcloud/storage/drivers/local.py
@@ -90,9 +90,9 @@ class LocalStorageDriver(StorageDriver):
if not os.path.isdir(self.base_path):
raise LibcloudError('The base path is not a directory')
- super(StorageDriver, self).__init__(key=key, secret=secret,
- secure=secure, host=host,
- port=port, **kwargs)
+ super(LocalStorageDriver, self).__init__(key=key, secret=secret,
+ secure=secure, host=host,
+ port=port, **kwargs)
def _make_path(self, path, ignore_existing=True):
"""
http://git-wip-us.apache.org/repos/asf/libcloud/blob/ad43fc47/libcloud/storage/drivers/nimbus.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/drivers/nimbus.py b/libcloud/storage/drivers/nimbus.py
index b649e8b..583aefb 100644
--- a/libcloud/storage/drivers/nimbus.py
+++ b/libcloud/storage/drivers/nimbus.py
@@ -41,7 +41,7 @@ class NimbusResponse(JsonResponse):
if self.status in [httplib.UNAUTHORIZED]:
raise InvalidCredsError(self.body)
raise LibcloudError('Unknown error. Status code: %d' % (self.status),
- driver=self.driver)
+ driver=self.connection.driver)
class NimbusConnection(ConnectionUserAndKey):
@@ -89,13 +89,13 @@ class NimbusStorageDriver(StorageDriver):
def iterate_containers(self):
response = self.connection.request('/customers/%s/collections' %
- (self.connection.user_id))
+ (self.user_id))
return self._to_containers(response.object)
def create_container(self, container_name):
params = {'action': 'create', 'name': container_name}
response = self.connection.request('/customers/%s/collections' %
- (self.connection.user_id),
+ (self.user_id),
params=params,
method='POST')
return self._to_container(response.object)
http://git-wip-us.apache.org/repos/asf/libcloud/blob/ad43fc47/libcloud/storage/drivers/s3.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/drivers/s3.py b/libcloud/storage/drivers/s3.py
index 9577f98..862f076 100644
--- a/libcloud/storage/drivers/s3.py
+++ b/libcloud/storage/drivers/s3.py
@@ -602,6 +602,7 @@ class BaseS3StorageDriver(StorageDriver):
if response.status != httplib.OK:
element = response.object
+ # pylint: disable=maybe-no-member
code, message = response._parse_error_details(element=element)
msg = 'Error in multipart commit: %s (%s)' % (message, code)
raise LibcloudError(msg, driver=self)
@@ -730,6 +731,7 @@ class BaseS3StorageDriver(StorageDriver):
driver=self)
body = response.parse_body()
+ # pylint: disable=maybe-no-member
for node in body.findall(fixxpath(xpath='Upload',
namespace=self.namespace)):
@@ -748,6 +750,7 @@ class BaseS3StorageDriver(StorageDriver):
initiator, owner)
# Check if this is the last entry in the listing
+ # pylint: disable=maybe-no-member
is_truncated = body.findtext(fixxpath(xpath='IsTruncated',
namespace=self.namespace))
http://git-wip-us.apache.org/repos/asf/libcloud/blob/ad43fc47/libcloud/utils/py3.py
----------------------------------------------------------------------
diff --git a/libcloud/utils/py3.py b/libcloud/utils/py3.py
index 2e4fc38..4e05419 100644
--- a/libcloud/utils/py3.py
+++ b/libcloud/utils/py3.py
@@ -58,6 +58,7 @@ if PY3:
from io import StringIO
import urllib
import urllib as urllib2
+ # pylint: disable=no-name-in-module
import urllib.parse as urlparse
import xmlrpc.client as xmlrpclib
@@ -180,6 +181,7 @@ if PY25:
# Taken from http://jimmyg.org/work/code/barenecessities/index.html
# (MIT license)
+ # pylint: disable=function-redefined
def relpath(path, start=posixpath.curdir): # NOQA
"""Return a relative version of a path"""
if not path:
[2/2] git commit: Add pylint config and pylint tox target.
Posted by to...@apache.org.
Add pylint config and pylint tox target.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/688ec755
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/688ec755
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/688ec755
Branch: refs/heads/trunk
Commit: 688ec75504d76ba370f96bbe06115762cc87b252
Parents: ad43fc4
Author: Tomaz Muraus <to...@apache.org>
Authored: Sat Sep 13 17:52:43 2014 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Sat Sep 13 17:52:43 2014 +0200
----------------------------------------------------------------------
.pylintrc | 35 +++++++++++++++++++++++++++++++++++
tox.ini | 4 ++++
2 files changed, 39 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/688ec755/.pylintrc
----------------------------------------------------------------------
diff --git a/.pylintrc b/.pylintrc
new file mode 100644
index 0000000..56d02c2
--- /dev/null
+++ b/.pylintrc
@@ -0,0 +1,35 @@
+[MASTER]
+# Add <file or directory> to the black list. It should be a base name, not a
+# path. You may set this option multiple times.
+ignore=test
+
+
+# Pickle collected data for later comparisons.
+persistent=yes
+
+# List of plugins (as comma separated values of python modules names) to load,
+# usually to register additional checkers.
+load-plugins=
+
+
+[MESSAGES CONTROL]
+disable=redefined-builtin,too-many-arguments,too-few-public-methods,missing-docstring,invalid-name,abstract-method,no-self-use
+
+
+[TYPECHECK]
+# List of members which are set dynamically and missed by pylint inference
+# system, and so shouldn't trigger E0201 when accessed. Python regular
+# expressions are accepted.
+generated-members=async_request,objects
+
+[VARIABLES]
+
+# Tells wether we should check for unused import in __init__ files.
+init-import=no
+
+# A regular expression matching names used for dummy variables (i.e. not used).
+dummy-variables-rgx=_|dummy
+
+# List of additional names supposed to be defined in builtins. Remember that
+# you should avoid to define new builtins when possible.
+additional-builtins=
http://git-wip-us.apache.org/repos/asf/libcloud/blob/688ec755/tox.ini
----------------------------------------------------------------------
diff --git a/tox.ini b/tox.ini
index 52b51f7..30516b0 100644
--- a/tox.ini
+++ b/tox.ini
@@ -58,6 +58,10 @@ deps = requests
basepython = python2.7
commands = python contrib/scrape-ec2-prices.py
+[testenv:pylint]
+depds = pylint
+commands = pylint --rcfile=.pylintrc -E libcloud/
+
[testenv:lint]
deps = flake8
commands = flake8 --exclude="test" libcloud/