Move string expansion outside localisation (H702)

String expansion should be done outside localisation call (_()),
otherwise there will never be a matching string found in the
catalogue.

Also enable gating on this Hacking check (H702).

Change-Id: Ie7c89fbfb52629e75d5e68e9afda8bcf50bf4cdd
This commit is contained in:
Dirk Mueller 2013-08-30 23:56:55 +02:00
parent 3d36a76156
commit 00f9d718d2
4 changed files with 14 additions and 12 deletions

View File

@ -119,9 +119,9 @@ class ContainerController(object):
# but if there is, we want to know about it.
self.logger.error(_('ERROR Account update failed: different '
'numbers of hosts and devices in request: '
'"%s" vs "%s"' %
(req.headers.get('X-Account-Host', ''),
req.headers.get('X-Account-Device', ''))))
'"%s" vs "%s"') %
(req.headers.get('X-Account-Host', ''),
req.headers.get('X-Account-Device', '')))
return HTTPBadRequest(req=req)
if account_partition:

View File

@ -194,9 +194,9 @@ class ObjectController(object):
# but if there is, we want to know about it.
self.logger.error(_('ERROR Container update failed: different '
'numbers of hosts and devices in request: '
'"%s" vs "%s"' %
(headers_in.get('X-Container-Host', ''),
headers_in.get('X-Container-Device', ''))))
'"%s" vs "%s"') %
(headers_in.get('X-Container-Host', ''),
headers_in.get('X-Container-Device', '')))
return
if contpartition:

View File

@ -217,24 +217,24 @@ class SegmentedIterable(object):
if sub_etag != self.segment_dict['hash']:
raise SegmentError(_(
'Object segment does not match sub-slo: '
'%(path)s etag: %(r_etag)s != %(s_etag)s.' %
'%(path)s etag: %(r_etag)s != %(s_etag)s.') %
{'path': path, 'r_etag': sub_etag,
's_etag': self.segment_dict['hash']}))
's_etag': self.segment_dict['hash']})
return self._load_next_segment()
except ValueError:
raise SegmentError(_(
'Sub SLO has invalid manifest: %s' % path))
'Sub SLO has invalid manifest: %s') % path)
elif resp.etag != self.segment_dict['hash'] or \
resp.content_length != self.segment_dict['bytes']:
raise SegmentError(_(
'Object segment no longer valid: '
'%(path)s etag: %(r_etag)s != %(s_etag)s or '
'%(r_size)s != %(s_size)s.' %
'%(r_size)s != %(s_size)s.') %
{'path': path, 'r_etag': resp.etag,
'r_size': resp.content_length,
's_etag': self.segment_dict['hash'],
's_size': self.segment_dict['bytes']}))
's_size': self.segment_dict['bytes']})
self.segment_iter = resp.app_iter
# See NOTE: swift_conn at top of file about this.
self.segment_iter_swift_conn = getattr(resp, 'swift_conn', None)

View File

@ -28,6 +28,8 @@ commands =
commands = {posargs}
[flake8]
ignore = H203,H301,H302,H306,H402,H404,H702,H703
# TODO(dmllr): Review some of the hacking warnings and fix if applicable
# H233 Use print function, not print operator
ignore = H203,H233,H301,H302,H306,H402,H404,H703
exclude = .venv,.tox,dist,doc,*egg
show-source = True