cinder/.: replace 'locals()' with explicit values

Help bring source code into compliance with the Cinder Style Commandments:
https://github.com/openstack/cinder/blob/master/HACKING.rst

This change covers all affected source directly in the top-level directory
of the cinder module, i.e. cinder/*.py

Partially fixes: bug #1190748

Change-Id: Ice5efc5eda7189969af6a9b722344fad7aa49ff0
This commit is contained in:
Andrew Forrest 2013-06-15 11:09:33 -07:00
parent b1b06e33b0
commit 77be2761dc
5 changed files with 33 additions and 15 deletions

View File

@ -66,7 +66,13 @@ class ProcessExecutionError(IOError):
exit_code = '-'
message = _('%(description)s\nCommand: %(cmd)s\n'
'Exit code: %(exit_code)s\nStdout: %(stdout)r\n'
'Stderr: %(stderr)r') % locals()
'Stderr: %(stderr)r') % {
'description': description,
'cmd': cmd,
'exit_code': exit_code,
'stdout': stdout,
'stderr': stderr,
}
IOError.__init__(self, message)

View File

@ -702,7 +702,7 @@ class QuotaEngine(object):
expire=expire,
project_id=project_id)
LOG.debug(_("Created reservations %(reservations)s") % locals())
LOG.debug(_("Created reservations %s") % reservations)
return reservations
@ -724,8 +724,7 @@ class QuotaEngine(object):
# usage resynchronization and the reservation expiration
# mechanisms will resolve the issue. The exception is
# logged, however, because this is less than optimal.
LOG.exception(_("Failed to commit reservations "
"%(reservations)s") % locals())
LOG.exception(_("Failed to commit reservations %s") % reservations)
def rollback(self, context, reservations, project_id=None):
"""Roll back reservations.
@ -746,7 +745,7 @@ class QuotaEngine(object):
# mechanisms will resolve the issue. The exception is
# logged, however, because this is less than optimal.
LOG.exception(_("Failed to roll back reservations "
"%(reservations)s") % locals())
"%s") % reservations)
def destroy_all_by_project(self, context, project_id):
"""

View File

@ -270,10 +270,12 @@ class ProcessLauncher(object):
code = 0
if os.WIFSIGNALED(status):
sig = os.WTERMSIG(status)
LOG.info(_('Child %(pid)d killed by signal %(sig)d'), locals())
LOG.info(_('Child %(pid)d killed by signal %(sig)d'),
{'pid': pid, 'sig': sig})
else:
code = os.WEXITSTATUS(status)
LOG.info(_('Child %(pid)d exited with status %(code)d'), locals())
LOG.info(_('Child %(pid)d exited with status %(code)d'),
{'pid': pid, 'code': code})
if pid not in self.children:
LOG.warning(_('pid %d not in child list'), pid)
@ -613,9 +615,10 @@ def wait():
# should use secret flag when switch over to openstack-common
if ("_password" in flag or "_key" in flag or
(flag == "sql_connection" and "mysql:" in flag_get)):
LOG.debug(_('%(flag)s : FLAG SET ') % locals())
LOG.debug(_('%s : FLAG SET ') % flag)
else:
LOG.debug('%(flag)s : %(flag_get)s' % locals())
LOG.debug('%(flag)s : %(flag_get)s' %
{'flag': flag, 'flag_get': flag_get})
try:
_launcher.wait()
except KeyboardInterrupt:

View File

@ -223,7 +223,8 @@ class TestCase(testtools.TestCase):
d1str = str(d1)
d2str = str(d2)
base_msg = ('Dictionaries do not match. %(msg)s d1: %(d1str)s '
'd2: %(d2str)s' % locals())
'd2: %(d2str)s' %
{'msg': msg, 'd1str': d1str, 'd2str': d2str})
raise AssertionError(base_msg)
d1keys = set(d1.keys())
@ -232,7 +233,8 @@ class TestCase(testtools.TestCase):
d1only = d1keys - d2keys
d2only = d2keys - d1keys
raise_assertion('Keys in d1 and not d2: %(d1only)s. '
'Keys in d2 and not d1: %(d2only)s' % locals())
'Keys in d2 and not d1: %(d2only)s' %
{'d1only': d1only, 'd2only': d2only})
for key in d1keys:
d1value = d1[key]
@ -254,7 +256,12 @@ class TestCase(testtools.TestCase):
continue
elif d1value != d2value:
raise_assertion("d1['%(key)s']=%(d1value)s != "
"d2['%(key)s']=%(d2value)s" % locals())
"d2['%(key)s']=%(d2value)s" %
{
'key': key,
'd1value': d1value,
'd2value': d2value,
})
def assertDictListMatch(self, L1, L2, approx_equal=False, tolerance=0.001):
"""Assert a list of dicts are equivalent."""
@ -262,14 +269,16 @@ class TestCase(testtools.TestCase):
L1str = str(L1)
L2str = str(L2)
base_msg = ('List of dictionaries do not match: %(msg)s '
'L1: %(L1str)s L2: %(L2str)s' % locals())
'L1: %(L1str)s L2: %(L2str)s' %
{'msg': msg, 'L1str': L1str, 'L2str': L2str})
raise AssertionError(base_msg)
L1count = len(L1)
L2count = len(L2)
if L1count != L2count:
raise_assertion('Length mismatch: len(L1)=%(L1count)d != '
'len(L2)=%(L2count)d' % locals())
'len(L2)=%(L2count)d' %
{'L1count': L1count, 'L2count': L2count})
for d1, d2 in zip(L1, L2):
self.assertDictMatch(d1, d2, approx_equal=approx_equal,

View File

@ -530,7 +530,8 @@ def get_my_linklocal(interface):
% if_str)
except Exception as ex:
raise exception.Error(_("Couldn't get Link Local IP of %(interface)s"
" :%(ex)s") % locals())
" :%(ex)s") %
{'interface': interface, 'ex': ex, })
def parse_mailmap(mailmap='.mailmap'):