Skip to content

Commit

Permalink
Merge pull request #247 from harshavardhana/pr_out_more_pylint_cleanup
Browse files Browse the repository at this point in the history
More pylint cleanup
  • Loading branch information
Harshavardhana committed Jul 21, 2015
2 parents cfdea7c + 9d26218 commit dc0ab38
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 21 deletions.
3 changes: 1 addition & 2 deletions minio/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ def get_version():

sub = ''
if version_info[3] == 'alpha' and version_info[4] == 0:
# TODO: maybe append some sort of git info here??
sub = '.dev'
sub = '.dev0'
elif version_info[3] != 'final':
mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c'}
sub = mapping[version_info[3]] + str(version_info[4])
Expand Down
6 changes: 3 additions & 3 deletions minio/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def urlencode(text):
return compat_url2pathname(text)


compat_str_type = None
strtype = None
if sys.version_info < (3, 0):
compat_str_type = basestring
strtype = basestring
else:
compat_str_type = str
strtype = str
17 changes: 15 additions & 2 deletions minio/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ def __init__(self, bucket, key, upload_id):
self.upload_id = upload_id

def __str__(self):
return '<IncompleteUpload: {0} {1} {2}>'.format(self.bucket, self.key,
self.upload_id)
string_format = '<IncompleteUpload: bucket: {0} key: {1}' \
' upload_id: {2}>'
return string_format.format(self.bucket, self.key, self.upload_id)

class UploadPart(object):
def __init__(self, bucket, key, upload_id, part_number, etag,
Expand All @@ -60,3 +61,15 @@ def __init__(self, bucket, key, upload_id, part_number, etag,
self.etag = etag
self.last_modified = last_modified
self.size = size

def __str__(self):
string_format = '<UploadPart: bucket: {0} key: {1} upload_id: {2}' \
' part_number: {3} etag: {4} last_modified: {5}' \
' size: {6}>'
return string_format.format(self.bucket,
self.key,
self.upload_id,
self.part_number,
self.etag,
self.last_modified,
self.size)
6 changes: 3 additions & 3 deletions minio/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import hashlib
import re

from ._compat import compat_str_type, compat_pathname2url
from ._compat import strtype, compat_pathname2url

def get_region(hostname):
"""
Expand Down Expand Up @@ -84,7 +84,7 @@ def is_valid_url(url):
"""
validate a given url
"""
if not isinstance(url, compat_str_type):
if not isinstance(url, strtype):
raise TypeError('url')

regex = re.compile(
Expand Down Expand Up @@ -117,7 +117,7 @@ def is_non_empty_string(input_string):
"""
validate if non empty string
"""
if not isinstance(input_string, compat_str_type):
if not isinstance(input_string, strtype):
raise TypeError()
if not input_string.strip():
raise ValueError()
Expand Down
12 changes: 6 additions & 6 deletions minio/minio.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from .__version__ import get_version
from .acl import is_valid_acl
from ._compat import compat_urllib_parse, compat_str_type
from ._compat import compat_urllib_parse, strtype
from .generators import (ListObjectsIterator, ListIncompleteUploads,
ListUploadParts, DataStreamer)
from .helpers import (get_target_url, is_non_empty_string, is_valid_url,
Expand Down Expand Up @@ -90,8 +90,8 @@ def set_user_agent(self, name=None, version=None, comments=None):
"""
if name is None or version is None:
raise TypeError()
if not isinstance(name, compat_str_type) or \
not isinstance(version, compat_str_type):
if not isinstance(name, strtype) or \
not isinstance(version, strtype):
raise TypeError()
if not name.strip() or not version.strip():
raise ValueError()
Expand Down Expand Up @@ -183,7 +183,7 @@ def list_buckets(self):

if response.status != 200:
try:
parse_error(response, bucket)
parse_error(response)
except ResponseError as err:
if err.code == 'Redirect':
err.code = 'AccessDeniedException'
Expand Down Expand Up @@ -418,7 +418,7 @@ def put_object(self, bucket, key, data, length=0,
data = data.read(length)
if isinstance(data, io.TextIOWrapper):
data = data.read(length).encode('utf-8')
if sys.version_info >= (3, 0) and isinstance(data, compat_str_type):
if sys.version_info >= (3, 0) and isinstance(data, strtype):
data = data.encode('utf-8')
return self._do_put_object(bucket, key, length, data, content_type)
self._stream_put_object(bucket, key, length, data, content_type)
Expand Down Expand Up @@ -583,7 +583,7 @@ def _stream_put_object(self, bucket, key, length, data, content_type):
if not isinstance(data, io.BufferedReader):
if not isinstance(data, RawIOBase):
if sys.version_info >= (3, 0):
if isinstance(data, compat_str_type):
if isinstance(data, strtype):
data = data.encode('utf-8')
data = io.BytesIO(data)
data = io.BufferedReader(data)
Expand Down
4 changes: 2 additions & 2 deletions minio/signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import binascii

from datetime import datetime
from ._compat import compat_urllib_parse, compat_str_type
from ._compat import compat_urllib_parse, strtype
from .helpers import get_region

empty_sha256 = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
Expand Down Expand Up @@ -121,7 +121,7 @@ def generate_canonical_request(method, parsed_url, headers, content_hash_hex):
header_lines = []
for header in headers:
value = headers[header]
if isinstance(value, compat_str_type):
if isinstance(value, strtype):
value = value.strip()
header = header.lower().strip()
signed_headers.append(header)
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
except ImportError: # python 2
from urlparse import urlparse as compat_urllib_parse

compat_str_type = None
strtype = None
if sys.version_info < (3, 0):
compat_str_type = basestring
strtype = basestring
else:
compat_str_type = str
strtype = str

0 comments on commit dc0ab38

Please sign in to comment.