Fix and enable gating on H702

Formatting operations should be outside of localization,
otherwise translation lookup will never find a translated
string as a match. This also fixes H701 alongway.

Change-Id: I6708e0f5b11841b18ba9042ac4958643f91396dd
This commit is contained in:
Dirk Mueller 2013-12-11 22:09:28 +01:00
parent 63ab7f0ae6
commit 2fb875f79f
5 changed files with 24 additions and 26 deletions

View File

@ -673,9 +673,9 @@ class Controller(controller.BaseController):
image_size_store != image_size_meta): image_size_store != image_size_meta):
msg = _("Provided image size must match the stored " msg = _("Provided image size must match the stored "
"image size. (provided size: %(ps)d, " "image size. (provided size: %(ps)d, "
"stored size: %(ss)d)" % "stored size: %(ss)d)") % {
{"ps": image_size_meta, "ps": image_size_meta,
"ss": image_size_store}) "ss": image_size_store}
LOG.debug(msg) LOG.debug(msg)
raise HTTPConflict(explanation=msg, raise HTTPConflict(explanation=msg,
request=req, request=req,

View File

@ -76,9 +76,10 @@ class PropertyRules(object):
raise exception.InvalidPropertyProtectionConfiguration() raise exception.InvalidPropertyProtectionConfiguration()
if self.prop_prot_rule_format not in ['policies', 'roles']: if self.prop_prot_rule_format not in ['policies', 'roles']:
msg = _("Invalid value '%s' for 'property_protection_rule_format'" msg = _("Invalid value '%s' for "
". The permitted values are 'roles' and 'policies'" % "'property_protection_rule_format'. "
self.prop_prot_rule_format) "The permitted values are "
"'roles' and 'policies'") % self.prop_prot_rule_format
LOG.error(msg) LOG.error(msg)
raise exception.InvalidPropertyProtectionConfiguration() raise exception.InvalidPropertyProtectionConfiguration()
@ -93,11 +94,11 @@ class PropertyRules(object):
if permissions: if permissions:
if self.prop_prot_rule_format == 'policies': if self.prop_prot_rule_format == 'policies':
if ',' in permissions: if ',' in permissions:
msg = _("Multiple policies '%s' not allowed for a" LOG.error(
" given operation. Policies can be " _("Multiple policies '%s' not allowed"
"combined in the policy file" % "for a given operation. Policies can be "
permissions) "combined in the policy file"),
LOG.error(msg) permissions)
raise exception.\ raise exception.\
InvalidPropertyProtectionConfiguration() InvalidPropertyProtectionConfiguration()
self.prop_exp_mapping[compiled_rule] = property_exp self.prop_exp_mapping[compiled_rule] = property_exp
@ -110,11 +111,10 @@ class PropertyRules(object):
property_dict[operation] = permissions property_dict[operation] = permissions
else: else:
property_dict[operation] = [] property_dict[operation] = []
msg = _(('Property protection on operation %s for rule ' LOG.warn(
'%s is not found. No role will be allowed to ' _('Property protection on operation %s for rule '
'perform this operation.' % '%s is not found. No role will be allowed to '
(operation, property_exp))) 'perform this operation.'), operation, property_exp)
LOG.warn(msg)
self.rules.append((compiled_rule, property_dict)) self.rules.append((compiled_rule, property_dict))
@ -165,9 +165,9 @@ class PropertyRules(object):
rule_roles = rule.get(action) rule_roles = rule.get(action)
if rule_roles: if rule_roles:
if '@' in rule_roles and '!' in rule_roles: if '@' in rule_roles and '!' in rule_roles:
msg = _("Malformed property protection rule '%s': '@' " msg = _(
"and '!' are mutually exclusive" "Malformed property protection rule '%s': '@' "
% property_name) "and '!' are mutually exclusive") % property_name
LOG.error(msg) LOG.error(msg)
raise webob.exc.HTTPInternalServerError(msg) raise webob.exc.HTTPInternalServerError(msg)
elif '@' in rule_roles: elif '@' in rule_roles:

View File

@ -244,9 +244,9 @@ class ImageMemberRepo(object):
pass pass
else: else:
msg = _('The target member %(member_id)s is already ' msg = _('The target member %(member_id)s is already '
'associated with image %(image_id)s.' % 'associated with image %(image_id)s.') % {
dict(member_id=image_member.member_id, 'member_id': image_member.member_id,
image_id=self.image.image_id)) 'image_id': self.image.image_id}
raise exception.Duplicate(msg) raise exception.Duplicate(msg)
image_member_values = self._format_image_member_to_db(image_member) image_member_values = self._format_image_member_to_db(image_member)

View File

@ -286,7 +286,7 @@ class BaseStore(glance.store.base.Store):
resp_chunk_size=self.CHUNKSIZE) resp_chunk_size=self.CHUNKSIZE)
except swiftclient.ClientException as e: except swiftclient.ClientException as e:
if e.http_status == httplib.NOT_FOUND: if e.http_status == httplib.NOT_FOUND:
msg = _("Swift could not find object %s." % location.obj) msg = _("Swift could not find object %s.") % location.obj
LOG.warn(msg) LOG.warn(msg)
raise exception.NotFound(msg) raise exception.NotFound(msg)
else: else:

View File

@ -44,9 +44,7 @@ commands = {posargs}
# H306 imports not in alphabetical order # H306 imports not in alphabetical order
# H402 one line docstring needs punctuation. # H402 one line docstring needs punctuation.
# H404 multi line docstring should start with a summary # H404 multi line docstring should start with a summary
# H701 Empty localisation string
# H702 Formatting operation should be outside of localization
# H703 multiple positional placeholders # H703 multiple positional placeholders
ignore = E125,E126,E711,E712,F811,F821,F841,H102,H201,H202,H233,H301,H302,H306,H402,H404,H701,H702,H703 ignore = E125,E126,E711,E712,F811,F821,F841,H102,H201,H202,H233,H301,H302,H306,H402,H404,H703
builtins = _ builtins = _
exclude = .venv,.git,.tox,dist,doc,etc,*glance/locale*,*openstack/common*,*lib/python*,*egg,build exclude = .venv,.git,.tox,dist,doc,etc,*glance/locale*,*openstack/common*,*lib/python*,*egg,build