diff --git a/minio/__version__.py b/minio/__version__.py index 200db9786..547ce8d83 100644 --- a/minio/__version__.py +++ b/minio/__version__.py @@ -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]) diff --git a/minio/_compat.py b/minio/_compat.py index fd590a95f..e62f40511 100644 --- a/minio/_compat.py +++ b/minio/_compat.py @@ -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 diff --git a/minio/definitions.py b/minio/definitions.py index edebd83a4..945fa1deb 100644 --- a/minio/definitions.py +++ b/minio/definitions.py @@ -47,8 +47,9 @@ def __init__(self, bucket, key, upload_id): self.upload_id = upload_id def __str__(self): - return ''.format(self.bucket, self.key, - self.upload_id) + string_format = '' + return string_format.format(self.bucket, self.key, self.upload_id) class UploadPart(object): def __init__(self, bucket, key, upload_id, part_number, etag, @@ -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 = '' + return string_format.format(self.bucket, + self.key, + self.upload_id, + self.part_number, + self.etag, + self.last_modified, + self.size) diff --git a/minio/helpers.py b/minio/helpers.py index f230245ab..1586e1986 100644 --- a/minio/helpers.py +++ b/minio/helpers.py @@ -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): """ @@ -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( @@ -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() diff --git a/minio/minio.py b/minio/minio.py index b2348f4c4..76b2bcef6 100644 --- a/minio/minio.py +++ b/minio/minio.py @@ -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, @@ -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() @@ -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' @@ -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) @@ -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) diff --git a/minio/signer.py b/minio/signer.py index 50282ff99..2dbf2c534 100644 --- a/minio/signer.py +++ b/minio/signer.py @@ -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' @@ -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) diff --git a/tests/unit/compat.py b/tests/unit/compat.py index d832ff8ac..9ac4f83a1 100644 --- a/tests/unit/compat.py +++ b/tests/unit/compat.py @@ -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