Skip to content

Commit 7349ff8

Browse files
balamuruganaharshavardhana
authored andcommitted
add pyflakes check (#451)
1 parent cd0f9ca commit 7349ff8

File tree

6 files changed

+53
-42
lines changed

6 files changed

+53
-42
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ env:
1414
- ARCH=i686
1515

1616
install:
17-
- pip install urllib3 certifi pytz
17+
- pip install urllib3 certifi pytz pyflakes
1818

1919
script:
20+
- pyflakes minio/*.py || true
2021
- python setup.py install
2122
- python setup.py nosetests
2223

minio/api.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
# Dependencies
4242
import urllib3
4343
import certifi
44-
import pytz
4544

4645
# Internal imports
4746
from . import __title__, __version__
@@ -372,7 +371,7 @@ def set_bucket_policy(self, bucket_name, prefix, policy_access):
372371
self._url_open("PUT",
373372
bucket_name=bucket_name,
374373
query={"policy": ""},
375-
headers={},
374+
headers=headers,
376375
body=content,
377376
content_sha256=content_sha256_hex)
378377

@@ -463,10 +462,10 @@ def listen_bucket_notification(self, bucket_name, prefix, suffix, events):
463462

464463
url_components = urlsplit(self._endpoint_url)
465464
if url_components.hostname == 's3.amazonaws.com':
466-
raise InvalidArgumentErr('Listening for event notifications on a'
467-
' bucket is a Minio specific extension to'
468-
' bucket notification API. It is not'
469-
' supported by Amazon S3')
465+
raise InvalidArgumentError(
466+
'Listening for event notifications on a bucket is a Minio '
467+
'specific extension to bucket notification API. It is not '
468+
'supported by Amazon S3')
470469

471470
query = {
472471
'prefix': prefix,
@@ -601,11 +600,6 @@ def fput_object(self, bucket_name, object_name, file_path,
601600
total_uploaded += previous_part.size
602601
continue
603602

604-
# Save hexlified sha256.
605-
part_sha256_hex = sha256hasher.hexdigest()
606-
# Save base64 md5sum.
607-
part_md5_base64 = md5hasher.base64digest()
608-
609603
# Seek back to previous offset position before checksum
610604
# calculation.
611605
file_data.seek(prev_offset, 0)

minio/compat.py

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,56 @@
2727

2828
import sys
2929

30-
# -------
31-
# Pythons
32-
# -------
33-
34-
# Syntax sugar.
35-
_ver = sys.version_info
36-
3730
#: Python 2.x?
38-
is_py2 = (_ver[0] == 2)
31+
_is_py2 = (sys.version_info[0] == 2)
3932

4033
#: Python 3.x?
41-
is_py3 = (_ver[0] == 3)
34+
_is_py3 = (sys.version_info[0] == 3)
4235

43-
if is_py2:
44-
from urllib import pathname2url as urlencode
45-
from urllib import url2pathname as urldecode
46-
from urlparse import urlsplit, parse_qs
36+
if _is_py2:
37+
from urllib import pathname2url
38+
urlencode = pathname2url
4739

48-
builtin_str = str
40+
from urllib import url2pathname
41+
urldecode = url2pathname
42+
43+
import urlparse
44+
urlsplit = urlparse.urlsplit
45+
parse_qs = urlparse.parse_qs
46+
47+
## Create missing types.
4948
bytes = str
49+
50+
## Update better types.
51+
builtin_range = range
52+
range = xrange
53+
builtin_str = str
5054
str = unicode
55+
56+
## Add missing imports
5157
basestring = basestring
52-
numeric_types = (int, long, float)
53-
range = xrange
58+
elif _is_py3:
59+
from urllib.request import pathname2url
60+
urlencode = pathname2url
61+
62+
from urllib.request import url2pathname
63+
urldecode = url2pathname
5464

55-
elif is_py3:
56-
from urllib.request import pathname2url as urlencode
57-
from urllib.request import url2pathname as urldecode
58-
from urllib.parse import urlsplit, parse_qs
65+
import urllib.parse
66+
urlsplit = urllib.parse.urlsplit
67+
parse_qs = urllib.parse.parse_qs
5968

69+
## Create types to compat with py2.
70+
builtin_range = range
6071
builtin_str = str
61-
str = str
62-
bytes = bytes
72+
73+
## Create missing types.
6374
basestring = (str, bytes)
64-
numeric_types = (int, float)
75+
long = int
76+
77+
## Add missing imports
78+
bytes = bytes
6579
range = range
80+
str = str
81+
82+
numeric_types = (int, long, float)

minio/copy_conditions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"""
2626

2727
import collections
28-
from .helpers import (is_non_empty_string, is_valid_bucket_name)
28+
from .helpers import is_non_empty_string
2929

3030
# CopyCondition explanation:
3131
# http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectCOPY.html

minio/signer.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@
2828
import collections
2929
import hashlib
3030
import hmac
31-
import binascii
3231

3332
from datetime import datetime
3433
from .error import InvalidArgumentError
35-
from .compat import urlsplit, parse_qs, basestring, urlencode
34+
from .compat import urlsplit, urlencode
3635
from .helpers import (ignore_headers, get_sha256_hexdigest)
3736

3837
# Signature version '4' algorithm.
@@ -158,7 +157,6 @@ def get_signed_headers(headers):
158157
159158
:param headers: input dictionary to be sorted.
160159
"""
161-
headers_to_sign = dict(headers)
162160
signed_headers = []
163161
for header in headers:
164162
signed_headers.append(header.lower().strip())

tests/unit/minio_mocks.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
2-
# Minio Python Library for Amazon S3 Compatible Cloud Storage, (C) 2015 Minio, Inc.
2+
# Minio Python Library for Amazon S3 Compatible Cloud Storage,
3+
# (C) 2015,2016 Minio, Inc.
34
#
45
# Licensed under the Apache License, Version 2.0 (the "License");
56
# you may not use this file except in compliance with the License.
@@ -13,9 +14,9 @@
1314
# See the License for the specific language governing permissions and
1415
# limitations under the License.
1516

16-
from minio.compat import is_py3
17+
from minio.compat import _is_py3
1718

18-
if is_py3:
19+
if _is_py3:
1920
import http.client as httplib
2021
else:
2122
import httplib

0 commit comments

Comments
 (0)