summaryrefslogtreecommitdiffstats
path: root/keystone/common
diff options
context:
space:
mode:
authorDolph Mathews <dolph.mathews@gmail.com>2013-05-23 14:33:55 -0500
committerGerrit Code Review <review@openstack.org>2013-05-23 23:48:43 +0000
commitf9b535c84ed22f6831165cb0807029a44a01bddb (patch)
tree8ed4140ea358a24751c7ffeec2ffa24bdaa2f498 /keystone/common
parent67175a667308e534c1d55931322bbd36e1e0a7c5 (diff)
downloadkeystone-f9b535c84ed22f6831165cb0807029a44a01bddb.tar.gz
keystone-f9b535c84ed22f6831165cb0807029a44a01bddb.tar.xz
keystone-f9b535c84ed22f6831165cb0807029a44a01bddb.zip
consistent i18n placeholders (flake8 H701, H702, H703)
- eliminates ambiguously defined keywords in i18n strings which may become incorrectly ordered in a corresponding translation. - ensures formatting operations occur outside of i18n calls - use bare multiline string concatenation instead of 'ab' + \n 'cd' - eliminates an 'empty localization string' (passing a variable to i18n function) Change-Id: I0d78b978cc730e5fb892b80dfacaaf6687cd80be
Diffstat (limited to 'keystone/common')
-rw-r--r--keystone/common/controller.py7
-rw-r--r--keystone/common/ldap/core.py43
-rw-r--r--keystone/common/ldap/fakeldap.py18
-rw-r--r--keystone/common/sql/nova.py17
-rw-r--r--keystone/common/utils.py9
-rw-r--r--keystone/common/wsgi.py5
6 files changed, 60 insertions, 39 deletions
diff --git a/keystone/common/controller.py b/keystone/common/controller.py
index ab6b5b53..9c28f081 100644
--- a/keystone/common/controller.py
+++ b/keystone/common/controller.py
@@ -15,10 +15,9 @@ DEFAULT_DOMAIN_ID = CONF.identity.default_domain_id
def _build_policy_check_credentials(self, action, context, kwargs):
-
- LOG.debug(_('RBAC: Authorizing %s(%s)') % (
- action,
- ', '.join(['%s=%s' % (k, kwargs[k]) for k in kwargs])))
+ LOG.debug(_('RBAC: Authorizing %(action)s(%(kwargs)s)') % {
+ 'action': action,
+ 'kwargs': ', '.join(['%s=%s' % (k, kwargs[k]) for k in kwargs])})
try:
token_ref = self.token_api.get_token(
diff --git a/keystone/common/ldap/core.py b/keystone/common/ldap/core.py
index da3be1df..b9b8d08b 100644
--- a/keystone/common/ldap/core.py
+++ b/keystone/common/ldap/core.py
@@ -84,17 +84,21 @@ def parse_tls_cert(opt):
try:
return LDAP_TLS_CERTS[opt]
except KeyError:
- raise ValueError((_('Invalid LDAP tls certs option: %s. '
- 'Choose one of: ') %
- opt) + ', '.join(LDAP_TLS_CERTS.keys()))
+ raise ValueError(_(
+ 'Invalid LDAP TLS certs option: %(option). '
+ 'Choose one of: %(options)s') % {
+ 'option': opt,
+ 'options': ', '.join(LDAP_TLS_CERTS.keys())})
def ldap_scope(scope):
try:
return LDAP_SCOPES[scope]
except KeyError:
- raise ValueError(_('Invalid LDAP scope: %s. Choose one of: ' % scope) +
- ', '.join(LDAP_SCOPES.keys()))
+ raise ValueError(
+ _('Invalid LDAP scope: %(scope)s. Choose one of: %(options)s') % {
+ 'scope': scope,
+ 'options': ', '.join(LDAP_SCOPES.keys())})
class BaseLdap(object):
@@ -182,9 +186,10 @@ class BaseLdap(object):
try:
ldap_attr, attr_map = item.split(':')
except Exception:
- LOG.warn(_('Invalid additional attribute mapping: "%s". '
- 'Format must be ' +
- '<ldap_attribute>:<keystone_attribute>') % item)
+ LOG.warn(_(
+ 'Invalid additional attribute mapping: "%s". '
+ 'Format must be <ldap_attribute>:<keystone_attribute>')
+ % item)
continue
if attr_map not in self.attribute_mapping:
LOG.warn(_('Invalid additional attribute mapping: "%(item)s". '
@@ -500,16 +505,19 @@ class LdapWrapper(object):
if kind != 'userPassword'
else ['****'])
for kind, values in ldap_attrs]
- LOG.debug(_('LDAP add: dn=%s, attrs=%s'), dn, sane_attrs)
+ LOG.debug(_('LDAP add: dn=%(dn)s, attrs=%(attrs)s') % {
+ 'dn': dn, 'attrs': sane_attrs})
return self.conn.add_s(dn, ldap_attrs)
def search_s(self, dn, scope, query, attrlist=None):
if LOG.isEnabledFor(logging.DEBUG):
- LOG.debug(_('LDAP search: dn=%s, scope=%s, query=%s, attrs=%s'),
- dn,
- scope,
- query,
- attrlist)
+ LOG.debug(_(
+ 'LDAP search: dn=%(dn)s, scope=%(scope)s, query=%(query)s, '
+ 'attrs=%(attrs)s') % {
+ 'dn': dn,
+ 'scope': scope,
+ 'query': query,
+ 'attrlist': attrlist})
if self.page_size:
res = self.paged_search_s(dn, scope, query, attrlist)
else:
@@ -573,7 +581,8 @@ class LdapWrapper(object):
sane_modlist = [(op, kind, (values if kind != 'userPassword'
else ['****']))
for op, kind, values in ldap_modlist]
- LOG.debug(_("LDAP modify: dn=%s, modlist=%s"), dn, sane_modlist)
+ LOG.debug(_('LDAP modify: dn=%(dn)s, modlist=%(modlist)s') % {
+ 'dn': dn, 'modlist': sane_modlist})
return self.conn.modify_s(dn, ldap_modlist)
@@ -582,7 +591,9 @@ class LdapWrapper(object):
return self.conn.delete_s(dn)
def delete_ext_s(self, dn, serverctrls):
- LOG.debug(_("LDAP delete_ext: dn=%s, serverctrls=%s"), dn, serverctrls)
+ LOG.debug(
+ _('LDAP delete_ext: dn=%(dn)s, serverctrls=%(serverctrls)s') % {
+ 'dn': dn, 'serverctrls': serverctrls})
return self.conn.delete_ext_s(dn, serverctrls)
def _disable_paging(self):
diff --git a/keystone/common/ldap/fakeldap.py b/keystone/common/ldap/fakeldap.py
index 56eedee1..f6c95895 100644
--- a/keystone/common/ldap/fakeldap.py
+++ b/keystone/common/ldap/fakeldap.py
@@ -187,7 +187,8 @@ class FakeLdap(object):
raise ldap.SERVER_DOWN
key = '%s%s' % (self.__prefix, dn)
- LOG.debug(_('FakeLdap add item: dn=%s, attrs=%s'), dn, attrs)
+ LOG.debug(_('FakeLdap add item: dn=%(dn)s, attrs=%(attrs)s') % {
+ 'dn': dn, 'attrs': attrs})
if key in self.db:
LOG.debug(_('FakeLdap add item failed: dn=%s is'
' already in store.'), dn)
@@ -236,7 +237,8 @@ class FakeLdap(object):
raise ldap.SERVER_DOWN
key = '%s%s' % (self.__prefix, dn)
- LOG.debug(_('FakeLdap modify item: dn=%s attrs=%s'), dn, attrs)
+ LOG.debug(_('FakeLdap modify item: dn=%(dn)s attrs=%(attrs)s') % {
+ 'dn': dn, 'attrs': attrs})
try:
entry = self.db[key]
except KeyError:
@@ -268,9 +270,10 @@ class FakeLdap(object):
try:
values.remove(val)
except ValueError:
- LOG.debug(_('FakeLdap modify item failed:'
- ' item has no attribute "%s" with'
- ' value "%s" to delete'), k, val)
+ LOG.debug(_('FakeLdap modify item failed: '
+ 'item has no attribute "%(k)s" with '
+ 'value "%(v)s" to delete') % {
+ 'k': k, 'v': val})
raise ldap.NO_SUCH_ATTRIBUTE
else:
LOG.debug(_('FakeLdap modify item failed: unknown'
@@ -293,8 +296,9 @@ class FakeLdap(object):
if server_fail:
raise ldap.SERVER_DOWN
- LOG.debug(_('FakeLdap search at dn=%s scope=%s query=%s'),
- dn, SCOPE_NAMES.get(scope, scope), query)
+ LOG.debug(
+ _('FakeLdap search at dn=%(dn)s scope=%(scope)s query=%(query)s') %
+ {'dn': dn, 'scope': SCOPE_NAMES.get(scope, scope), 'query': query})
if scope == ldap.SCOPE_BASE:
try:
item_dict = self.db['%s%s' % (self.__prefix, dn)]
diff --git a/keystone/common/sql/nova.py b/keystone/common/sql/nova.py
index 968c542f..7e4d9b37 100644
--- a/keystone/common/sql/nova.py
+++ b/keystone/common/sql/nova.py
@@ -85,7 +85,8 @@ def _create_memberships(api, memberships, user_map, tenant_map):
for membership in memberships:
user_id = user_map[membership['user_id']]
tenant_id = tenant_map[membership['tenant_id']]
- LOG.debug(_('Add user %s to tenant %s') % (user_id, tenant_id))
+ LOG.debug(_('Add user %(user_id)s to tenant %(tenant_id)s') % {
+ 'user_id': user_id, 'tenant_id': tenant_id})
api.add_user_to_project(tenant_id, user_id)
@@ -110,8 +111,12 @@ def _assign_roles(api, assignments, role_map, user_map, tenant_map):
role_id = role_map[assignment['role']]
user_id = user_map[assignment['user_id']]
tenant_id = tenant_map[assignment['tenant_id']]
- LOG.debug(_('Assign role %s to user %s on tenant %s') %
- (role_id, user_id, tenant_id))
+ LOG.debug(_(
+ 'Assign role %(role_id)s to user %(user_id)s on tenant '
+ '%(tenant_id)s') % {
+ 'role_id': role_id,
+ 'user_id': user_id,
+ 'tenant_id': tenant_id})
api.add_role_to_user_and_project(user_id, tenant_id, role_id)
@@ -125,6 +130,8 @@ def _create_ec2_creds(ec2_api, identity_api, ec2_creds, user_map):
'user_id': user_id,
'tenant_id': tenant_id,
}
- LOG.debug(_('Creating ec2 cred for user %s and tenant %s') %
- (user_id, tenant_id))
+ LOG.debug(_(
+ 'Creating ec2 cred for user %(user_id)s and tenant '
+ '%(tenant_id)s') % {
+ 'user_id': user_id, 'tenant_id': tenant_id})
ec2_api.create_credential(None, cred_dict)
diff --git a/keystone/common/utils.py b/keystone/common/utils.py
index 13a4cc40..9536cdc7 100644
--- a/keystone/common/utils.py
+++ b/keystone/common/utils.py
@@ -217,10 +217,6 @@ def hash_signed_token(signed_text):
def setup_remote_pydev_debug():
if CONF.pydev_debug_host and CONF.pydev_debug_port:
- error_msg = ('Error setting up the debug environment. Verify that the'
- ' option --debug-url has the format <host>:<port> and '
- 'that a debugger processes is listening on that port.')
-
try:
try:
from pydevd import pydevd
@@ -233,7 +229,10 @@ def setup_remote_pydev_debug():
stderrToServer=True)
return True
except:
- LOG.exception(_(error_msg))
+ LOG.exception(_(
+ 'Error setting up the debug environment. Verify that the '
+ 'option --debug-url has the format <host>:<port> and that a '
+ 'debugger processes is listening on that port.'))
raise
diff --git a/keystone/common/wsgi.py b/keystone/common/wsgi.py
index 4ea05628..a07ae117 100644
--- a/keystone/common/wsgi.py
+++ b/keystone/common/wsgi.py
@@ -181,8 +181,9 @@ class Application(BaseApplication):
try:
result = method(context, **params)
except exception.Unauthorized as e:
- LOG.warning(_("Authorization failed. %s from %s")
- % (e, req.environ['REMOTE_ADDR']))
+ LOG.warning(
+ _('Authorization failed. %(exception)s from %(remote_addr)s') %
+ {'exception': e, 'remote_addr': req.environ['REMOTE_ADDR']})
return render_exception(e)
except exception.Error as e:
LOG.warning(e)