diff --git a/swift3/controllers/acl.py b/swift3/controllers/acl.py index 80050ca3..e9943276 100644 --- a/swift3/controllers/acl.py +++ b/swift3/controllers/acl.py @@ -25,6 +25,7 @@ XMLNS_XSI = 'http://www.w3.org/2001/XMLSchema-instance' MAX_ACL_BODY_SIZE = 200 * 1024 + def add_canonical_user(parent, tag, user, nsmap=None): """ Create an element for cannonical user. @@ -91,10 +92,11 @@ def swift_acl_translate(acl, group='', user='', xml=False): ['HTTP_X_CONTAINER_READ', '.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: - #swift_acl['private'] = [['HTTP_X_CONTAINER_WRITE', group + ':' + user], \ - # ['HTTP_X_CONTAINER_READ', group + ':' + user]] + # swift_acl['private'] = \ + # [['HTTP_X_CONTAINER_WRITE', group + ':' + user], \ + # ['HTTP_X_CONTAINER_READ', group + ':' + user]] swift_acl['private'] = [['HTTP_X_CONTAINER_WRITE', '.'], ['HTTP_X_CONTAINER_READ', '.']] if xml: diff --git a/swift3/controllers/base.py b/swift3/controllers/base.py index 7f1c412a..e5730bdc 100644 --- a/swift3/controllers/base.py +++ b/swift3/controllers/base.py @@ -23,6 +23,7 @@ from swift3.cfg import CONF LOGGER = get_logger(CONF, log_route='swift3') + def bucket_operation(func=None, err_resp=None, err_msg=None): """ 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: return _bucket_operation + def object_operation(func): """ A decorator to ensure that the request is an object operation. If the diff --git a/swift3/etree.py b/swift3/etree.py index e33fa7c0..715408eb 100644 --- a/swift3/etree.py +++ b/swift3/etree.py @@ -27,6 +27,7 @@ XMLNS_S3 = 'http://s3.amazonaws.com/doc/2006-03-01/' LOGGER = get_logger(CONF, log_route='swift3') + class DocumentInvalid(S3Exception, lxml.etree.DocumentInvalid): pass diff --git a/swift3/middleware.py b/swift3/middleware.py index bbca1411..4533db19 100644 --- a/swift3/middleware.py +++ b/swift3/middleware.py @@ -62,6 +62,7 @@ from swift3.response import ErrorResponse, InternalError, MethodNotAllowed, \ ResponseBase from swift3.cfg import CONF + def validate_bucket_name(name): """ Validates the name of the bucket against S3 criteria, @@ -104,7 +105,7 @@ class Swift3Middleware(object): if isinstance(err_resp, InternalError): self.logger.exception(err_resp) resp = err_resp - except Exception, e: + except Exception as e: self.logger.exception(e) resp = InternalError(reason=e) diff --git a/swift3/test/unit/test_cfg.py b/swift3/test/unit/test_cfg.py index 8447db5e..8963d9ec 100644 --- a/swift3/test/unit/test_cfg.py +++ b/swift3/test/unit/test_cfg.py @@ -17,6 +17,7 @@ import unittest from swift3.cfg import Config + class TestSwift3Cfg(unittest.TestCase): def test_config(self): conf = Config( diff --git a/swift3/test/unit/test_logging.py b/swift3/test/unit/test_logging.py index 7032f4b8..3802d7db 100644 --- a/swift3/test/unit/test_logging.py +++ b/swift3/test/unit/test_logging.py @@ -25,7 +25,6 @@ class TestSwift3Logging(Swift3TestCase): def setUp(self): super(TestSwift3Logging, self).setUp() - def test_object_logging_GET(self): req = Request.blank('/bucket/object?logging', environ={'REQUEST_METHOD': 'GET'}, diff --git a/swift3/test/unit/test_middleware.py b/swift3/test/unit/test_middleware.py index 662ac96f..d4ca716b 100644 --- a/swift3/test/unit/test_middleware.py +++ b/swift3/test/unit/test_middleware.py @@ -136,12 +136,10 @@ class TestSwift3Middleware(Swift3TestCase): 'response-content-encoding&response-content-language&' 'response-content-type&response-expires', {}) - str1 = canonical_string('/', headers= - {'Content-Type': None, - 'X-Amz-Something': 'test'}) - str2 = canonical_string('/', headers= - {'Content-Type': '', - 'X-Amz-Something': 'test'}) + str1 = canonical_string('/', headers={'Content-Type': None, + 'X-Amz-Something': 'test'}) + str2 = canonical_string('/', headers={'Content-Type': '', + 'X-Amz-Something': 'test'}) str3 = canonical_string('/', headers={'X-Amz-Something': 'test'}) self.assertEquals(str1, str2) diff --git a/swift3/utils.py b/swift3/utils.py index b09ef252..c17f94cd 100644 --- a/swift3/utils.py +++ b/swift3/utils.py @@ -15,6 +15,7 @@ import re + def camel_to_snake(camel): return re.sub('(.)([A-Z])', r'\1_\2', camel).lower() diff --git a/tox.ini b/tox.ini index 0ba1063f..98a5ccdb 100644 --- a/tox.ini +++ b/tox.ini @@ -54,6 +54,6 @@ downloadcache = ~/cache/pip [flake8] # follow the same style guidelines with swift 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 show-source = True