From a0db56dcde83096708e6fe64ae9338098e0ba98a Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 30 Jul 2015 00:16:06 +0200 Subject: [PATCH] Fix pep8 E265 warning of hacking 0.10 Fix the warning E265 "block comment should start with '# '" added in pep 1.5. Change-Id: Ib57282e958be9c7cddffc7bca34fbbf1d4c460fd --- swift/common/direct_client.py | 2 +- swift/common/http.py | 10 ++++---- swift/common/manager.py | 2 +- swift/common/middleware/keystoneauth.py | 4 ++-- swift/common/middleware/recon.py | 2 +- swift/common/middleware/tempauth.py | 2 +- .../middleware/x_profile/html_viewer.py | 2 +- swift/common/utils.py | 6 ++--- test/functional/swift_test_client.py | 4 ++-- test/functional/tests.py | 6 ++--- test/unit/account/test_replicator.py | 2 +- test/unit/cli/test_recon.py | 12 +++++----- .../common/middleware/test_account_quotas.py | 2 +- test/unit/common/middleware/test_dlo.py | 2 +- test/unit/common/middleware/test_recon.py | 24 +++++++++---------- test/unit/common/test_utils.py | 16 ++++++------- test/unit/container/test_backend.py | 4 ++-- test/unit/obj/test_server.py | 2 +- test/unit/proxy/test_server.py | 6 ++--- test/unit/test_locale/test_locale.py | 2 +- 20 files changed, 56 insertions(+), 56 deletions(-) diff --git a/swift/common/direct_client.py b/swift/common/direct_client.py index 5d78fe641a..8ba1e5e119 100644 --- a/swift/common/direct_client.py +++ b/swift/common/direct_client.py @@ -401,7 +401,7 @@ def direct_put_object(node, part, account, container, name, contents, headers['Content-Length'] = '0' if isinstance(contents, basestring): contents = [contents] - #Incase the caller want to insert an object with specific age + # Incase the caller want to insert an object with specific age add_ts = 'X-Timestamp' not in headers if content_length is None: diff --git a/swift/common/http.py b/swift/common/http.py index 1eccf9b957..070404c3a3 100644 --- a/swift/common/http.py +++ b/swift/common/http.py @@ -67,7 +67,7 @@ def is_server_error(status): # List of HTTP status codes ############################################################################### -## 1xx Informational +# 1xx Informational ############################################################################### HTTP_CONTINUE = 100 @@ -77,7 +77,7 @@ HTTP_CHECKPOINT = 103 HTTP_REQUEST_URI_TOO_LONG = 122 ############################################################################### -## 2xx Success +# 2xx Success ############################################################################### HTTP_OK = 200 @@ -91,7 +91,7 @@ HTTP_MULTI_STATUS = 207 # WebDAV HTTP_IM_USED = 226 ############################################################################### -## 3xx Redirection +# 3xx Redirection ############################################################################### HTTP_MULTIPLE_CHOICES = 300 @@ -105,7 +105,7 @@ HTTP_TEMPORARY_REDIRECT = 307 HTTP_RESUME_INCOMPLETE = 308 ############################################################################### -## 4xx Client Error +# 4xx Client Error ############################################################################### HTTP_BAD_REQUEST = 400 @@ -141,7 +141,7 @@ HTTP_BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS = 450 HTTP_CLIENT_CLOSED_REQUEST = 499 ############################################################################### -## 5xx Server Error +# 5xx Server Error ############################################################################### HTTP_INTERNAL_SERVER_ERROR = 500 diff --git a/swift/common/manager.py b/swift/common/manager.py index 43b10ed25e..eb1e93ae20 100644 --- a/swift/common/manager.py +++ b/swift/common/manager.py @@ -704,7 +704,7 @@ class Server(object): pid = self.spawn(conf_file, **kwargs) except OSError as e: if e.errno == errno.ENOENT: - #TODO(clayg): should I check if self.cmd exists earlier? + # TODO(clayg): should I check if self.cmd exists earlier? print(_("%s does not exist") % self.cmd) break else: diff --git a/swift/common/middleware/keystoneauth.py b/swift/common/middleware/keystoneauth.py index 6f70ede5f4..d57f132ff9 100644 --- a/swift/common/middleware/keystoneauth.py +++ b/swift/common/middleware/keystoneauth.py @@ -410,7 +410,7 @@ class KeystoneAuth(object): user_id, user_name = env_identity['user'] referrers, roles = swift_acl.parse_acl(getattr(req, 'acl', None)) - #allow OPTIONS requests to proceed as normal + # allow OPTIONS requests to proceed as normal if req.method == 'OPTIONS': return @@ -526,7 +526,7 @@ class KeystoneAuth(object): except ValueError: return HTTPNotFound(request=req) - #allow OPTIONS requests to proceed as normal + # allow OPTIONS requests to proceed as normal if req.method == 'OPTIONS': return diff --git a/swift/common/middleware/recon.py b/swift/common/middleware/recon.py index 88d5243a4d..8bd66a7d9b 100644 --- a/swift/common/middleware/recon.py +++ b/swift/common/middleware/recon.py @@ -340,7 +340,7 @@ class ReconMiddleware(object): elif rcheck == 'replication' and rtype in all_rtypes: content = self.get_replication_info(rtype) elif rcheck == 'replication' and rtype is None: - #handle old style object replication requests + # handle old style object replication requests content = self.get_replication_info('object') elif rcheck == "devices": content = self.get_device_info() diff --git a/swift/common/middleware/tempauth.py b/swift/common/middleware/tempauth.py index dfde519f42..15c3a4a03b 100644 --- a/swift/common/middleware/tempauth.py +++ b/swift/common/middleware/tempauth.py @@ -531,7 +531,7 @@ class TempAuth(object): return None if req.method == 'OPTIONS': - #allow OPTIONS requests to proceed as normal + # allow OPTIONS requests to proceed as normal self.logger.debug("Allow OPTIONS request.") return None diff --git a/swift/common/middleware/x_profile/html_viewer.py b/swift/common/middleware/x_profile/html_viewer.py index 7fb1c5dcd3..1132c6aa59 100644 --- a/swift/common/middleware/x_profile/html_viewer.py +++ b/swift/common/middleware/x_profile/html_viewer.py @@ -423,7 +423,7 @@ class HTMLViewer(object): plt.yticks(y_pos, nfls) plt.xlabel(names[metric_selected]) plt.title('Profile Statistics (by %s)' % names[metric_selected]) - #plt.gcf().tight_layout(pad=1.2) + # plt.gcf().tight_layout(pad=1.2) with tempfile.TemporaryFile() as profile_img: plt.savefig(profile_img, format='png', dpi=300) profile_img.seek(0) diff --git a/swift/common/utils.py b/swift/common/utils.py index ac08b984fe..093db76ac8 100644 --- a/swift/common/utils.py +++ b/swift/common/utils.py @@ -569,9 +569,9 @@ class FallocateWrapper(object): self.func_name = 'posix_fallocate' self.fallocate = noop_libc_function return - ## fallocate is preferred because we need the on-disk size to match - ## the allocated size. Older versions of sqlite require that the - ## two sizes match. However, fallocate is Linux only. + # fallocate is preferred because we need the on-disk size to match + # the allocated size. Older versions of sqlite require that the + # two sizes match. However, fallocate is Linux only. for func in ('fallocate', 'posix_fallocate'): self.func_name = func self.fallocate = load_libc_function(func, log_error=False) diff --git a/test/functional/swift_test_client.py b/test/functional/swift_test_client.py index a1a775ab98..c93b2eab09 100644 --- a/test/functional/swift_test_client.py +++ b/test/functional/swift_test_client.py @@ -208,7 +208,7 @@ class Connection(object): def http_connect(self): self.connection = self.conn_class(self.storage_host, port=self.storage_port) - #self.connection.set_debuglevel(3) + # self.connection.set_debuglevel(3) def make_path(self, path=None, cfg=None): if path is None: @@ -334,7 +334,7 @@ class Connection(object): self.connection = self.conn_class(self.storage_host, port=self.storage_port) - #self.connection.set_debuglevel(3) + # self.connection.set_debuglevel(3) self.connection.putrequest('PUT', path) for key, value in headers.items(): self.connection.putheader(key, value) diff --git a/test/functional/tests.py b/test/functional/tests.py index f09f10aeaf..6e0dc1fb69 100644 --- a/test/functional/tests.py +++ b/test/functional/tests.py @@ -1403,7 +1403,7 @@ class TestFile(Base): self.assertTrue(file_item.read(hdrs=hdrs) == data, range_string) def testRangedGetsWithLWSinHeader(self): - #Skip this test until webob 1.2 can tolerate LWS in Range header. + # Skip this test until webob 1.2 can tolerate LWS in Range header. file_length = 10000 file_item = self.env.container.file(Utils.create_name()) data = file_item.write_random(file_length) @@ -1478,8 +1478,8 @@ class TestFile(Base): self.assert_status(501) # bad request types - #for req in ('LICK', 'GETorHEAD_base', 'container_info', - # 'best_response'): + # for req in ('LICK', 'GETorHEAD_base', 'container_info', + # 'best_response'): for req in ('LICK', 'GETorHEAD_base'): self.env.account.conn.make_request(req) self.assert_status(405) diff --git a/test/unit/account/test_replicator.py b/test/unit/account/test_replicator.py index 43e3a4d725..34aad91184 100644 --- a/test/unit/account/test_replicator.py +++ b/test/unit/account/test_replicator.py @@ -77,7 +77,7 @@ class TestReplicatorSync(test_db_replicator.TestReplicatorSync): # add a row to "local" db broker.put_container('/a/c', time.time(), 0, 0, 0, POLICIES.default.idx) - #replicate + # replicate daemon = replicator.AccountReplicator({}) def _rsync_file(db_file, remote_file, **kwargs): diff --git a/test/unit/cli/test_recon.py b/test/unit/cli/test_recon.py index 009b53f7f0..f48d44cac6 100644 --- a/test/unit/cli/test_recon.py +++ b/test/unit/cli/test_recon.py @@ -387,7 +387,7 @@ class TestReconCommands(unittest.TestCase): res_account = 'Invalid: http://127.0.0.1:6012/ is account-server' valid = "1/1 hosts ok, 0 error[s] while checking hosts." - #Test for object server type - default + # Test for object server type - default with nested(*patches): self.recon.server_type_check(hosts) @@ -396,7 +396,7 @@ class TestReconCommands(unittest.TestCase): self.assertTrue(res_account in output.splitlines()) stdout.truncate(0) - #Test ok for object server type - default + # Test ok for object server type - default with nested(*patches): self.recon.server_type_check([hosts[0]]) @@ -404,7 +404,7 @@ class TestReconCommands(unittest.TestCase): self.assertTrue(valid in output.splitlines()) stdout.truncate(0) - #Test for account server type + # Test for account server type with nested(*patches): self.recon.server_type = 'account' self.recon.server_type_check(hosts) @@ -414,7 +414,7 @@ class TestReconCommands(unittest.TestCase): self.assertTrue(res_object in output.splitlines()) stdout.truncate(0) - #Test ok for account server type + # Test ok for account server type with nested(*patches): self.recon.server_type = 'account' self.recon.server_type_check([hosts[2]]) @@ -423,7 +423,7 @@ class TestReconCommands(unittest.TestCase): self.assertTrue(valid in output.splitlines()) stdout.truncate(0) - #Test for container server type + # Test for container server type with nested(*patches): self.recon.server_type = 'container' self.recon.server_type_check(hosts) @@ -433,7 +433,7 @@ class TestReconCommands(unittest.TestCase): self.assertTrue(res_object in output.splitlines()) stdout.truncate(0) - #Test ok for container server type + # Test ok for container server type with nested(*patches): self.recon.server_type = 'container' self.recon.server_type_check([hosts[1]]) diff --git a/test/unit/common/middleware/test_account_quotas.py b/test/unit/common/middleware/test_account_quotas.py index e8c2563c5a..ef995b10fe 100644 --- a/test/unit/common/middleware/test_account_quotas.py +++ b/test/unit/common/middleware/test_account_quotas.py @@ -96,7 +96,7 @@ class TestAccountQuota(unittest.TestCase): environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache}) res = req.get_response(app) - #Response code of 200 because authentication itself is not done here + # Response code of 200 because authentication itself is not done here self.assertEquals(res.status_int, 200) def test_no_quotas(self): diff --git a/test/unit/common/middleware/test_dlo.py b/test/unit/common/middleware/test_dlo.py index 119e4aba55..c290430e08 100644 --- a/test/unit/common/middleware/test_dlo.py +++ b/test/unit/common/middleware/test_dlo.py @@ -1,4 +1,4 @@ -#-*- coding:utf-8 -*- +# coding: utf-8 # Copyright (c) 2013 OpenStack Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test/unit/common/middleware/test_recon.py b/test/unit/common/middleware/test_recon.py index 05a11ce859..56ed93d3fc 100644 --- a/test/unit/common/middleware/test_recon.py +++ b/test/unit/common/middleware/test_recon.py @@ -774,11 +774,11 @@ class TestReconSuccess(TestCase): self.assertEquals(rv, unmounted_resp) def test_get_diskusage(self): - #posix.statvfs_result(f_bsize=4096, f_frsize=4096, f_blocks=1963185, - # f_bfree=1113075, f_bavail=1013351, - # f_files=498736, - # f_ffree=397839, f_favail=397839, f_flag=0, - # f_namemax=255) + # posix.statvfs_result(f_bsize=4096, f_frsize=4096, f_blocks=1963185, + # f_bfree=1113075, f_bavail=1013351, + # f_files=498736, + # f_ffree=397839, f_favail=397839, f_flag=0, + # f_namemax=255) statvfs_content = (4096, 4096, 1963185, 1113075, 1013351, 498736, 397839, 397839, 0, 255) du_resp = [{'device': 'canhazdrive1', 'avail': 4150685696, @@ -815,9 +815,9 @@ class TestReconSuccess(TestCase): self.mockos.ismount_output = True def fake_lstat(*args, **kwargs): - #posix.lstat_result(st_mode=1, st_ino=2, st_dev=3, st_nlink=4, - # st_uid=5, st_gid=6, st_size=7, st_atime=8, - # st_mtime=9, st_ctime=10) + # posix.lstat_result(st_mode=1, st_ino=2, st_dev=3, st_nlink=4, + # st_uid=5, st_gid=6, st_size=7, st_atime=8, + # st_mtime=9, st_ctime=10) return stat_result((1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) def fake_exists(*args, **kwargs): @@ -867,7 +867,7 @@ class TestReconMiddleware(unittest.TestCase): os.listdir = self.fake_list self.app = recon.ReconMiddleware(FakeApp(), {'object_recon': "true"}) os.listdir = self.real_listdir - #self.app.object_recon = True + # self.app.object_recon = True self.app.get_mem = self.frecon.fake_mem self.app.get_load = self.frecon.fake_load self.app.get_async_info = self.frecon.fake_async @@ -927,21 +927,21 @@ class TestReconMiddleware(unittest.TestCase): def test_recon_get_replication_all(self): get_replication_resp = ['{"replicationtest": "1"}'] - #test account + # test account req = Request.blank('/recon/replication/account', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) self.assertEquals(resp, get_replication_resp) self.assertEquals(self.frecon.fake_replication_rtype, 'account') self.frecon.fake_replication_rtype = None - #test container + # test container req = Request.blank('/recon/replication/container', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) self.assertEquals(resp, get_replication_resp) self.assertEquals(self.frecon.fake_replication_rtype, 'container') self.frecon.fake_replication_rtype = None - #test object + # test object req = Request.blank('/recon/replication/object', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) diff --git a/test/unit/common/test_utils.py b/test/unit/common/test_utils.py index b5dc6edf32..809a0d440c 100644 --- a/test/unit/common/test_utils.py +++ b/test/unit/common/test_utils.py @@ -4298,7 +4298,7 @@ class TestAuditLocationGenerator(unittest.TestCase): else: return orig_listdir(path) - #Check Raise on Bad partition + # Check Raise on Bad partition tmpdir = mkdtemp() data = os.path.join(tmpdir, "drive", "data") os.makedirs(data) @@ -4315,7 +4315,7 @@ class TestAuditLocationGenerator(unittest.TestCase): self.assertRaises(OSError, audit) rmtree(tmpdir) - #Check Raise on Bad Suffix + # Check Raise on Bad Suffix tmpdir = mkdtemp() data = os.path.join(tmpdir, "drive", "data") os.makedirs(data) @@ -4334,7 +4334,7 @@ class TestAuditLocationGenerator(unittest.TestCase): self.assertRaises(OSError, audit) rmtree(tmpdir) - #Check Raise on Bad Hash + # Check Raise on Bad Hash tmpdir = mkdtemp() data = os.path.join(tmpdir, "drive", "data") os.makedirs(data) @@ -4358,14 +4358,14 @@ class TestAuditLocationGenerator(unittest.TestCase): logger = FakeLogger() data = os.path.join(tmpdir, "drive", "data") os.makedirs(data) - #Create a file, that represents a non-dir drive + # Create a file, that represents a non-dir drive open(os.path.join(tmpdir, 'asdf'), 'w') locations = utils.audit_location_generator( tmpdir, "data", mount_check=False, logger=logger ) self.assertEqual(list(locations), []) self.assertEqual(1, len(logger.get_lines_for_level('warning'))) - #Test without the logger + # Test without the logger locations = utils.audit_location_generator( tmpdir, "data", mount_check=False ) @@ -4376,7 +4376,7 @@ class TestAuditLocationGenerator(unittest.TestCase): logger = FakeLogger() data = os.path.join(tmpdir, "drive", "data") os.makedirs(data) - #Create a file, that represents a non-dir drive + # Create a file, that represents a non-dir drive open(os.path.join(tmpdir, 'asdf'), 'w') locations = utils.audit_location_generator( tmpdir, "data", mount_check=True, logger=logger @@ -4384,7 +4384,7 @@ class TestAuditLocationGenerator(unittest.TestCase): self.assertEqual(list(locations), []) self.assertEqual(2, len(logger.get_lines_for_level('warning'))) - #Test without the logger + # Test without the logger locations = utils.audit_location_generator( tmpdir, "data", mount_check=True ) @@ -4416,7 +4416,7 @@ class TestAuditLocationGenerator(unittest.TestCase): logger = FakeLogger() data = os.path.join(tmpdir, "drive", "data") os.makedirs(data) - #Create a file, that represents a non-dir drive + # Create a file, that represents a non-dir drive open(os.path.join(tmpdir, 'asdf'), 'w') partition = os.path.join(data, "partition1") os.makedirs(partition) diff --git a/test/unit/container/test_backend.py b/test/unit/container/test_backend.py index 0880c32aee..1572265c2d 100644 --- a/test/unit/container/test_backend.py +++ b/test/unit/container/test_backend.py @@ -994,8 +994,8 @@ class TestContainerBroker(unittest.TestCase): '/snakes', Timestamp(0).internal, 0, 'text/plain', 'd41d8cd98f00b204e9800998ecf8427e') - #def list_objects_iter(self, limit, marker, prefix, delimiter, - # path=None, format=None): + # def list_objects_iter(self, limit, marker, prefix, delimiter, + # path=None, format=None): listing = broker.list_objects_iter(100, None, None, '/pets/f', '/') self.assertEquals([row[0] for row in listing], ['/pets/fish/', '/pets/fish_info.txt']) diff --git a/test/unit/obj/test_server.py b/test/unit/obj/test_server.py index b07c25139c..7a5dff5a4c 100755 --- a/test/unit/obj/test_server.py +++ b/test/unit/obj/test_server.py @@ -1,4 +1,4 @@ -#-*- coding:utf-8 -*- +# coding: utf-8 # Copyright (c) 2010-2012 OpenStack Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py index dde59e3597..83cb05cfce 100644 --- a/test/unit/proxy/test_server.py +++ b/test/unit/proxy/test_server.py @@ -4905,7 +4905,7 @@ class TestObjectController(unittest.TestCase): req.account = 'a' controller.object_name = 'o' set_http_connect(200, 200, 200, 200, 200, 201, 201, 201, - #act cont objc objc objc obj obj obj + # act cont objc objc objc obj obj obj timestamps=('1', '1', '1', '3', '2', '4', '4', '4')) self.app.memcache.store = {} @@ -4925,7 +4925,7 @@ class TestObjectController(unittest.TestCase): req.account = 'a' controller.object_name = 'o' set_http_connect(200, 200, 200, 200, 200, 200, 200, 201, 201, 201, - #act cont acct cont objc objc objc obj obj obj + # act cont acct cont objc objc objc obj obj obj timestamps=('1', '1', '1', '1', '3', '2', '1', '4', '4', '4')) self.app.memcache.store = {} @@ -9085,7 +9085,7 @@ class TestProxyObjectPerformance(unittest.TestCase): # Small, fast for testing obj_len = 2 * 64 * 1024 # Use 1 GB or more for measurements - #obj_len = 2 * 512 * 1024 * 1024 + # obj_len = 2 * 512 * 1024 * 1024 self.path = '/v1/a/c/o.large' fd.write('PUT %s HTTP/1.1\r\n' 'Host: localhost\r\n' diff --git a/test/unit/test_locale/test_locale.py b/test/unit/test_locale/test_locale.py index a0804ed0eb..ee1416d428 100644 --- a/test/unit/test_locale/test_locale.py +++ b/test/unit/test_locale/test_locale.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -#-*- coding:utf-8 -*- +# coding: utf-8 # Copyright (c) 2013 OpenStack Foundation # # Licensed under the Apache License, Version 2.0 (the "License");