From c0ec97f310bc56c69c22e49928b4aea4cd8458f1 Mon Sep 17 00:00:00 2001 From: Chuck Short Date: Wed, 21 Nov 2012 12:03:07 -0600 Subject: [PATCH] Pin pep8 to 1.3.3 Standardize pep8 to 1.3.3 and cleared up any errors found by pep8 tests. Change-Id: Ib7eb97d0789556d1676ccad58b5d3364065b7d15 Signed-off-by: Chuck Short --- glanceclient/common/base.py | 2 +- glanceclient/common/http.py | 4 +- glanceclient/shell.py | 227 +++++++++++++++++++----------------- glanceclient/v1/images.py | 4 +- glanceclient/v1/shell.py | 4 +- tests/test_http.py | 10 +- tests/v1/test_images.py | 4 +- tests/v2/test_images.py | 2 +- tools/test-requires | 2 +- 9 files changed, 135 insertions(+), 124 deletions(-) diff --git a/glanceclient/common/base.py b/glanceclient/common/base.py index 3cedd32..357b40b 100644 --- a/glanceclient/common/base.py +++ b/glanceclient/common/base.py @@ -100,7 +100,7 @@ class Resource(object): def __repr__(self): reprkeys = sorted(k for k in self.__dict__.keys() if k[0] != '_' and - k != 'manager') + k != 'manager') info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys) return "<%s %s>" % (self.__class__.__name__, info) diff --git a/glanceclient/common/http.py b/glanceclient/common/http.py index 8915107..f06f043 100644 --- a/glanceclient/common/http.py +++ b/glanceclient/common/http.py @@ -54,7 +54,7 @@ class HTTPClient(object): self.connection_class = self.get_connection_class(self.endpoint_scheme) self.connection_kwargs = self.get_connection_kwargs( - self.endpoint_scheme, **kwargs) + self.endpoint_scheme, **kwargs) self.auth_token = kwargs.get('token') @@ -212,7 +212,7 @@ class HTTPClient(object): 'application/octet-stream') if 'body' in kwargs: if (hasattr(kwargs['body'], 'read') - and method.lower() in ('post', 'put')): + and method.lower() in ('post', 'put')): # We use 'Transfer-Encoding: chunked' because # body size may not always be known in advance. kwargs['headers']['Transfer-Encoding'] = 'chunked' diff --git a/glanceclient/shell.py b/glanceclient/shell.py index 17ad33d..4811211 100644 --- a/glanceclient/shell.py +++ b/glanceclient/shell.py @@ -43,203 +43,210 @@ class OpenStackImagesShell(object): # Global arguments parser.add_argument('-h', '--help', - action='store_true', - help=argparse.SUPPRESS, - ) + action='store_true', + help=argparse.SUPPRESS, + ) parser.add_argument('--version', action='version', version=glanceclient.__version__) parser.add_argument('-d', '--debug', - default=bool(utils.env('GLANCECLIENT_DEBUG')), - action='store_true', - help='Defaults to env[GLANCECLIENT_DEBUG]') + default=bool(utils.env('GLANCECLIENT_DEBUG')), + action='store_true', + help='Defaults to env[GLANCECLIENT_DEBUG]') parser.add_argument('-v', '--verbose', - default=False, action="store_true", - help="Print more verbose output") + default=False, action="store_true", + help="Print more verbose output") parser.add_argument('-k', '--insecure', - default=False, - action='store_true', - help="Explicitly allow glanceclient to perform \"insecure\" " - "SSL (https) requests. The server's certificate will " - "not be verified against any certificate authorities. " - "This option should be used with caution.") + default=False, + action='store_true', + help='Explicitly allow glanceclient to perform' + '\"insecure SSL\" (https) requests. The servers' + 'certificate will not be verified against any' + 'certificate authorities. This option should' + 'be used with caution.') parser.add_argument('--cert-file', - help='Path of certificate file to use in SSL connection. This ' - 'file can optionally be prepended with the private key.') + help='Path of certificate file to use in SSL ' + 'connection. This file can optionally be' + 'prepended with the private key.') parser.add_argument('--key-file', - help='Path of client key to use in SSL connection. This option is ' - 'not necessary if your key is prepended to your cert file.') + help='Path of client key to use in SSL ' + 'connection. This option is not necessary ' + 'if your key is prepended to your cert file.') parser.add_argument('--ca-file', - help='Path of CA SSL certificate(s) used to verify the remote ' - 'server\'s certificate. Without this option glance looks ' - 'for the default system CA certificates.') + help='Path of CA SSL certificate(s) used to verify' + 'the remote server\'s certificate. Without this ' + 'option glance looks for the default system ' + 'CA certificates.') parser.add_argument('--timeout', - default=600, - help='Number of seconds to wait for a response') + default=600, + help='Number of seconds to wait for a response') parser.add_argument('--no-ssl-compression', - dest='ssl_compression', - default=True, action='store_false', - help='Disable SSL compression when using https.') + dest='ssl_compression', + default=True, action='store_false', + help='Disable SSL compression when using https.') parser.add_argument('-f', '--force', - dest='force', - default=False, action='store_true', - help='Prevent select actions from requesting ' - 'user confirmation.') + dest='force', + default=False, action='store_true', + help='Prevent select actions from requesting ' + 'user confirmation.') #NOTE(bcwaldon): DEPRECATED parser.add_argument('--dry-run', - default=False, - action='store_true', - help='DEPRECATED! Only used for deprecated legacy commands.') + default=False, + action='store_true', + help='DEPRECATED! Only used for deprecated ' + 'legacy commands.') #NOTE(bcwaldon): DEPRECATED parser.add_argument('--ssl', - dest='use_ssl', - default=False, - action='store_true', - help='DEPRECATED! Send a fully-formed endpoint using ' - '--os-image-url instead.') + dest='use_ssl', + default=False, + action='store_true', + help='DEPRECATED! Send a fully-formed endpoint ' + 'using --os-image-url instead.') #NOTE(bcwaldon): DEPRECATED parser.add_argument('-H', '--host', - metavar='ADDRESS', - help='DEPRECATED! Send a fully-formed endpoint using ' - '--os-image-url instead.') + metavar='ADDRESS', + help='DEPRECATED! Send a fully-formed endpoint ' + 'using --os-image-url instead.') #NOTE(bcwaldon): DEPRECATED parser.add_argument('-p', '--port', - dest='port', - metavar='PORT', - type=int, - default=9292, - help='DEPRECATED! Send a fully-formed endpoint using ' - '--os-image-url instead.') + dest='port', + metavar='PORT', + type=int, + default=9292, + help='DEPRECATED! Send a fully-formed endpoint ' + 'using --os-image-url instead.') parser.add_argument('--os-username', - default=utils.env('OS_USERNAME'), - help='Defaults to env[OS_USERNAME]') + default=utils.env('OS_USERNAME'), + help='Defaults to env[OS_USERNAME]') parser.add_argument('--os_username', - help=argparse.SUPPRESS) + help=argparse.SUPPRESS) #NOTE(bcwaldon): DEPRECATED parser.add_argument('-I', - dest='os_username', - help='DEPRECATED! Use --os-username.') + dest='os_username', + help='DEPRECATED! Use --os-username.') parser.add_argument('--os-password', - default=utils.env('OS_PASSWORD'), - help='Defaults to env[OS_PASSWORD]') + default=utils.env('OS_PASSWORD'), + help='Defaults to env[OS_PASSWORD]') parser.add_argument('--os_password', - help=argparse.SUPPRESS) + help=argparse.SUPPRESS) #NOTE(bcwaldon): DEPRECATED parser.add_argument('-K', - dest='os_password', - help='DEPRECATED! Use --os-password.') + dest='os_password', + help='DEPRECATED! Use --os-password.') parser.add_argument('--os-tenant-id', - default=utils.env('OS_TENANT_ID'), - help='Defaults to env[OS_TENANT_ID]') + default=utils.env('OS_TENANT_ID'), + help='Defaults to env[OS_TENANT_ID]') parser.add_argument('--os_tenant_id', - help=argparse.SUPPRESS) + help=argparse.SUPPRESS) parser.add_argument('--os-tenant-name', - default=utils.env('OS_TENANT_NAME'), - help='Defaults to env[OS_TENANT_NAME]') + default=utils.env('OS_TENANT_NAME'), + help='Defaults to env[OS_TENANT_NAME]') parser.add_argument('--os_tenant_name', - help=argparse.SUPPRESS) + help=argparse.SUPPRESS) #NOTE(bcwaldon): DEPRECATED parser.add_argument('-T', - dest='os_tenant_name', - help='DEPRECATED! Use --os-tenant-name.') + dest='os_tenant_name', + help='DEPRECATED! Use --os-tenant-name.') parser.add_argument('--os-auth-url', - default=utils.env('OS_AUTH_URL'), - help='Defaults to env[OS_AUTH_URL]') + default=utils.env('OS_AUTH_URL'), + help='Defaults to env[OS_AUTH_URL]') parser.add_argument('--os_auth_url', - help=argparse.SUPPRESS) + help=argparse.SUPPRESS) #NOTE(bcwaldon): DEPRECATED parser.add_argument('-N', - dest='os_auth_url', - help='DEPRECATED! Use --os-auth-url.') + dest='os_auth_url', + help='DEPRECATED! Use --os-auth-url.') parser.add_argument('--os-region-name', - default=utils.env('OS_REGION_NAME'), - help='Defaults to env[OS_REGION_NAME]') + default=utils.env('OS_REGION_NAME'), + help='Defaults to env[OS_REGION_NAME]') parser.add_argument('--os_region_name', - help=argparse.SUPPRESS) + help=argparse.SUPPRESS) #NOTE(bcwaldon): DEPRECATED parser.add_argument('-R', - dest='os_region_name', - help='DEPRECATED! Use --os-region-name.') + dest='os_region_name', + help='DEPRECATED! Use --os-region-name.') parser.add_argument('--os-auth-token', - default=utils.env('OS_AUTH_TOKEN'), - help='Defaults to env[OS_AUTH_TOKEN]') + default=utils.env('OS_AUTH_TOKEN'), + help='Defaults to env[OS_AUTH_TOKEN]') parser.add_argument('--os_auth_token', - help=argparse.SUPPRESS) + help=argparse.SUPPRESS) #NOTE(bcwaldon): DEPRECATED parser.add_argument('-A', '--auth_token', - dest='os_auth_token', - help='DEPRECATED! Use --os-auth-token.') + dest='os_auth_token', + help='DEPRECATED! Use --os-auth-token.') parser.add_argument('--os-image-url', - default=utils.env('OS_IMAGE_URL'), - help='Defaults to env[OS_IMAGE_URL]') + default=utils.env('OS_IMAGE_URL'), + help='Defaults to env[OS_IMAGE_URL]') parser.add_argument('--os_image_url', - help=argparse.SUPPRESS) + help=argparse.SUPPRESS) #NOTE(bcwaldon): DEPRECATED parser.add_argument('-U', '--url', - dest='os_image_url', - help='DEPRECATED! Use --os-image-url.') + dest='os_image_url', + help='DEPRECATED! Use --os-image-url.') parser.add_argument('--os-image-api-version', - default=utils.env('OS_IMAGE_API_VERSION', default='1'), - help='Defaults to env[OS_IMAGE_API_VERSION] or 1') + default=utils.env( + 'OS_IMAGE_API_VERSION', default='1'), + help='Defaults to env[OS_IMAGE_API_VERSION] or 1') parser.add_argument('--os_image_api_version', - help=argparse.SUPPRESS) + help=argparse.SUPPRESS) parser.add_argument('--os-service-type', - default=utils.env('OS_SERVICE_TYPE'), - help='Defaults to env[OS_SERVICE_TYPE]') + default=utils.env('OS_SERVICE_TYPE'), + help='Defaults to env[OS_SERVICE_TYPE]') parser.add_argument('--os_service_type', - help=argparse.SUPPRESS) + help=argparse.SUPPRESS) parser.add_argument('--os-endpoint-type', - default=utils.env('OS_ENDPOINT_TYPE'), - help='Defaults to env[OS_ENDPOINT_TYPE]') + default=utils.env('OS_ENDPOINT_TYPE'), + help='Defaults to env[OS_ENDPOINT_TYPE]') parser.add_argument('--os_endpoint_type', - help=argparse.SUPPRESS) + help=argparse.SUPPRESS) #NOTE(bcwaldon): DEPRECATED parser.add_argument('-S', '--os_auth_strategy', - help='DEPRECATED! This option is completely ignored.') + help='DEPRECATED! This option is ' + 'completely ignored.') return parser @@ -264,15 +271,15 @@ class OpenStackImagesShell(object): arguments = getattr(callback, 'arguments', []) subparser = subparsers.add_parser(command, - help=help, - description=desc, - add_help=False, - formatter_class=HelpFormatter - ) + help=help, + description=desc, + add_help=False, + formatter_class=HelpFormatter + ) subparser.add_argument('-h', '--help', - action='help', - help=argparse.SUPPRESS, - ) + action='help', + help=argparse.SUPPRESS, + ) self.subcommands[command] = subparser for (args, kwargs) in arguments: subparser.add_argument(*args, **kwargs) @@ -375,19 +382,23 @@ class OpenStackImagesShell(object): else: if not args.os_username: raise exc.CommandError("You must provide a username via" - " either --os-username or env[OS_USERNAME]") + " either --os-username or " + "env[OS_USERNAME]") if not args.os_password: raise exc.CommandError("You must provide a password via" - " either --os-password or env[OS_PASSWORD]") + " either --os-password or " + "env[OS_PASSWORD]") if not (args.os_tenant_id or args.os_tenant_name): raise exc.CommandError("You must provide a tenant_id via" - " either --os-tenant-id or via env[OS_TENANT_ID]") + " either --os-tenant-id or " + "via env[OS_TENANT_ID]") if not args.os_auth_url: raise exc.CommandError("You must provide an auth url via" - " either --os-auth-url or via env[OS_AUTH_URL]") + " either --os-auth-url or " + "via env[OS_AUTH_URL]") kwargs = { 'username': args.os_username, 'password': args.os_password, @@ -403,7 +414,7 @@ class OpenStackImagesShell(object): token = args.os_auth_token or _ksclient.auth_token endpoint = args.os_image_url or \ - self._get_endpoint(_ksclient, **kwargs) + self._get_endpoint(_ksclient, **kwargs) kwargs = { 'token': token, diff --git a/glanceclient/v1/images.py b/glanceclient/v1/images.py index e833732..26fe7d6 100644 --- a/glanceclient/v1/images.py +++ b/glanceclient/v1/images.py @@ -212,7 +212,7 @@ class ImageManager(base.Manager): hdrs['x-glance-api-copy-from'] = copy_from resp, body_iter = self.api.raw_request( - 'POST', '/v1/images', headers=hdrs, body=image_data) + 'POST', '/v1/images', headers=hdrs, body=image_data) body = json.loads(''.join([c for c in body_iter])) return Image(self, self._format_image_meta_for_user(body['image'])) @@ -250,6 +250,6 @@ class ImageManager(base.Manager): url = '/v1/images/%s' % base.getid(image) resp, body_iter = self.api.raw_request( - 'PUT', url, headers=hdrs, body=image_data) + 'PUT', url, headers=hdrs, body=image_data) body = json.loads(''.join([c for c in body_iter])) return Image(self, self._format_image_meta_for_user(body['image'])) diff --git a/glanceclient/v1/shell.py b/glanceclient/v1/shell.py index 116fff0..ff0c2a6 100644 --- a/glanceclient/v1/shell.py +++ b/glanceclient/v1/shell.py @@ -51,7 +51,7 @@ DISK_FORMATS = ('Acceptable formats: ami, ari, aki, vhd, vmdk, raw, ' help='Filter images to those with a size less than this.') @utils.arg('--property-filter', metavar='', help="Filter images by a user-defined image property.", - action='append', dest='properties', default=[]) + action='append', dest='properties', default=[]) @utils.arg('--page-size', metavar='', default=None, type=int, help='Number of images to request in each paginated request.') @utils.arg('--human-readable', action='store_true', default=False, @@ -59,7 +59,7 @@ DISK_FORMATS = ('Acceptable formats: ami, ari, aki, vhd, vmdk, raw, ' def do_image_list(gc, args): """List images you can access.""" filter_keys = ['name', 'status', 'container_format', 'disk_format', - 'size_min', 'size_max'] + 'size_min', 'size_max'] filter_items = [(key, getattr(args, key)) for key in filter_keys] filters = dict([item for item in filter_items if item[1] is not None]) diff --git a/tests/test_http.py b/tests/test_http.py index 7fd42e0..783f6ca 100644 --- a/tests/test_http.py +++ b/tests/test_http.py @@ -37,10 +37,10 @@ class TestClient(unittest.TestCase): m = mox.Mox() m.StubOutWithMock(httplib.HTTPConnection, 'request') httplib.HTTPConnection.request( - mox.IgnoreArg(), - mox.IgnoreArg(), - headers=mox.IgnoreArg(), - ).AndRaise(socket.error()) + mox.IgnoreArg(), + mox.IgnoreArg(), + headers=mox.IgnoreArg(), + ).AndRaise(socket.error()) m.ReplayAll() try: client.json_request('GET', '/v1/images/detail?limit=20') @@ -51,7 +51,7 @@ class TestClient(unittest.TestCase): self.fail('An exception should have bypassed this line.') except exc.CommunicationError, comm_err: fail_msg = ("Exception message '%s' should contain '%s'" % - (comm_err.message, endpoint)) + (comm_err.message, endpoint)) self.assertTrue(endpoint in comm_err.message, fail_msg) finally: m.UnsetStubs() diff --git a/tests/v1/test_images.py b/tests/v1/test_images.py index 759010f..73655c2 100644 --- a/tests/v1/test_images.py +++ b/tests/v1/test_images.py @@ -174,7 +174,7 @@ fixtures = { 'DELETE': ({}, None), }, '/v1/images/2': { - 'HEAD': ( + 'HEAD': ( { 'x-image-meta-id': '2' }, @@ -188,7 +188,7 @@ fixtures = { ), }, '/v1/images/3': { - 'HEAD': ( + 'HEAD': ( { 'x-image-meta-id': '3' }, diff --git a/tests/v2/test_images.py b/tests/v2/test_images.py index ef3869e..07bcf6b 100644 --- a/tests/v2/test_images.py +++ b/tests/v2/test_images.py @@ -43,7 +43,7 @@ fixtures = { {}, { 'images': [ - { + { 'id': '3a4560a1-e585-443e-9b39-553b46ec92d1', 'name': 'image-1', }, diff --git a/tools/test-requires b/tools/test-requires index 18557f0..7e6512f 100644 --- a/tools/test-requires +++ b/tools/test-requires @@ -6,6 +6,6 @@ nose-exclude nosexcover openstack.nose_plugin nosehtmloutput -pep8==1.2 +pep8==1.3.3 setuptools-git>=0.4 sphinx>=1.1.2