tox: update pep8 parameters based on the latest Swift
This also fixes newly detected style errors. Change-Id: Ib0c2241986415ec0246611c2155dc1d773399b3a
This commit is contained in:
@@ -25,6 +25,7 @@ XMLNS_XSI = 'http://www.w3.org/2001/XMLSchema-instance'
|
|||||||
|
|
||||||
MAX_ACL_BODY_SIZE = 200 * 1024
|
MAX_ACL_BODY_SIZE = 200 * 1024
|
||||||
|
|
||||||
|
|
||||||
def add_canonical_user(parent, tag, user, nsmap=None):
|
def add_canonical_user(parent, tag, user, nsmap=None):
|
||||||
"""
|
"""
|
||||||
Create an element for cannonical user.
|
Create an element for cannonical user.
|
||||||
@@ -91,10 +92,11 @@ def swift_acl_translate(acl, group='', user='', xml=False):
|
|||||||
['HTTP_X_CONTAINER_READ',
|
['HTTP_X_CONTAINER_READ',
|
||||||
'.r:*,.rlistings']]
|
'.r:*,.rlistings']]
|
||||||
|
|
||||||
#TODO: if there's a way to get group and user, this should work for
|
# TODO: if there's a way to get group and user, this should work for
|
||||||
# private:
|
# private:
|
||||||
#swift_acl['private'] = [['HTTP_X_CONTAINER_WRITE', group + ':' + user], \
|
# swift_acl['private'] = \
|
||||||
# ['HTTP_X_CONTAINER_READ', group + ':' + user]]
|
# [['HTTP_X_CONTAINER_WRITE', group + ':' + user], \
|
||||||
|
# ['HTTP_X_CONTAINER_READ', group + ':' + user]]
|
||||||
swift_acl['private'] = [['HTTP_X_CONTAINER_WRITE', '.'],
|
swift_acl['private'] = [['HTTP_X_CONTAINER_WRITE', '.'],
|
||||||
['HTTP_X_CONTAINER_READ', '.']]
|
['HTTP_X_CONTAINER_READ', '.']]
|
||||||
if xml:
|
if xml:
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ from swift3.cfg import CONF
|
|||||||
|
|
||||||
LOGGER = get_logger(CONF, log_route='swift3')
|
LOGGER = get_logger(CONF, log_route='swift3')
|
||||||
|
|
||||||
|
|
||||||
def bucket_operation(func=None, err_resp=None, err_msg=None):
|
def bucket_operation(func=None, err_resp=None, err_msg=None):
|
||||||
"""
|
"""
|
||||||
A decorator to ensure that the request is a bucket operation. If the
|
A decorator to ensure that the request is a bucket operation. If the
|
||||||
@@ -49,6 +50,7 @@ def bucket_operation(func=None, err_resp=None, err_msg=None):
|
|||||||
else:
|
else:
|
||||||
return _bucket_operation
|
return _bucket_operation
|
||||||
|
|
||||||
|
|
||||||
def object_operation(func):
|
def object_operation(func):
|
||||||
"""
|
"""
|
||||||
A decorator to ensure that the request is an object operation. If the
|
A decorator to ensure that the request is an object operation. If the
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ XMLNS_S3 = 'http://s3.amazonaws.com/doc/2006-03-01/'
|
|||||||
|
|
||||||
LOGGER = get_logger(CONF, log_route='swift3')
|
LOGGER = get_logger(CONF, log_route='swift3')
|
||||||
|
|
||||||
|
|
||||||
class DocumentInvalid(S3Exception, lxml.etree.DocumentInvalid):
|
class DocumentInvalid(S3Exception, lxml.etree.DocumentInvalid):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ from swift3.response import ErrorResponse, InternalError, MethodNotAllowed, \
|
|||||||
ResponseBase
|
ResponseBase
|
||||||
from swift3.cfg import CONF
|
from swift3.cfg import CONF
|
||||||
|
|
||||||
|
|
||||||
def validate_bucket_name(name):
|
def validate_bucket_name(name):
|
||||||
"""
|
"""
|
||||||
Validates the name of the bucket against S3 criteria,
|
Validates the name of the bucket against S3 criteria,
|
||||||
@@ -104,7 +105,7 @@ class Swift3Middleware(object):
|
|||||||
if isinstance(err_resp, InternalError):
|
if isinstance(err_resp, InternalError):
|
||||||
self.logger.exception(err_resp)
|
self.logger.exception(err_resp)
|
||||||
resp = err_resp
|
resp = err_resp
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.logger.exception(e)
|
self.logger.exception(e)
|
||||||
resp = InternalError(reason=e)
|
resp = InternalError(reason=e)
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import unittest
|
|||||||
|
|
||||||
from swift3.cfg import Config
|
from swift3.cfg import Config
|
||||||
|
|
||||||
|
|
||||||
class TestSwift3Cfg(unittest.TestCase):
|
class TestSwift3Cfg(unittest.TestCase):
|
||||||
def test_config(self):
|
def test_config(self):
|
||||||
conf = Config(
|
conf = Config(
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ class TestSwift3Logging(Swift3TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestSwift3Logging, self).setUp()
|
super(TestSwift3Logging, self).setUp()
|
||||||
|
|
||||||
|
|
||||||
def test_object_logging_GET(self):
|
def test_object_logging_GET(self):
|
||||||
req = Request.blank('/bucket/object?logging',
|
req = Request.blank('/bucket/object?logging',
|
||||||
environ={'REQUEST_METHOD': 'GET'},
|
environ={'REQUEST_METHOD': 'GET'},
|
||||||
|
|||||||
@@ -136,12 +136,10 @@ class TestSwift3Middleware(Swift3TestCase):
|
|||||||
'response-content-encoding&response-content-language&'
|
'response-content-encoding&response-content-language&'
|
||||||
'response-content-type&response-expires', {})
|
'response-content-type&response-expires', {})
|
||||||
|
|
||||||
str1 = canonical_string('/', headers=
|
str1 = canonical_string('/', headers={'Content-Type': None,
|
||||||
{'Content-Type': None,
|
'X-Amz-Something': 'test'})
|
||||||
'X-Amz-Something': 'test'})
|
str2 = canonical_string('/', headers={'Content-Type': '',
|
||||||
str2 = canonical_string('/', headers=
|
'X-Amz-Something': 'test'})
|
||||||
{'Content-Type': '',
|
|
||||||
'X-Amz-Something': 'test'})
|
|
||||||
str3 = canonical_string('/', headers={'X-Amz-Something': 'test'})
|
str3 = canonical_string('/', headers={'X-Amz-Something': 'test'})
|
||||||
|
|
||||||
self.assertEquals(str1, str2)
|
self.assertEquals(str1, str2)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
def camel_to_snake(camel):
|
def camel_to_snake(camel):
|
||||||
return re.sub('(.)([A-Z])', r'\1_\2', camel).lower()
|
return re.sub('(.)([A-Z])', r'\1_\2', camel).lower()
|
||||||
|
|
||||||
|
|||||||
2
tox.ini
2
tox.ini
@@ -54,6 +54,6 @@ downloadcache = ~/cache/pip
|
|||||||
[flake8]
|
[flake8]
|
||||||
# follow the same style guidelines with swift
|
# follow the same style guidelines with swift
|
||||||
ignore = H
|
ignore = H
|
||||||
select = H102,H103,H201,H501,H903
|
select = F,E,W,H102,H103,H501,H903,H231
|
||||||
exclude = .venv,.git,.tox,dist,doc,*egg,build
|
exclude = .venv,.git,.tox,dist,doc,*egg,build
|
||||||
show-source = True
|
show-source = True
|
||||||
|
|||||||
Reference in New Issue
Block a user