From 379354b935fe02a72ffe64bfdce6d397bcfad2b1 Mon Sep 17 00:00:00 2001 From: Dolph Mathews Date: Wed, 29 Aug 2012 03:57:15 -0500 Subject: [PATCH] HACKING: Use single quotes Change-Id: Ibe5422affe13aac0d43c159a8b8ff2f35f4a72a3 --- HACKING.rst | 3 +++ keystone/service.py | 62 ++++++++++++++++++++++----------------------- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/HACKING.rst b/HACKING.rst index da11ca19e2..96f3421ae4 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -15,6 +15,7 @@ General - Include your name with TODOs as in "#TODO(termie)" - Do not name anything the same name as a built-in or reserved word - When defining global constants, define them before functions and classes +- Avoid using "double quotes" where you can reasonably use 'single quotes' TODO vs FIXME @@ -25,6 +26,7 @@ TODO vs FIXME - FIXME(name): implies that the method/function/etc shouldn't be used until that code is resolved and bug fixed. + Logging ------- @@ -36,6 +38,7 @@ Use the built-in logging module, and ensure you ``getLogger``:: LOG.debug('Foobar') + Imports ------- diff --git a/keystone/service.py b/keystone/service.py index 65e336cd66..b25ffb8c4d 100644 --- a/keystone/service.py +++ b/keystone/service.py @@ -163,7 +163,7 @@ class AdminVersionRouter(wsgi.ComposingRouter): class VersionController(wsgi.Application): def __init__(self, version_type): self.catalog_api = catalog.Manager() - self.url_key = "%sURL" % version_type + self.url_key = '%sURL' % version_type super(VersionController, self).__init__() @@ -186,35 +186,35 @@ class VersionController(wsgi.Application): versions = {} versions['v2.0'] = { - "id": "v2.0", - "status": "beta", - "updated": "2011-11-19T00:00:00Z", - "links": [ + 'id': 'v2.0', + 'status': 'beta', + 'updated': '2011-11-19T00:00:00Z', + 'links': [ { - "rel": "self", - "href": identity_url, + 'rel': 'self', + 'href': identity_url, }, { - "rel": "describedby", - "type": "text/html", - "href": "http://docs.openstack.org/api/openstack-" - "identity-service/2.0/content/" + 'rel': 'describedby', + 'type': 'text/html', + 'href': 'http://docs.openstack.org/api/openstack-' + 'identity-service/2.0/content/' }, { - "rel": "describedby", - "type": "application/pdf", - "href": "http://docs.openstack.org/api/openstack-" - "identity-service/2.0/identity-dev-guide-" - "2.0.pdf" + 'rel': 'describedby', + 'type': 'application/pdf', + 'href': 'http://docs.openstack.org/api/openstack-' + 'identity-service/2.0/identity-dev-guide-' + '2.0.pdf' } ], - "media-types": [ + 'media-types': [ { - "base": "application/json", - "type": "application/vnd.openstack.identity-v2.0" - "+json" + 'base': 'application/json', + 'type': 'application/vnd.openstack.identity-v2.0' + '+json' }, { - "base": "application/xml", - "type": "application/vnd.openstack.identity-v2.0" - "+xml" + 'base': 'application/xml', + 'type': 'application/vnd.openstack.identity-v2.0' + '+xml' } ] } @@ -224,15 +224,15 @@ class VersionController(wsgi.Application): def get_versions(self, context): versions = self._get_versions_list(context) return wsgi.render_response(status=(300, 'Multiple Choices'), body={ - "versions": { - "values": versions.values() + 'versions': { + 'values': versions.values() } }) def get_version(self, context): versions = self._get_versions_list(context) return wsgi.render_response(body={ - "version": versions['v2.0'] + 'version': versions['v2.0'] }) @@ -433,17 +433,17 @@ class TokenController(wsgi.Application): service_catalog = self._format_catalog(catalog_ref) token_data['access']['serviceCatalog'] = service_catalog - if config.CONF.signing.token_format == "UUID": + if config.CONF.signing.token_format == 'UUID': token_id = uuid.uuid4().hex - elif config.CONF.signing.token_format == "PKI": + elif config.CONF.signing.token_format == 'PKI': token_id = cms.cms_sign_token(json.dumps(token_data), config.CONF.signing.certfile, config.CONF.signing.keyfile) else: raise exception.UnexpectedError( - "Invalid value for token_format: %s." - " Allowed values are PKI or UUID." % + 'Invalid value for token_format: %s.' + ' Allowed values are PKI or UUID.' % config.CONF.signing.token_format) try: self.token_api.create_token( @@ -509,7 +509,7 @@ class TokenController(wsgi.Application): Returns metadata about the token along any associated roles. """ - belongs_to = context['query_string'].get("belongsTo") + belongs_to = context['query_string'].get('belongsTo') token_ref = self._get_token_ref(context, token_id, belongs_to) # TODO(termie): optimize this call at some point and put it into the